1
0
mirror of https://github.com/flarum/core.git synced 2025-10-10 06:24:26 +02:00

Improve some post/discussion permission logic

- Allow users to see their own posts, even if they have been hidden by
someone else
- Don't require hiding a post to be necessarily attributed to a user
- Hide discussions with zero posts, unless the user can edit posts, or
they are the discussion author
This commit is contained in:
Toby Zerner
2015-09-04 12:22:27 +09:30
parent 9277fca0ec
commit 276334ec52
4 changed files with 61 additions and 6 deletions

View File

@@ -87,7 +87,7 @@ class CommentPost extends Post
* @param User $actor
* @return $this
*/
public function hide(User $actor)
public function hide(User $actor = null)
{
if ($this->number == 1) {
throw new DomainException('Cannot hide the first post of a discussion');
@@ -95,7 +95,7 @@ class CommentPost extends Post
if (! $this->hide_time) {
$this->hide_time = time();
$this->hide_user_id = $actor->id;
$this->hide_user_id = $actor ? $actor->id : null;
$this->raise(new PostWasHidden($this));
}