IUserManager.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. * - assignedUserId(string $uid)
  41. * - preUnassignedUserId(string $uid)
  42. * - postUnassignedUserId(string $uid)
  43. *
  44. * @package OC\User
  45. * @since 8.0.0
  46. */
  47. interface IUserManager {
  48. /**
  49. * register a user backend
  50. *
  51. * @param \OCP\UserInterface $backend
  52. * @since 8.0.0
  53. */
  54. public function registerBackend($backend);
  55. /**
  56. * Get the active backends
  57. * @return \OCP\UserInterface[]
  58. * @since 8.0.0
  59. */
  60. public function getBackends();
  61. /**
  62. * remove a user backend
  63. *
  64. * @param \OCP\UserInterface $backend
  65. * @since 8.0.0
  66. */
  67. public function removeBackend($backend);
  68. /**
  69. * remove all user backends
  70. * @since 8.0.0
  71. */
  72. public function clearBackends() ;
  73. /**
  74. * get a user by user id
  75. *
  76. * @param string $uid
  77. * @return \OCP\IUser|null Either the user or null if the specified user does not exist
  78. * @since 8.0.0
  79. */
  80. public function get($uid);
  81. /**
  82. * check if a user exists
  83. *
  84. * @param string $uid
  85. * @return bool
  86. * @since 8.0.0
  87. */
  88. public function userExists($uid);
  89. /**
  90. * Check if the password is valid for the user
  91. *
  92. * @param string $loginName
  93. * @param string $password
  94. * @return mixed the User object on success, false otherwise
  95. * @since 8.0.0
  96. */
  97. public function checkPassword($loginName, $password);
  98. /**
  99. * search by user id
  100. *
  101. * @param string $pattern
  102. * @param int $limit
  103. * @param int $offset
  104. * @return \OCP\IUser[]
  105. * @since 8.0.0
  106. */
  107. public function search($pattern, $limit = null, $offset = null);
  108. /**
  109. * search by displayName
  110. *
  111. * @param string $pattern
  112. * @param int $limit
  113. * @param int $offset
  114. * @return \OCP\IUser[]
  115. * @since 8.0.0
  116. */
  117. public function searchDisplayName($pattern, $limit = null, $offset = null);
  118. /**
  119. * @param string $uid
  120. * @param string $password
  121. * @throws \InvalidArgumentException
  122. * @return bool|\OCP\IUser the created user or false
  123. * @since 8.0.0
  124. */
  125. public function createUser($uid, $password);
  126. /**
  127. * @param string $uid
  128. * @param string $password
  129. * @param UserInterface $backend
  130. * @return IUser|null
  131. * @throws \InvalidArgumentException
  132. * @since 12.0.0
  133. */
  134. public function createUserFromBackend($uid, $password, UserInterface $backend);
  135. /**
  136. * returns how many users per backend exist (if supported by backend)
  137. *
  138. * @return array an array of backend class as key and count number as value
  139. * @since 8.0.0
  140. */
  141. public function countUsers();
  142. /**
  143. * @param \Closure $callback
  144. * @param string $search
  145. * @since 9.0.0
  146. */
  147. public function callForAllUsers(\Closure $callback, $search = '');
  148. /**
  149. * returns how many users have logged in once
  150. *
  151. * @return int
  152. * @since 11.0.0
  153. */
  154. public function countDisabledUsers();
  155. /**
  156. * returns how many users have logged in once
  157. *
  158. * @return int
  159. * @since 11.0.0
  160. */
  161. public function countSeenUsers();
  162. /**
  163. * @param \Closure $callback
  164. * @since 11.0.0
  165. */
  166. public function callForSeenUsers(\Closure $callback);
  167. /**
  168. * @param string $email
  169. * @return IUser[]
  170. * @since 9.1.0
  171. */
  172. public function getByEmail($email);
  173. }