Merge branch 'MDL-39303_master' of https://github.com/markn86/moodle

This commit is contained in:
Sam Hemelryk
2013-04-30 10:08:20 +12:00
2 changed files with 27 additions and 6 deletions
+19 -1
View File
@@ -7098,7 +7098,7 @@ function forum_check_throttling($forum, $cm = null) {
}
if (!is_object($forum)) {
return false; // This is broken.
return false; // This is broken.
}
if (!$cm) {
@@ -7154,6 +7154,24 @@ function forum_check_throttling($forum, $cm = null) {
}
}
/**
* Throws an error if the user is no longer allowed to post due to having reached
* or exceeded the number of posts specified in 'Post threshold for blocking'
* setting.
*
* @since Moodle 2.5
* @param stdClass $thresholdwarning the warning information returned
* from the function forum_check_throttling.
*/
function forum_check_blocking_threshold($thresholdwarning) {
if (!empty($thresholdwarning) && !$thresholdwarning->canpost) {
print_error($thresholdwarning->errorcode,
$thresholdwarning->module,
$thresholdwarning->link,
$thresholdwarning->additional);
}
}
/**
* Removes all grades from gradebook
+8 -5
View File
@@ -688,6 +688,9 @@ if ($fromform = $mform_post->get_data()) {
} else if ($fromform->discussion) { // Adding a new post to an existing discussion
// Before we add this we must check that the user will not exceed the blocking threshold.
forum_check_blocking_threshold($thresholdwarning);
unset($fromform->groupid);
$message = '';
$addpost = $fromform;
@@ -736,7 +739,10 @@ if ($fromform = $mform_post->get_data()) {
}
exit;
} else { // Adding a new discussion
} else { // Adding a new discussion.
// Before we add this we must check that the user will not exceed the blocking threshold.
forum_check_blocking_threshold($thresholdwarning);
if (!forum_user_can_post_discussion($forum, $fromform->groupid, -1, $cm, $modcontext)) {
print_error('cannotcreatediscussion', 'forum');
}
@@ -875,10 +881,7 @@ if ($forum->type == 'qanda'
// 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);
}
forum_check_blocking_threshold($thresholdwarning);
}
if (!empty($parent)) {