Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 <[email protected]>
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Jun 23, 2020
commit 7a36a4b99c632f72b1e9ec267bc3d5208ca76d9f
16 changes: 6 additions & 10 deletions lib/private/Collaboration/Collaborators/UserPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,19 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
$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;
Expand Down Expand Up @@ -155,9 +154,6 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {

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);
}
Expand Down