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 committed Feb 1, 2023
1 parent 41148ac commit 74bc46c
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 @@ -383,21 +383,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 74bc46c

Please sign in to comment.