summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-17 11:59:56 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-06-23 12:04:49 +0000
commit7a36a4b99c632f72b1e9ec267bc3d5208ca76d9f (patch)
treec57b924136fed676964b5467ef981ac6acfcbeba /lib
parent86fdf17eedef0974162e09c9cf906bc49bcffd05 (diff)
downloadnextcloud-server-7a36a4b99c632f72b1e9ec267bc3d5208ca76d9f.tar.gz
nextcloud-server-7a36a4b99c632f72b1e9ec267bc3d5208ca76d9f.zip
Move back to IGroupManager::displayNamesInGroup()
The problem is that despite it's name IGroup::searchDisplayName() only searches by userid and this is less fixable than changing back to this method here Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Collaboration/Collaborators/UserPlugin.php16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php
index 7c02e3c79ac..4e293dd28b9 100644
--- a/lib/private/Collaboration/Collaborators/UserPlugin.php
+++ b/lib/private/Collaboration/Collaborators/UserPlugin.php
@@ -73,20 +73,19 @@ class UserPlugin implements ISearchPlugin {
$users = [];
$hasMoreResults = false;
- $userGroups = [];
+ $currentUserGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser());
if ($this->shareWithGroupOnly) {
// Search in all the groups this user is part of
- $userGroups = $this->groupManager->getUserGroups($this->userSession->getUser());
- foreach ($userGroups as $userGroup) {
- $usersInGroup = $userGroup->searchDisplayName($search, $limit, $offset);
- foreach ($usersInGroup as $user) {
- $users[$user->getUID()] = $user;
+ foreach ($currentUserGroups as $userGroupId) {
+ $usersInGroup = $this->groupManager->displayNamesInGroup($userGroupId, $search, $limit, $offset);
+ foreach ($usersInGroup as $userId => $displayName) {
+ $userId = (string) $userId;
+ $users[$userId] = $this->userManager->get($userId);
}
}
} else {
// Search in all users
$usersTmp = $this->userManager->searchDisplayName($search, $limit, $offset);
- $currentUserGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser());
foreach ($usersTmp as $user) {
if ($user->isEnabled()) { // Don't keep deactivated users
$users[$user->getUID()] = $user;
@@ -155,9 +154,6 @@ class UserPlugin implements ISearchPlugin {
if ($this->shareWithGroupOnly) {
// Only add, if we have a common group
- $userGroupIds = array_map(function (IGroup $group) {
- return $group->getGID();
- }, $userGroups);
$commonGroups = array_intersect($userGroupIds, $this->groupManager->getUserGroupIds($user));
$addUser = !empty($commonGroups);
}