user.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Public interface of ownCloud for apps to use.
  24. * User Class.
  25. *
  26. */
  27. // use OCP namespace for all classes that are considered public.
  28. // This means that they should be used by apps instead of the internal ownCloud classes
  29. namespace OCP;
  30. /**
  31. * This class provides access to the user management. You can get information about the currently logged in user and the permissions for example
  32. */
  33. class User {
  34. /**
  35. * @brief get the user id of the user currently logged in.
  36. * @return string uid or false
  37. */
  38. public static function getUser() {
  39. return \OC_USER::getUser();
  40. }
  41. /**
  42. * @brief Get a list of all users
  43. * @returns array with all uids
  44. *
  45. * Get a list of all users.
  46. */
  47. public static function getUsers($search = '', $limit = null, $offset = null) {
  48. return \OC_USER::getUsers();
  49. }
  50. /**
  51. * @brief Check if the user is logged in
  52. * @returns true/false
  53. *
  54. * Checks if the user is logged in
  55. */
  56. public static function isLoggedIn() {
  57. return \OC_USER::isLoggedIn();
  58. }
  59. /**
  60. * @brief check if a user exists
  61. * @param string $uid the username
  62. * @return boolean
  63. */
  64. public static function userExists( $uid ) {
  65. return \OC_USER::userExists( $uid );
  66. }
  67. /**
  68. * @brief Loggs the user out including all the session data
  69. * @returns true
  70. *
  71. * Logout, destroys session
  72. */
  73. public static function logout() {
  74. return \OC_USER::logout();
  75. }
  76. /**
  77. * @brief Check if the password is correct
  78. * @param $uid The username
  79. * @param $password The password
  80. * @returns true/false
  81. *
  82. * Check if the password is correct without logging in the user
  83. */
  84. public static function checkPassword( $uid, $password ) {
  85. return \OC_USER::checkPassword( $uid, $password );
  86. }
  87. /**
  88. * Check if the user is a admin, redirects to home if not
  89. */
  90. public static function checkAdminUser() {
  91. \OC_Util::checkAdminUser();
  92. }
  93. /**
  94. * Check if the user is logged in, redirects to home if not. With
  95. * redirect URL parameter to the request URI.
  96. */
  97. public static function checkLoggedIn() {
  98. \OC_Util::checkLoggedIn();
  99. }
  100. }