IUserManager.php 4.2 KB

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