mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 21:11:55 +08:00
parent
fffedb4e1d
commit
bf5a401787
|
@ -98,9 +98,6 @@ return [
|
|||
(new Extend\ModelVisibility(Discussion::class))
|
||||
->scopeAll(Access\ScopeDiscussionVisibilityForAbility::class),
|
||||
|
||||
(new Extend\ModelVisibility(Flag::class))
|
||||
->scope(Access\ScopeFlagVisibility::class),
|
||||
|
||||
(new Extend\ModelVisibility(Tag::class))
|
||||
->scope(Access\ScopeTagVisibility::class),
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Tags\Access;
|
||||
|
||||
use Flarum\Tags\Tag;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ScopeFlagVisibility
|
||||
{
|
||||
/**
|
||||
* @param User $actor
|
||||
* @param Builder $query
|
||||
*/
|
||||
public function __invoke(User $actor, Builder $query)
|
||||
{
|
||||
$query
|
||||
->select('flags.*')
|
||||
->leftJoin('posts', 'posts.id', '=', 'flags.post_id')
|
||||
->leftJoin('discussions', 'discussions.id', '=', 'posts.discussion_id')
|
||||
->whereNotExists(function ($query) use ($actor) {
|
||||
return $query->selectRaw('1')
|
||||
->from('discussion_tag')
|
||||
->whereNotIn('tag_id', function ($query) use ($actor) {
|
||||
Tag::query()->setQuery($query->from('tags'))->whereHasPermission($actor, 'viewFlags')->select('tags.id');
|
||||
})
|
||||
->whereColumn('discussions.id', 'discussion_id');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user