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

index ed9482418bd4ba1a3421ac3dc89a08a29c8551f3..8ebb698692b39ec7dca302ce6a0012257c6f43d5 100644 (file)
@@ -286,4 +286,33 @@ class OC_Group {
                }
                return $users;
        }
+       
+       /**\r
+        * @brief get a list of all display names in a group\r
+        * @returns array with display names (key) and user ids(value)\r
+        */\r
+       public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {\r
+               $displayNames=array();\r
+               foreach(self::$_usedBackends as $backend) {\r
+                       $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames);\r
+               }\r
+               return $displayNames;\r
+       }
+       
+       /**\r
+        * @brief get a list of all display names in several groups\r
+        * @param array $gids\r
+        * @param string $search\r
+        * @param int $limit\r
+        * @param int $offset\r
+        * @return array with display names (Key) user ids (value)\r
+        */\r
+       public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {\r
+               $displayNames = array();\r
+               foreach ($gids as $gid) {\r
+                       // TODO Need to apply limits to groups as total\r
+                       $displayNames = array_merge(array_diff(self::displayNamesInGroup($gid, $search, $limit, $offset), $displayNames), $displayNames);\r
+               }\r
+               return $displayNames;\r
+       }
 }
index 9ff432d06632c2a9d50b13a98d1758e4c673990b..ceb2d9242dd911c266ea6c54f5c6fcb438b4e46f 100644 (file)
@@ -133,5 +133,23 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
        public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
                return array();
        }
+       
+       /**\r
+        * @brief get a list of all display names in a group\r
+        * @param string $gid\r
+        * @param string $search\r
+        * @param int $limit\r
+        * @param int $offset\r
+        * @return array with display names (key) and user ids (value)\r
+        */\r
+       public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {\r
+               $displayNames = '';\r
+               $users = $this->usersInGroup($gid, $search, $limit, $offset);\r
+               foreach ( $users as $user ) {\r
+                       $DisplayNames[$user] = $user;\r
+               }\r
+                       \r
+               return $DisplayNames;\r
+       }
 
 }
index 3a2f4d02f5c214a96a1bbaf8b186c4353e91d0c7..a93e3a674a84bb297554c9d67a17c8a76f02ec7c 100644 (file)
@@ -62,9 +62,9 @@ class User {
        
        /**\r
         * @brief Get a list of all display names\r
-        * @returns array with all display names and the correspondig uids\r
+        * @returns array with all display names (key) and the correspondig uids (value)\r
         *\r
-        * Get a list of all display names.\r
+        * Get a list of all display names and user ids.\r
         */\r
        public static function getDisplayNames($search = '', $limit = null, $offset = null) {\r
                return \OC_USER::getDisplayNames($search, $limit, $offset);\r
index f84b4c01df75f403cf19244ca5ef3841fac34cd3..4cdf07dc3ff9d62f22df9f468d444cd4d5a15ce5 100644 (file)
@@ -460,9 +460,9 @@ class OC_User {
        
        /**\r
         * @brief Get a list of all users display name\r
-        * @returns associative array with all display names and corresponding uids\r
+        * @returns associative array with all display names (key) and corresponding uids (value)\r
         *\r
-        * Get a list of all users.\r
+        * Get a list of all display names and user ids.\r
         */\r
        public static function getDisplayNames($search = '', $limit = null, $offset = null) {\r
                $displayNames = array();\r
index 5823e3904061964ed02b314f9a25a382ccc1f497..ec43d7f1872a7b435023e486eae1c500a579bea8 100644 (file)
@@ -134,9 +134,9 @@ abstract class OC_User_Backend implements OC_User_Interface {
        
        /**\r
         * @brief Get a list of all display names\r
-        * @returns array with  all displayNames and the correspondig uids\r
+        * @returns array with  all displayNames (key) and the correspondig uids (value)\r
         *\r
-        * Get a list of all display names.\r
+        * Get a list of all display names and user ids.\r
         */\r
        public function getDisplayNames($search = '', $limit = null, $offset = null) {\r
                $displayNames = array();
index 3706dc918c0d23669f671847a566845f4aecf2aa..bf27e80441191b1aa0a74a57c702752ddc275be7 100644 (file)
@@ -26,7 +26,7 @@ if($isadmin) {
        $subadmins = OC_SubAdmin::getAllSubAdmins();
 }else{
        $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
-       $accessibleusers = OC_Group::usersInGroups($accessiblegroups, '', 30);
+       $accessibleusers = OC_Group::displayNamesInGroups($accessiblegroups, '', 30);
        $subadmins = false;
 }