diff --git a/lib/group.php b/lib/group.php index ed9482418b..8ebb698692 100644 --- a/lib/group.php +++ b/lib/group.php @@ -286,4 +286,33 @@ class OC_Group { } return $users; } + + /** + * @brief get a list of all display names in a group + * @returns array with display names (key) and user ids(value) + */ + public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { + $displayNames=array(); + foreach(self::$_usedBackends as $backend) { + $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames); + } + return $displayNames; + } + + /** + * @brief get a list of all display names in several groups + * @param array $gids + * @param string $search + * @param int $limit + * @param int $offset + * @return array with display names (Key) user ids (value) + */ + public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) { + $displayNames = array(); + foreach ($gids as $gid) { + // TODO Need to apply limits to groups as total + $displayNames = array_merge(array_diff(self::displayNamesInGroup($gid, $search, $limit, $offset), $displayNames), $displayNames); + } + return $displayNames; + } } diff --git a/lib/group/backend.php b/lib/group/backend.php index 9ff432d066..ceb2d9242d 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -133,5 +133,23 @@ abstract class OC_Group_Backend implements OC_Group_Interface { public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { return array(); } + + /** + * @brief get a list of all display names in a group + * @param string $gid + * @param string $search + * @param int $limit + * @param int $offset + * @return array with display names (key) and user ids (value) + */ + public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { + $displayNames = ''; + $users = $this->usersInGroup($gid, $search, $limit, $offset); + foreach ( $users as $user ) { + $DisplayNames[$user] = $user; + } + + return $DisplayNames; + } } diff --git a/lib/public/user.php b/lib/public/user.php index 3a2f4d02f5..a93e3a674a 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -62,9 +62,9 @@ class User { /** * @brief Get a list of all display names - * @returns array with all display names and the correspondig uids + * @returns array with all display names (key) and the correspondig uids (value) * - * Get a list of all display names. + * Get a list of all display names and user ids. */ public static function getDisplayNames($search = '', $limit = null, $offset = null) { return \OC_USER::getDisplayNames($search, $limit, $offset); diff --git a/lib/user.php b/lib/user.php index f84b4c01df..4cdf07dc3f 100644 --- a/lib/user.php +++ b/lib/user.php @@ -460,9 +460,9 @@ class OC_User { /** * @brief Get a list of all users display name - * @returns associative array with all display names and corresponding uids + * @returns associative array with all display names (key) and corresponding uids (value) * - * Get a list of all users. + * Get a list of all display names and user ids. */ public static function getDisplayNames($search = '', $limit = null, $offset = null) { $displayNames = array(); diff --git a/lib/user/backend.php b/lib/user/backend.php index 5823e39040..ec43d7f187 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -134,9 +134,9 @@ abstract class OC_User_Backend implements OC_User_Interface { /** * @brief Get a list of all display names - * @returns array with all displayNames and the correspondig uids + * @returns array with all displayNames (key) and the correspondig uids (value) * - * Get a list of all display names. + * Get a list of all display names and user ids. */ public function getDisplayNames($search = '', $limit = null, $offset = null) { $displayNames = array(); diff --git a/settings/users.php b/settings/users.php index 3706dc918c..bf27e80441 100644 --- a/settings/users.php +++ b/settings/users.php @@ -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; }