Skip to content

Commit

Permalink
Manually search for displayname by iterating over group members
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and skjnldsv committed Feb 27, 2024
1 parent 455a209 commit 78970ce
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/private/Group/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,17 @@ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0

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;
}

$chunkOffset = 0;
$chunkLimit = 500;
do {
$filteredUsers = $this->userManager->searchDisplayName($search, $searchLimit, $searchOffset);
foreach ($filteredUsers as $filteredUser) {
if ($group->inGroup($filteredUser)) {
$groupUsers[] = $filteredUser;
$userChunk = $group->searchUsers('', $chunkLimit, $chunkOffset);
foreach ($userChunk as $user) {
if (mb_stripos($user->getDisplayName(), $search) > -1) {
$groupUsers[] = $user;
}
}
$searchOffset += $searchLimit;
} while (count($groupUsers) < $searchLimit + $offset && count($filteredUsers) >= $searchLimit);
$chunkOffset += $chunkLimit;
} while (count($userChunk) !== 0);

if ($limit === -1) {
$groupUsers = array_slice($groupUsers, $offset);
Expand Down

0 comments on commit 78970ce

Please sign in to comment.