diff --git a/lang/en_utf8/forum.php b/lang/en_utf8/forum.php index b1e6c216e01b2..09af61fce6dc8 100644 --- a/lang/en_utf8/forum.php +++ b/lang/en_utf8/forum.php @@ -31,6 +31,7 @@ $string['cannotviewpostyet'] = 'You cannot read other students questions in this discussion yet because you haven\'t posted'; $string['cannotadddiscussion'] = 'Adding discussions to this forum requires group membership.'; $string['cannotadddiscussionall'] = 'You do not have permission to add a new discussion topic for all participants.'; +$string['cannotdeletepost'] = 'You can\'t delete this post!'; $string['cleanreadtime'] = 'Mark old posts as read hour'; $string['configajaxrating'] = 'AJAX rating is a forum rating usability improvement. If enabled, users can rate forum posts almost instantly without needing to scroll to the bottom of the page and click the \'Send in my latest ratings\' button. This setting also requires AJAX to be enabled for the site and in user profiles.'; $string['configcleanreadtime'] = 'The hour of the day to clean old posts from the \'read\' table.'; diff --git a/mod/forum/post.php b/mod/forum/post.php index 97caee6a120c1..d42232c44221b 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -265,9 +265,15 @@ $replycount = forum_count_replies($post); - + if (!empty($confirm) && confirm_sesskey()) { // User has confirmed the delete - + //check user capability to delete post. + $timepassed = time() - $post->created; + if (($timepassed > $CFG->maxeditingtime) && !has_capability('mod/forum:deleteanypost', $modcontext)) { + print_error("cannotdeletepost", "forum", + forum_go_back_to("discuss.php?d=$post->discussion")); + } + if ($post->totalscore) { notice(get_string("couldnotdeleteratings", "forum"), forum_go_back_to("discuss.php?d=$post->discussion"));