aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-01-25 11:48:03 +0100
committerBjörn Schießle <schiessle@owncloud.com>2013-01-25 11:48:03 +0100
commit4271430e609be252d9b4a69fd7b3590571c14f7c (patch)
tree2c5c5bf9bf16e17a18488fcea6cc0f7f28e8aad2
parent9bb8e0583995fff244432bc34820127ef8ff6ac6 (diff)
downloadnextcloud-server-4271430e609be252d9b4a69fd7b3590571c14f7c.tar.gz
nextcloud-server-4271430e609be252d9b4a69fd7b3590571c14f7c.zip
get all display names from users in a given group
-rw-r--r--lib/group.php29
-rw-r--r--lib/group/backend.php18
-rw-r--r--lib/public/user.php4
-rw-r--r--lib/user.php4
-rw-r--r--lib/user/backend.php4
-rw-r--r--settings/users.php2
6 files changed, 54 insertions, 7 deletions
diff --git a/lib/group.php b/lib/group.php
index ed9482418bd..8ebb698692b 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 9ff432d0663..ceb2d9242dd 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 3a2f4d02f5c..a93e3a674a8 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 f84b4c01df7..4cdf07dc3ff 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 5823e390406..ec43d7f1872 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 3706dc918c0..bf27e804411 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;
}