mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 06:01:56 +08:00
Massively simplify TagPolicy
This commit is contained in:
parent
3b3cbdc82f
commit
fd48af2032
|
@ -16,20 +16,10 @@ use Flarum\User\User;
|
|||
class TagPolicy extends AbstractPolicy
|
||||
{
|
||||
/**
|
||||
* @param User $actor
|
||||
* @param Tag $tag
|
||||
* @return bool|null
|
||||
*/
|
||||
public function addToDiscussion(User $actor, Tag $tag)
|
||||
{
|
||||
static $disallowedTags;
|
||||
|
||||
if (! isset($disallowedTags[$actor->id])) {
|
||||
$disallowedTags[$actor->id] = Tag::getIdsWhereCannot($actor, 'discussion.startWithoutApproval');
|
||||
}
|
||||
|
||||
if (in_array($tag->id, $disallowedTags)) {
|
||||
return $this->deny();
|
||||
}
|
||||
return $actor->can('discussion.startWithoutApproval', $tag);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user