Permalink
Browse files

MDL-24258: eliminate student capability to delete their post when it …

…exceeded the max editing time.
  • Loading branch information...
1 parent b02ed89 commit c927eb443e653019ed2441336fbac7c9f08d121b @rwijaya rwijaya committed Sep 23, 2010
Showing with 9 additions and 2 deletions.
  1. +1 −0 lang/en_utf8/forum.php
  2. +8 −2 mod/forum/post.php
View
@@ -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.';
View
@@ -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"));

0 comments on commit c927eb4

Please sign in to comment.