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