diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-01-25 11:05:00 +0100 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-01-25 11:05:00 +0100 |
commit | 9bb8e0583995fff244432bc34820127ef8ff6ac6 (patch) | |
tree | e3294e6b26b148d2735aa30d07d167b4ed1c9c64 /lib | |
parent | 2fee1208eff1911ffcdbba24ea1e8543ed6ec26b (diff) | |
download | nextcloud-server-9bb8e0583995fff244432bc34820127ef8ff6ac6.tar.gz nextcloud-server-9bb8e0583995fff244432bc34820127ef8ff6ac6.zip |
get all display names
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/user.php | 10 | ||||
-rw-r--r-- | lib/user.php | 18 | ||||
-rw-r--r-- | lib/user/backend.php | 15 |
3 files changed, 43 insertions, 0 deletions
diff --git a/lib/public/user.php b/lib/public/user.php index 2d22bdd96c8..3a2f4d02f5c 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -60,6 +60,16 @@ class User { return \OC_USER::getDisplayName();
} + /**
+ * @brief Get a list of all display names
+ * @returns array with all display names and the correspondig uids
+ *
+ * Get a list of all display names.
+ */
+ public static function getDisplayNames($search = '', $limit = null, $offset = null) {
+ return \OC_USER::getDisplayNames($search, $limit, $offset);
+ } + /** * @brief Check if the user is logged in * @returns true/false diff --git a/lib/user.php b/lib/user.php index f9c8f48568e..f84b4c01df7 100644 --- a/lib/user.php +++ b/lib/user.php @@ -457,6 +457,24 @@ class OC_User { asort($users); return $users; } + + /**
+ * @brief Get a list of all users display name
+ * @returns associative array with all display names and corresponding uids
+ *
+ * Get a list of all users.
+ */
+ public static function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $displayNames = array();
+ foreach (self::$_usedBackends as $backend) {
+ $backendDisplayNames = $backend->getDisplayNames($search, $limit, $offset);
+ if (is_array($backendDisplayNames)) {
+ $displayNames = array_merge($displayNames, $backendDisplayNames);
+ }
+ }
+ ksort($displayNames);
+ return $displayNames;
+ } /** * @brief check if a user exists diff --git a/lib/user/backend.php b/lib/user/backend.php index 47c92f5fe7b..5823e390406 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -131,4 +131,19 @@ abstract class OC_User_Backend implements OC_User_Interface { public function getDisplayName($uid) { return $uid; } + + /**
+ * @brief Get a list of all display names
+ * @returns array with all displayNames and the correspondig uids
+ *
+ * Get a list of all display names.
+ */
+ public function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $displayNames = array(); + $users = $this->getUsers($search, $limit, $offset); + foreach ( $users as $user) { + $displayNames[$user] = $user; + } + return $displayNames;
+ } } |