summaryrefslogtreecommitdiffstats
path: root/lib/private/group/manager.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2014-05-07 17:54:38 +0200
committerBart Visscher <bartv@thisnet.nl>2014-05-07 17:54:38 +0200
commitf569c721a64486d0e7c7e307ed77ac0caed2dc2d (patch)
treedf7b3399a858ffdae6bd6e66616746efbcee24bc /lib/private/group/manager.php
parent47d70da2f5cb55ad47023b061b68062dd8b8d8e2 (diff)
parent254fa5eb22efa5ba572702064377a6ad9eec9a53 (diff)
downloadnextcloud-server-f569c721a64486d0e7c7e307ed77ac0caed2dc2d.tar.gz
nextcloud-server-f569c721a64486d0e7c7e307ed77ac0caed2dc2d.zip
Merge branch 'master' into optimize-startup-queries
Conflicts: apps/files_sharing/lib/sharedstorage.php tests/lib/group/manager.php removed hasFilesSharedWith from lib/public/share.php and sharedstorage.php to fix merge
Diffstat (limited to 'lib/private/group/manager.php')
-rw-r--r--lib/private/group/manager.php40
1 files changed, 34 insertions, 6 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 151b185dbf7..40c6074b2ac 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -153,12 +153,6 @@ class Manager extends PublicEmitter {
$groups = array();
foreach ($this->backends as $backend) {
$groupIds = $backend->getGroups($search, $limit, $offset);
- if (!is_null($limit)) {
- $limit -= count($groupIds);
- }
- if (!is_null($offset)) {
- $offset -= count($groupIds);
- }
foreach ($groupIds as $groupId) {
$groups[$groupId] = $this->get($groupId);
}
@@ -188,4 +182,38 @@ class Manager extends PublicEmitter {
$this->cachedUserGroups[$uid] = array_values($groups);
return $this->cachedUserGroups[$uid];
}
+
+ /**
+ * @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;
+ }
}