From: Joas Schilling Date: Wed, 17 Jun 2020 09:59:56 +0000 (+0200) Subject: Move back to IGroupManager::displayNamesInGroup() X-Git-Tag: v18.0.7RC1~21^2~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1e3748f6723c5d706b5d078cf21a6779af8e42ba;p=nextcloud-server.git 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 --- diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index 5fb278fc5ff..c955b244f48 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -68,14 +68,14 @@ 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 { @@ -136,10 +136,7 @@ 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)); + $commonGroups = array_intersect($currentUserGroups, $this->groupManager->getUserGroupIds($user)); $addUser = !empty($commonGroups); }