summaryrefslogtreecommitdiffstats
path: root/lib/private/group/manager.php
diff options
context:
space:
mode:
authorblizzz <blizzz@owncloud.com>2014-04-23 16:30:26 +0200
committerblizzz <blizzz@owncloud.com>2014-04-23 16:30:26 +0200
commit14c95086a98e2a2543b7d1eefe30508a3d3a4126 (patch)
treed228dd638b333ee0d24fa05c04b0f392b4e8fe3d /lib/private/group/manager.php
parent4696b06060b8dd43e1465d675aaa71b80afcc5f9 (diff)
parent0a9487ec801c640bfdb59c037b4ca3f4ea95fe0a (diff)
downloadnextcloud-server-14c95086a98e2a2543b7d1eefe30508a3d3a4126.tar.gz
nextcloud-server-14c95086a98e2a2543b7d1eefe30508a3d3a4126.zip
Merge pull request #7745 from owncloud/fix_6946_stable6
Group Database backend must not gather user details itself but ask user backends, fixes #6946 in stable6
Diffstat (limited to 'lib/private/group/manager.php')
-rw-r--r--lib/private/group/manager.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 454e2b63b47..e5d3076b7eb 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -160,4 +160,38 @@ class Manager extends PublicEmitter {
}
return array_values($groups);
}
+
+ /**
+ * @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 (value) and user ids (key)
+ */
+ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $group = $this->get($gid);
+ if(is_null($group)) {
+ return array();
+ }
+ // only user backends have the capability to do a complex search for users
+ $groupUsers = $group->searchUsers('', $limit, $offset);
+ $search = trim($search);
+ if(!empty($search)) {
+ //TODO: for OC 7 earliest: user backend should get a method to check selected users against a pattern
+ $filteredUsers = $this->userManager->search($search);
+ $testUsers = true;
+ } else {
+ $filteredUsers = array();
+ $testUsers = false;
+ }
+
+ $matchingUsers = array();
+ foreach($groupUsers as $user) {
+ if(!$testUsers || isset($filteredUsers[$user->getUID()])) {
+ $matchingUsers[$user->getUID()] = $user->getDisplayName();
+ }
+ }
+ return $matchingUsers;
+ }
}