summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2020-06-23 14:02:17 +0200
committerGitHub <noreply@github.com>2020-06-23 14:02:17 +0200
commit8ec1b8132efed59a0f4b6ad49b99dfa5dd23424c (patch)
tree6d92ecd47b62bcdf94b992426089b7b66e071f4a /lib
parent3487ac763df3718bb6ccf1eff41ef161a80d34de (diff)
parent11513947397e10eb8cfd70bf880781cba270ad31 (diff)
downloadnextcloud-server-8ec1b8132efed59a0f4b6ad49b99dfa5dd23424c.tar.gz
nextcloud-server-8ec1b8132efed59a0f4b6ad49b99dfa5dd23424c.zip
Merge pull request #21452 from nextcloud/bugfix/21451/allow-autocomplete-by-displayname-again
Fix autocomplete for LDAP with `shareapi_only_share_with_group_members` on
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Collaboration/Collaborators/UserPlugin.php19
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);
}