aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorblizzz <blizzz@owncloud.com>2014-09-22 12:13:15 +0200
committerblizzz <blizzz@owncloud.com>2014-09-22 12:13:15 +0200
commitb8a134053881e0f95242b46bb362d016c686a57f (patch)
tree74f029d62b931a0efac6b8dbce37e6cd531c3516 /lib
parentb1d0a0f3bfd746104e40c539b091b90fff3f879a (diff)
parent7a14f94ae5cc8d02d46294ca5079c929877c2fe4 (diff)
downloadnextcloud-server-b8a134053881e0f95242b46bb362d016c686a57f.tar.gz
nextcloud-server-b8a134053881e0f95242b46bb362d016c686a57f.zip
Merge pull request #9225 from voxsim/fix_displayNamesInGroup
fix in displayNamesInGroup
Diffstat (limited to 'lib')
-rw-r--r--lib/private/group/manager.php40
1 files changed, 29 insertions, 11 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index bea7ad193bf..58a23924872 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -209,23 +209,41 @@ class Manager extends PublicEmitter implements IGroupManager {
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);
+ $groupUsers = array();
+
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;
+ // only user backends have the capability to do a complex search for users
+ $searchOffset = 0;
+ if($limit === -1) {
+ $searchLimit = $group->count('');
+ } else {
+ $searchLimit = $limit * 2;
+ }
+
+ do {
+ $filteredUsers = $this->userManager->search($search, $searchLimit, $searchOffset);
+ foreach($filteredUsers as $filteredUser) {
+ if($group->inGroup($filteredUser)) {
+ $groupUsers[]= $filteredUser;
+ }
+ }
+ $searchOffset += $searchLimit;
+ } while(count($groupUsers) < $searchLimit+$offset && count($filteredUsers) === $searchLimit);
+
+ if($limit === -1) {
+ $groupUsers = array_slice($groupUsers, $offset);
+ } else {
+ $groupUsers = array_slice($groupUsers, $offset, $limit);
+ }
} else {
- $filteredUsers = array();
- $testUsers = false;
+ $groupUsers = $group->searchUsers('', $limit, $offset);
}
$matchingUsers = array();
- foreach($groupUsers as $user) {
- if(!$testUsers || isset($filteredUsers[$user->getUID()])) {
- $matchingUsers[$user->getUID()] = $user->getDisplayName();
- }
+ foreach($groupUsers as $groupUser) {
+ $matchingUsers[$groupUser->getUID()] = $groupUser->getDisplayName();
}
return $matchingUsers;
}