Update references to forum. permissions

ref flarum/core#425
This commit is contained in:
Toby Zerner 2015-10-14 16:12:10 +10:30
parent 67c1d79c5c
commit eb49e1d4e8
4 changed files with 11 additions and 21 deletions

View File

@ -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 '';
}

View File

@ -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'));
});
}

View File

@ -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'));
}
/**

View File

@ -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)) {