diff options
author | Joas Schilling <coding@schilljs.com> | 2021-03-17 10:26:21 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-03-17 11:20:30 +0100 |
commit | cf434d5107acc95d8a6afad15707e3e4fc33bbc9 (patch) | |
tree | 04901fa8e58eb76a16914812fea18331b9a55682 /lib/private/Collaboration | |
parent | 3379e69ecc092da6897f38a0be30e917a38f5439 (diff) | |
download | nextcloud-server-cf434d5107acc95d8a6afad15707e3e4fc33bbc9.tar.gz nextcloud-server-cf434d5107acc95d8a6afad15707e3e4fc33bbc9.zip |
Also limit to user group in case enumeration is enabled for groups and phonenumbers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Collaboration')
-rw-r--r-- | lib/private/Collaboration/Collaborators/UserPlugin.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index c2132048b2f..12ed3e98932 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -97,7 +97,7 @@ class UserPlugin implements ISearchPlugin { $currentUserId = $this->userSession->getUser()->getUID(); $currentUserGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser()); - if ($this->shareWithGroupOnly) { + if ($this->shareWithGroupOnly || $this->shareeEnumerationInGroupOnly) { // Search in all the groups this user is part of foreach ($currentUserGroups as $userGroupId) { $usersInGroup = $this->groupManager->displayNamesInGroup($userGroupId, $search, $limit, $offset); @@ -114,6 +114,25 @@ class UserPlugin implements ISearchPlugin { $hasMoreResults = true; } } + + if (!$this->shareWithGroupOnly && $this->shareeEnumerationPhone) { + $usersTmp = $this->userManager->searchKnownUsersByDisplayName($currentUserId, $search, $limit, $offset); + if (!empty($usersTmp)) { + foreach ($usersTmp as $user) { + if ($user->isEnabled()) { // Don't keep deactivated users + $users[$user->getUID()] = $user; + } + } + + uasort($users, function ($a, $b) { + /** + * @var \OC\User\User $a + * @var \OC\User\User $b + */ + return strcasecmp($a->getDisplayName(), $b->getDisplayName()); + }); + } + } } else { // Search in all users if ($this->shareeEnumerationPhone) { |