1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 07:24:27 +02:00

Updated GroupFilterGambit to prevent hidden groups being visible wher… (#2657)

Updated GroupFilterGambit to prevent hidden groups being visible where they shouldn't be and to ensure that only the selected groups are returned on a search. Fixes #2559
This commit is contained in:
Blake Payne
2021-03-04 15:08:12 +00:00
committed by GitHub
parent a61f9e7328
commit 8eef7230e9
2 changed files with 336 additions and 2 deletions

View File

@@ -51,14 +51,20 @@ class GroupFilterGambit extends AbstractRegexGambit implements FilterInterface
$groupQuery = Group::whereVisibleTo($actor);
$ids = [];
$names = [];
foreach ($groupIdentifiers as $identifier) {
if (is_numeric($identifier)) {
$groupQuery->orWhere('id', $identifier);
$ids[] = $identifier;
} else {
$groupQuery->orWhere('name_singular', $identifier)->orWhere('name_plural', $identifier);
$names[] = $identifier;
}
}
$groupQuery->whereIn('id', $ids)
->orWhereIn('name_singular', $names)
->orWhereIn('name_plural', $names);
$userIds = $groupQuery->join('group_user', 'groups.id', 'group_user.group_id')
->pluck('group_user.user_id')
->all();