]> source.dussan.org Git - nextcloud-server.git/commitdiff
get all display names
authorBjörn Schießle <schiessle@owncloud.com>
Fri, 25 Jan 2013 10:05:00 +0000 (11:05 +0100)
committerBjörn Schießle <schiessle@owncloud.com>
Fri, 25 Jan 2013 10:05:00 +0000 (11:05 +0100)
lib/public/user.php
lib/user.php
lib/user/backend.php
settings/users.php

index 2d22bdd96c87ffe2936c5e1d78f3b0cc04223a82..3a2f4d02f5c214a96a1bbaf8b186c4353e91d0c7 100644 (file)
@@ -60,6 +60,16 @@ class User {
                return \OC_USER::getDisplayName();\r
        }
        
+       /**\r
+        * @brief Get a list of all display names\r
+        * @returns array with all display names and the correspondig uids\r
+        *\r
+        * Get a list of all display names.\r
+        */\r
+       public static function getDisplayNames($search = '', $limit = null, $offset = null) {\r
+               return \OC_USER::getDisplayNames($search, $limit, $offset);\r
+       }
+       
        /**
         * @brief Check if the user is logged in
         * @returns true/false
index f9c8f48568e72e26e7d3414c69fd356225b8bcc0..f84b4c01df75f403cf19244ca5ef3841fac34cd3 100644 (file)
@@ -457,6 +457,24 @@ class OC_User {
                asort($users);
                return $users;
        }
+       
+       /**\r
+        * @brief Get a list of all users display name\r
+        * @returns associative array with all display names and corresponding uids\r
+        *\r
+        * Get a list of all users.\r
+        */\r
+       public static function getDisplayNames($search = '', $limit = null, $offset = null) {\r
+               $displayNames = array();\r
+               foreach (self::$_usedBackends as $backend) {\r
+                       $backendDisplayNames = $backend->getDisplayNames($search, $limit, $offset);\r
+                       if (is_array($backendDisplayNames)) {\r
+                               $displayNames = array_merge($displayNames, $backendDisplayNames);\r
+                       }\r
+               }\r
+               ksort($displayNames);\r
+               return $displayNames;\r
+       }
 
        /**
         * @brief check if a user exists
index 47c92f5fe7b61942e4fd0477bf64082f0814c3c8..5823e3904061964ed02b314f9a25a382ccc1f497 100644 (file)
@@ -131,4 +131,19 @@ abstract class OC_User_Backend implements OC_User_Interface {
        public function getDisplayName($uid) {
                return $uid;
        }
+       
+       /**\r
+        * @brief Get a list of all display names\r
+        * @returns array with  all displayNames and the correspondig uids\r
+        *\r
+        * Get a list of all display names.\r
+        */\r
+       public function getDisplayNames($search = '', $limit = null, $offset = null) {\r
+               $displayNames = array();
+               $users = $this->getUsers($search, $limit, $offset);
+               foreach ( $users as $user) {
+                       $displayNames[$user] = $user;
+               }
+               return $displayNames;\r
+       }
 }
index 668d974693ae7ce043567a80445533209924dde9..3706dc918c0d23669f671847a566845f4aecf2aa 100644 (file)
@@ -22,7 +22,7 @@ $isadmin = OC_User::isAdminUser(OC_User::getUser());
 
 if($isadmin) {
        $accessiblegroups = OC_Group::getGroups();
-       $accessibleusers = OC_User::getUsers('', 30);
+       $accessibleusers = OC_User::getDisplayNames('', 30);
        $subadmins = OC_SubAdmin::getAllSubAdmins();
 }else{
        $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
@@ -42,16 +42,21 @@ $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
 $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false && array_search($defaultQuota, array('none', 'default'))===false;
 
 // load users and quota
-foreach($accessibleusers as $i) {
+foreach($accessibleusers as $displayName => $uid) {
        $quota=OC_Preferences::getValue($i, 'files', 'quota', 'default');
        $isQuotaUserDefined=array_search($quota, $quotaPreset)===false && array_search($quota, array('none', 'default'))===false;
 
+       $name = $displayName;
+       if ( $displayName != $uid ) {
+               $name = $name . ' ('.$uid.')';
+       } 
+       
        $users[] = array(
-               "name" => $i,
-               "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
+               "name" => $name,
+               "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($uid)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
                'quota'=>$quota,
                'isQuotaUserDefined'=>$isQuotaUserDefined,
-               'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
+               'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($iuid)));
 }
 
 foreach( $accessiblegroups as $i ) {