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 <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Oct 14, 2022
1 parent 0ac2a90 commit e0ef680
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 @@ -370,21 +370,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 e0ef680

Please sign in to comment.