diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2020-07-01 10:13:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-01 10:13:19 +0200 |
commit | 9e9e74736dbfee294d30f35cac63759bcbf2e7f5 (patch) | |
tree | 51c0d5d898da30bcceb10ad42a281fb53a03ec62 /lib | |
parent | c0b3cd90a632f6a2703a4a4bf031a39d2a88177e (diff) | |
parent | d1df66f7af7c46e12ccb78a60ec0e85ea0678ede (diff) | |
download | nextcloud-server-9e9e74736dbfee294d30f35cac63759bcbf2e7f5.tar.gz nextcloud-server-9e9e74736dbfee294d30f35cac63759bcbf2e7f5.zip |
Merge pull request #21538 from nextcloud/backport/21452/stable19
[stable19] Fix autocomplete for LDAP with `shareapi_only_share_with_group_members` on
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Collaboration/Collaborators/UserPlugin.php | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index 7c02e3c79ac..123fa731445 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -33,7 +33,6 @@ use OCP\Collaboration\Collaborators\ISearchPlugin; use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\IConfig; -use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; @@ -73,20 +72,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,10 +153,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); } |