diff --git a/Web/Models/Entities/Comment.php b/Web/Models/Entities/Comment.php index fd32c0b8..c0460dd5 100644 --- a/Web/Models/Entities/Comment.php +++ b/Web/Models/Entities/Comment.php @@ -46,8 +46,11 @@ class Comment extends Post return parent::getOwner($honourFlags, $real); } - function canBeDeletedBy(User $user): bool + function canBeDeletedBy(User $user = NULL): bool { + if(!$user) + return false; + return $this->getOwner()->getId() == $user->getId() || $this->getTarget()->getOwner()->getId() == $user->getId() || $this->getTarget() instanceof Post && $this->getTarget()->getTargetWall() < 0 && (new Clubs)->get(abs($this->getTarget()->getTargetWall()))->canBeModifiedBy($user) || diff --git a/Web/Models/Entities/Post.php b/Web/Models/Entities/Post.php index 21f1591c..5d5469d4 100644 --- a/Web/Models/Entities/Post.php +++ b/Web/Models/Entities/Post.php @@ -260,16 +260,22 @@ class Post extends Postable $this->save(); } - function canBePinnedBy(User $user): bool + function canBePinnedBy(User $user = NULL): bool { + if(!$user) + return false; + if($this->getTargetWall() < 0) return (new Clubs)->get(abs($this->getTargetWall()))->canBeModifiedBy($user); return $this->getTargetWall() === $user->getId(); } - function canBeDeletedBy(User $user): bool + function canBeDeletedBy(User $user = NULL): bool { + if(!$user) + return false; + if($this->getTargetWall() < 0 && !$this->getWallOwner()->canBeModifiedBy($user) && $this->getWallOwner()->getWallType() != 1 && $this->getSuggestionType() == 0) return false;