diff --git a/extensions/tags/src/Tag.php b/extensions/tags/src/Tag.php index 9766ebbf8..4183fe703 100644 --- a/extensions/tags/src/Tag.php +++ b/extensions/tags/src/Tag.php @@ -57,7 +57,7 @@ class Tag extends Model return $this; } - public static function getVisibleTo($user) + public static function getNotVisibleTo($user) { static $tags; if (! $tags) { @@ -66,7 +66,7 @@ class Tag extends Model $ids = []; foreach ($tags as $tag) { - if (! $tag->is_restricted || $user->hasPermission('tag'.$tag->id.'.view')) { + if ($tag->is_restricted && ! $user->hasPermission('tag'.$tag->id.'.view')) { $ids[] = $tag->id; } } diff --git a/extensions/tags/src/TagsServiceProvider.php b/extensions/tags/src/TagsServiceProvider.php index 78098c977..f8a8b2f39 100644 --- a/extensions/tags/src/TagsServiceProvider.php +++ b/extensions/tags/src/TagsServiceProvider.php @@ -39,7 +39,7 @@ class TagsServiceProvider extends ServiceProvider (new Extend\Model('Flarum\Tags\Tag')) // Hide tags that the user doesn't have permission to see. ->scopeVisible(function ($query, User $user) { - $query->whereIn('id', Tag::getVisibleTo($user)); + $query->whereNotIn('id', Tag::getNotVisibleTo($user)); }) // Allow the user to start discussions in tags which aren't @@ -76,7 +76,7 @@ class TagsServiceProvider extends ServiceProvider $query->whereNotExists(function ($query) use ($user) { return $query->select(app('db')->raw(1)) ->from('discussions_tags') - ->whereNotIn('tag_id', Tag::getVisibleTo($user)) + ->whereIn('tag_id', Tag::getNotVisibleTo($user)) ->whereRaw('discussion_id = discussions.id'); }); })