User.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Frank Karlitschek <frank@karlitschek.de>
  8. * @author Georg Ehrke <oc.list@georgehrke.com>
  9. * @author Joas Schilling <coding@schilljs.com>
  10. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  11. * @author Lukas Reschke <lukas@statuscode.ch>
  12. * @author Morris Jobke <hey@morrisjobke.de>
  13. * @author Robin McCorkell <robin@mccorkell.me.uk>
  14. * @author Sebastian Wessalowski <sebastian@wessalowski.org>
  15. * @author Thomas Müller <thomas.mueller@tmit.eu>
  16. *
  17. * @license AGPL-3.0
  18. *
  19. * This code is free software: you can redistribute it and/or modify
  20. * it under the terms of the GNU Affero General Public License, version 3,
  21. * as published by the Free Software Foundation.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU Affero General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU Affero General Public License, version 3,
  29. * along with this program. If not, see <http://www.gnu.org/licenses/>
  30. *
  31. */
  32. /**
  33. * Public interface of ownCloud for apps to use.
  34. * User Class
  35. *
  36. */
  37. // use OCP namespace for all classes that are considered public.
  38. // This means that they should be used by apps instead of the internal ownCloud classes
  39. namespace OCP;
  40. /**
  41. * This class provides access to the user management. You can get information
  42. * about the currently logged in user and the permissions for example
  43. * @since 5.0.0
  44. * @deprecated 13.0.0
  45. */
  46. class User {
  47. /**
  48. * Get the user id of the user currently logged in.
  49. * @return string uid or false
  50. * @deprecated 8.0.0 Use \OC::$server->getUserSession()->getUser()->getUID()
  51. * @since 5.0.0
  52. */
  53. public static function getUser() {
  54. return \OC_User::getUser();
  55. }
  56. /**
  57. * Get a list of all users
  58. * @param string $search search pattern
  59. * @param int|null $limit
  60. * @param int|null $offset
  61. * @return array an array of all uids
  62. * @deprecated 8.1.0 use method search() of \OCP\IUserManager - \OC::$server->getUserManager()
  63. * @since 5.0.0
  64. */
  65. public static function getUsers( $search = '', $limit = null, $offset = null ) {
  66. return \OC_User::getUsers( $search, $limit, $offset );
  67. }
  68. /**
  69. * Get the user display name of the user currently logged in.
  70. * @param string|null $user user id or null for current user
  71. * @return string display name
  72. * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method
  73. * get() of \OCP\IUserManager - \OC::$server->getUserManager()
  74. * @since 5.0.0
  75. */
  76. public static function getDisplayName( $user = null ) {
  77. return \OC_User::getDisplayName( $user );
  78. }
  79. /**
  80. * Get a list of all display names and user ids.
  81. * @param string $search search pattern
  82. * @param int|null $limit
  83. * @param int|null $offset
  84. * @return array an array of all display names (value) and the correspondig uids (key)
  85. * @deprecated 8.1.0 use method searchDisplayName() of \OCP\IUserManager - \OC::$server->getUserManager()
  86. * @since 5.0.0
  87. * @suppress PhanDeprecatedFunction
  88. */
  89. public static function getDisplayNames( $search = '', $limit = null, $offset = null ) {
  90. return \OC_User::getDisplayNames( $search, $limit, $offset );
  91. }
  92. /**
  93. * Check if the user is logged in
  94. * @return boolean
  95. * @since 5.0.0
  96. * @deprecated 13.0.0 Use annotation based ACLs from the AppFramework instead
  97. */
  98. public static function isLoggedIn() {
  99. return \OC::$server->getUserSession()->isLoggedIn();
  100. }
  101. /**
  102. * Check if a user exists
  103. * @param string $uid the username
  104. * @param string $excludingBackend (default none)
  105. * @return boolean
  106. * @deprecated 8.1.0 use method userExists() of \OCP\IUserManager - \OC::$server->getUserManager()
  107. * @since 5.0.0
  108. */
  109. public static function userExists($uid, $excludingBackend = null) {
  110. return \OC_User::userExists($uid);
  111. }
  112. /**
  113. * Logs the user out including all the session data
  114. * Logout, destroys session
  115. * @deprecated 8.0.0 Use \OC::$server->getUserSession()->logout();
  116. * @since 5.0.0
  117. */
  118. public static function logout() {
  119. \OC::$server->getUserSession()->logout();
  120. }
  121. /**
  122. * Check if the password is correct
  123. * @param string $uid The username
  124. * @param string $password The password
  125. * @return string|false username on success, false otherwise
  126. *
  127. * Check if the password is correct without logging in the user
  128. * @deprecated 8.0.0 Use \OC::$server->getUserManager()->checkPassword();
  129. * @since 5.0.0
  130. */
  131. public static function checkPassword( $uid, $password ) {
  132. return \OC_User::checkPassword( $uid, $password );
  133. }
  134. /**
  135. * Check if the user is a admin, redirects to home if not
  136. * @since 5.0.0
  137. * @deprecated 13.0.0 Use annotation based ACLs from the AppFramework instead
  138. */
  139. public static function checkAdminUser() {
  140. \OC_Util::checkAdminUser();
  141. }
  142. /**
  143. * Check if the user is logged in, redirects to home if not. With
  144. * redirect URL parameter to the request URI.
  145. * @since 5.0.0
  146. * @deprecated 13.0.0 Use annotation based ACLs from the AppFramework instead
  147. */
  148. public static function checkLoggedIn() {
  149. \OC_Util::checkLoggedIn();
  150. }
  151. }