mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 06:53:47 +08:00
parent
67c1d79c5c
commit
eb49e1d4e8
|
@ -16,24 +16,14 @@ export default function() {
|
|||
label: tagLabel(tag),
|
||||
onremove: () => tag.save({isRestricted: false}),
|
||||
render: item => {
|
||||
if (item.permission) {
|
||||
let permission;
|
||||
|
||||
if (item.permission === 'forum.view') {
|
||||
permission = 'view';
|
||||
} else if (item.permission === 'forum.startDiscussion') {
|
||||
permission = 'startDiscussion';
|
||||
} else if (item.permission.indexOf('discussion.') === 0) {
|
||||
permission = item.permission;
|
||||
}
|
||||
|
||||
if (permission) {
|
||||
if (item.permission === 'viewDiscussions'
|
||||
|| item.permission === 'startDiscussion'
|
||||
|| (item.permission && item.permission.indexOf('discussion.') === 0)) {
|
||||
return PermissionDropdown.component({
|
||||
permission: 'tag' + tag.id() + '.' + permission,
|
||||
permission: 'tag' + tag.id() + '.' + item.permission,
|
||||
allowGuest: item.allowGuest
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class DiscussionPolicy extends AbstractPolicy
|
|||
$query->whereNotExists(function ($query) use ($actor) {
|
||||
return $query->select(new Expression(1))
|
||||
->from('discussions_tags')
|
||||
->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'view'))
|
||||
->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'))
|
||||
->where('discussions.id', new Expression('discussion_id'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class TagPolicy extends AbstractPolicy
|
|||
*/
|
||||
public function find(User $actor, Builder $query)
|
||||
{
|
||||
$query->whereNotIn('id', Tag::getIdsWhereCannot($actor, 'view'));
|
||||
$query->whereNotIn('id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -132,7 +132,7 @@ class Tag extends AbstractModel
|
|||
}
|
||||
|
||||
$ids = [];
|
||||
$hasGlobalPermission = $user->hasPermission($permission === 'view' ? 'forum.view' : $permission);
|
||||
$hasGlobalPermission = $user->hasPermission($permission);
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if (($hasGlobalPermission && ! $tag->is_restricted) || $user->hasPermission('tag' . $tag->id . '.' . $permission)) {
|
||||
|
@ -157,7 +157,7 @@ class Tag extends AbstractModel
|
|||
}
|
||||
|
||||
$ids = [];
|
||||
$hasGlobalPermission = $user->hasPermission($permission === 'view' ? 'forum.view' : $permission);
|
||||
$hasGlobalPermission = $user->hasPermission($permission);
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if (($tag->is_restricted || ! $hasGlobalPermission) && ! $user->hasPermission('tag' . $tag->id . '.' . $permission)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user