From eaa8f5ad539911a4e72c031ec074054e662118df Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 24 Apr 2013 12:24:20 +0800 Subject: [PATCH] MDL-39192 mod_forum: do not need to check the posting threshold when editing a post --- mod/forum/post.php | 7 +++++-- mod/forum/post_form.php | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mod/forum/post.php b/mod/forum/post.php index ba95c46da45..69913bff1bb 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -514,7 +514,8 @@ $mform_post = new mod_forum_post_form('post.php', array('course' => $course, 'modcontext' => $modcontext, 'forum' => $forum, 'post' => $post, - 'thresholdwarning' => $thresholdwarning), 'post', '', array('id' => 'mformforum')); + 'thresholdwarning' => $thresholdwarning, + 'edit' => $edit), 'post', '', array('id' => 'mformforum')); $draftitemid = file_get_submitted_draft_itemid('attachments'); file_prepare_draft_area($draftitemid, $modcontext->id, 'mod_forum', 'attachment', empty($post->id)?null:$post->id, mod_forum_post_form::attachment_options($forum)); @@ -871,7 +872,9 @@ if ($forum->type == 'qanda' echo $OUTPUT->notification(get_string('qandanotify','forum')); } -if (!empty($thresholdwarning)) { +// If there is a warning message and we are not editing a post we need to handle the warning. +if (!empty($thresholdwarning) && !$edit) { + // Here we want to throw an exception if they are no longer allowed to post. if (!$thresholdwarning->canpost) { print_error($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->link, $thresholdwarning->additional); diff --git a/mod/forum/post_form.php b/mod/forum/post_form.php index 3de63873bf7..1cb99ec37b8 100644 --- a/mod/forum/post_form.php +++ b/mod/forum/post_form.php @@ -75,11 +75,14 @@ class mod_forum_post_form extends moodleform { $modcontext = $this->_customdata['modcontext']; $forum = $this->_customdata['forum']; $post = $this->_customdata['post']; + $edit = $this->_customdata['edit']; $thresholdwarning = $this->_customdata['thresholdwarning']; $mform->addElement('header', 'general', '');//fill in the data depending on page params later using set_data - if (!empty($thresholdwarning)) { + // If there is a warning message and we are not editing a post we need to handle the warning. + if (!empty($thresholdwarning) && !$edit) { + // Here we want to display a warning if they can still post but have reached the warning threshold. if ($thresholdwarning->canpost) { $message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional); $mform->addElement('html', $OUTPUT->notification($message));