MDL-17365 forum rate - validate rating against scale values.
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
|
||||
$discussionid = false;
|
||||
|
||||
/// Calculate scale values
|
||||
$scale_values = make_grades_menu($forum->scale);
|
||||
|
||||
foreach ((array)$data as $postid => $rating) {
|
||||
if (!is_numeric($postid)) {
|
||||
continue;
|
||||
@@ -63,6 +66,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// Check rate is valid for for that forum scale values
|
||||
if (!array_key_exists($rating, $scale_values) && $rating != FORUM_UNSET_POST_RATING) {
|
||||
print_error('invalidrate', 'forum', '', $rating);
|
||||
}
|
||||
|
||||
if ($rating == FORUM_UNSET_POST_RATING) {
|
||||
delete_records('forum_ratings', 'post', $postid, 'userid', $USER->id);
|
||||
forum_update_grades($forum, $post->userid);
|
||||
|
||||
Reference in New Issue
Block a user