From f01de70e4f7b89c7bd2699018cdfd8918934c6ac Mon Sep 17 00:00:00 2001 From: Maarten Wolzak Date: Tue, 5 Mar 2019 14:34:32 +0100 Subject: [PATCH] Commenter can remove their own comment when not in the moderator group Before this change, you had to be a moderator even if you only wanted to remove your own comment. --- core/components/quip/controllers/web/Thread.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/components/quip/controllers/web/Thread.php b/core/components/quip/controllers/web/Thread.php index a9c253d..dfde4f5 100644 --- a/core/components/quip/controllers/web/Thread.php +++ b/core/components/quip/controllers/web/Thread.php @@ -333,7 +333,12 @@ public function checkPermissions() { public function handleActions() { /* handle remove post */ $removeAction = $this->getProperty('removeAction','quip-remove'); - if (!empty($_REQUEST[$removeAction]) && $this->hasAuth && $this->isModerator) { + + /* handle author remove their own comment even when they are not moderator */ + $currentComment = $this->getComments()[(int)$_REQUEST['quip_comment']]; + + if (!empty($_REQUEST[$removeAction]) && $this->hasAuth && ($this->isModerator + || (!empty($currentComment) && $currentComment->get('author') == $this->modx->user->get('id')))) { $this->removeComment(); } /* handle report spam */ @@ -480,4 +485,4 @@ public function render(array $comments = array()) { return implode("\n",$list); } } -return 'QuipThreadController'; \ No newline at end of file +return 'QuipThreadController';