Skip to content

Commit

Permalink
Issue 59: Only delete comments when new ones can be posted
Browse files Browse the repository at this point in the history
This is to stop users being able to delete comments in a frozen context
  • Loading branch information
NeillM committed Mar 15, 2024
1 parent 60ac91d commit b474bd9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions classes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ public static function can_create($context) {
public function can_delete() {
global $USER;

if ($this->userid == $USER->id) {
$context = $this->get_context();
if ($this->userid == $USER->id && has_capability('mod/board:postcomment', $context)) {
return true;
}

$context = $this->get_context();
if (has_capability('mod/board:deleteallcomments', $context)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion external.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ public static function get_comments($noteid) {
$comment->id = $note->id;
$comment->noteid = $note->noteid;
$comment->content = $note->content;
$comment->candelete = ($note->userid === $USER->id || $candeleteall) ? true : false;
$comment->candelete = (($canpost && $note->userid === $USER->id) || $candeleteall) ? true : false;
$comment->date = userdate($note->timecreated);
$comments[] = $comment;
}
Expand Down

0 comments on commit b474bd9

Please sign in to comment.