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