MDL-39192 mod_forum: do not need to check the posting threshold when editing a post

This commit is contained in:
Mark Nelson 2013-04-24 12:24:20 +08:00
parent 14559e1849
commit eaa8f5ad53
2 changed files with 9 additions and 3 deletions

View File

@ -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);

View File

@ -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));