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