IUserManager.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 \Exception
  115. * @return bool|\OCP\IUser the created user of false
  116. * @since 8.0.0
  117. */
  118. public function createUser($uid, $password);
  119. /**
  120. * returns how many users per backend exist (if supported by backend)
  121. *
  122. * @return array an array of backend class as key and count number as value
  123. * @since 8.0.0
  124. */
  125. public function countUsers();
  126. /**
  127. * @param \Closure $callback
  128. * @param string $search
  129. * @since 9.0.0
  130. */
  131. public function callForAllUsers (\Closure $callback, $search = '');
  132. /**
  133. * @param string $email
  134. * @return IUser[]
  135. * @since 9.1.0
  136. */
  137. public function getByEmail($email);
  138. }