1
0
mirror of https://github.com/flarum/core.git synced 2025-10-20 19:27:14 +02:00

Create new hidePosts permission (#1466)

This commit is contained in:
AFR
2018-07-15 03:15:40 +07:00
committed by Franz Liedke
parent 9be13cb1cd
commit 034b82f4d4
8 changed files with 17 additions and 8 deletions

View File

@@ -68,7 +68,7 @@ class EditPostHandler
}
if (isset($attributes['isHidden'])) {
$this->assertCan($actor, 'edit', $post);
$this->assertCan($actor, 'hide', $post);
if ($attributes['isHidden']) {
$post->hide($actor);

View File

@@ -79,7 +79,7 @@ class PostPolicy extends AbstractPolicy
// Hide hidden posts, unless they are authored by the current user, or
// the current user has permission to view hidden posts in the
// discussion.
if (! $actor->hasPermission('discussion.editPosts')) {
if (! $actor->hasPermission('discussion.hidePosts')) {
$query->where(function ($query) use ($actor) {
$query->whereNull('posts.hide_time')
->orWhere('user_id', $actor->id)
@@ -89,7 +89,7 @@ class PostPolicy extends AbstractPolicy
->whereRaw('discussions.id = posts.discussion_id')
->where(function ($query) use ($actor) {
$this->events->dispatch(
new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'editPosts')
new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'hidePosts')
);
});
});