Skip to content
Closed
Changes from all commits
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
48 changes: 4 additions & 44 deletions lib/private/Group/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,6 @@ private function getUserIdGroupIds(string $uid): array {
return $this->cachedUserGroups[$uid];
}

/**
* get an array of groupid and displayName for a user
*
* @param IUser $user
* @return array ['displayName' => displayname]
*/
public function getUserGroupNames(IUser $user) {
return array_map(function ($group) {
return ['displayName' => $group->getDisplayName()];
}, $this->getUserGroups($user));
}

/**
* get a list of all display names in a group
*
Expand All @@ -365,39 +353,11 @@ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0
return [];
}

$search = trim($search);
$groupUsers = [];

if (!empty($search)) {
// only user backends have the capability to do a complex search for users
$searchOffset = 0;
$searchLimit = $limit * 100;
if ($limit === -1) {
$searchLimit = 500;
}

do {
$filteredUsers = $this->userManager->searchDisplayName($search, $searchLimit, $searchOffset);
foreach ($filteredUsers as $filteredUser) {
if ($group->inGroup($filteredUser)) {
$groupUsers[] = $filteredUser;
}
}
$searchOffset += $searchLimit;
} while (count($groupUsers) < $searchLimit + $offset && count($filteredUsers) >= $searchLimit);

if ($limit === -1) {
$groupUsers = array_slice($groupUsers, $offset);
} else {
$groupUsers = array_slice($groupUsers, $offset, $limit);
}
} else {
$groupUsers = $group->searchUsers('', $limit, $offset);
}

$users = $group->searchDisplayName(trim($search), $limit === -1 ? null : $limit, $offset);
/** @var IUser $user */
$matchingUsers = [];
foreach ($groupUsers as $groupUser) {
$matchingUsers[(string) $groupUser->getUID()] = $groupUser->getDisplayName();
foreach ($users as $user) {
$matchingUsers[$user->getUID()] = $user->getDisplayName();
}
return $matchingUsers;
}
Expand Down