IUserManager.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. namespace OCP;
  30. /**
  31. * Class Manager
  32. *
  33. * Hooks available in scope \OC\User:
  34. * - preSetPassword(\OC\User\User $user, string $password, string $recoverPassword)
  35. * - postSetPassword(\OC\User\User $user, string $password, string $recoverPassword)
  36. * - preDelete(\OC\User\User $user)
  37. * - postDelete(\OC\User\User $user)
  38. * - preCreateUser(string $uid, string $password)
  39. * - postCreateUser(\OC\User\User $user, string $password)
  40. *
  41. * @package OC\User
  42. * @since 8.0.0
  43. */
  44. interface IUserManager {
  45. /**
  46. * register a user backend
  47. *
  48. * @param \OCP\UserInterface $backend
  49. * @since 8.0.0
  50. */
  51. public function registerBackend($backend);
  52. /**
  53. * Get the active backends
  54. * @return \OCP\UserInterface[]
  55. * @since 8.0.0
  56. */
  57. public function getBackends();
  58. /**
  59. * remove a user backend
  60. *
  61. * @param \OCP\UserInterface $backend
  62. * @since 8.0.0
  63. */
  64. public function removeBackend($backend);
  65. /**
  66. * remove all user backends
  67. * @since 8.0.0
  68. */
  69. public function clearBackends() ;
  70. /**
  71. * get a user by user id
  72. *
  73. * @param string $uid
  74. * @return \OCP\IUser|null Either the user or null if the specified user does not exist
  75. * @since 8.0.0
  76. */
  77. public function get($uid);
  78. /**
  79. * check if a user exists
  80. *
  81. * @param string $uid
  82. * @return bool
  83. * @since 8.0.0
  84. */
  85. public function userExists($uid);
  86. /**
  87. * Check if the password is valid for the user
  88. *
  89. * @param string $loginName
  90. * @param string $password
  91. * @return mixed the User object on success, false otherwise
  92. * @since 8.0.0
  93. */
  94. public function checkPassword($loginName, $password);
  95. /**
  96. * search by user id
  97. *
  98. * @param string $pattern
  99. * @param int $limit
  100. * @param int $offset
  101. * @return \OCP\IUser[]
  102. * @since 8.0.0
  103. */
  104. public function search($pattern, $limit = null, $offset = null);
  105. /**
  106. * search by displayName
  107. *
  108. * @param string $pattern
  109. * @param int $limit
  110. * @param int $offset
  111. * @return \OCP\IUser[]
  112. * @since 8.0.0
  113. */
  114. public function searchDisplayName($pattern, $limit = null, $offset = null);
  115. /**
  116. * @param string $uid
  117. * @param string $password
  118. * @throws \InvalidArgumentException
  119. * @return bool|\OCP\IUser the created user of false
  120. * @since 8.0.0
  121. */
  122. public function createUser($uid, $password);
  123. /**
  124. * @param string $uid
  125. * @param string $password
  126. * @param UserInterface $backend
  127. * @return IUser|null
  128. * @throws \InvalidArgumentException
  129. * @since 12.0.0
  130. */
  131. public function createUserFromBackend($uid, $password, UserInterface $backend);
  132. /**
  133. * returns how many users per backend exist (if supported by backend)
  134. *
  135. * @return array an array of backend class as key and count number as value
  136. * @since 8.0.0
  137. */
  138. public function countUsers();
  139. /**
  140. * @param \Closure $callback
  141. * @param string $search
  142. * @since 9.0.0
  143. */
  144. public function callForAllUsers(\Closure $callback, $search = '');
  145. /**
  146. * returns how many users have logged in once
  147. *
  148. * @return int
  149. * @since 11.0.0
  150. */
  151. public function countDisabledUsers();
  152. /**
  153. * returns how many users have logged in once
  154. *
  155. * @return int
  156. * @since 11.0.0
  157. */
  158. public function countSeenUsers();
  159. /**
  160. * @param \Closure $callback
  161. * @since 11.0.0
  162. */
  163. public function callForSeenUsers(\Closure $callback);
  164. /**
  165. * @param string $email
  166. * @return IUser[]
  167. * @since 9.1.0
  168. */
  169. public function getByEmail($email);
  170. }