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:
@@ -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();
|
||||
|
Reference in New Issue
Block a user