Skip to content

Commit 304292c

Browse files
committed
Manually search for displayname by iterating over group members
Signed-off-by: Julius Härtl <[email protected]>
1 parent 0450e47 commit 304292c

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

lib/private/Group/Manager.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,21 +376,17 @@ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0
376376

377377
if (!empty($search)) {
378378
// only user backends have the capability to do a complex search for users
379-
$searchOffset = 0;
380-
$searchLimit = $limit * 100;
381-
if ($limit === -1) {
382-
$searchLimit = 500;
383-
}
384-
379+
$chunkOffset = 0;
380+
$chunkLimit = 500;
385381
do {
386-
$filteredUsers = $this->userManager->searchDisplayName($search, $searchLimit, $searchOffset);
387-
foreach ($filteredUsers as $filteredUser) {
388-
if ($group->inGroup($filteredUser)) {
389-
$groupUsers[] = $filteredUser;
382+
$userChunk = $group->searchUsers('', $chunkLimit, $chunkOffset);
383+
foreach ($userChunk as $user) {
384+
if (mb_stripos($user->getDisplayName(), $search) > -1) {
385+
$groupUsers[] = $user;
390386
}
391387
}
392-
$searchOffset += $searchLimit;
393-
} while (count($groupUsers) < $searchLimit + $offset && count($filteredUsers) >= $searchLimit);
388+
$chunkOffset += $chunkLimit;
389+
} while (count($userChunk) !== 0);
394390

395391
if ($limit === -1) {
396392
$groupUsers = array_slice($groupUsers, $offset);

0 commit comments

Comments
 (0)