summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorvoxsim <Simon Vocella>2014-08-28 13:51:48 +0200
committervoxsim <Simon Vocella>2014-08-28 13:51:48 +0200
commita49610e18a07d04dd3ed861e15b64a94b8a45e19 (patch)
tree17d665a48982974c6e9df51b06d21cf33702cd45 /lib
parent5d30ed9ad1bfe6f6e43cd779b3decb73010d4499 (diff)
downloadnextcloud-server-a49610e18a07d04dd3ed861e15b64a94b8a45e19.tar.gz
nextcloud-server-a49610e18a07d04dd3ed861e15b64a94b8a45e19.zip
change logic in displayNamesInGroup and add some unit tests
Diffstat (limited to 'lib')
-rw-r--r--lib/private/group/manager.php27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 942bdbb91c2..982a3ceec46 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -208,23 +208,30 @@ class Manager extends PublicEmitter {
if(is_null($group)) {
return array();
}
- // only user backends have the capability to do a complex search for users
- $groupUsers = $group->searchUsers('');
+
$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
+ // only user backends have the capability to do a complex search for users
$filteredUsers = $this->userManager->search($search);
- $testUsers = true;
+ foreach($filteredUsers as $filteredUser) {
+ if($group->inGroup($filteredUser)) {
+ $groupUsers []= $filteredUser;
+ }
+ }
+ 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;
}