MDL-49351 ratings: Correct check of viewallratings permission

This commit is contained in:
Juan Leyva
2015-03-06 11:33:56 +01:00
parent b90f98dade
commit c73b8d85c5
+6 -3
View File
@@ -60,9 +60,8 @@ if ($popup) {
if (!has_capability('moodle/rating:view', $context)) {
print_error('noviewrate', 'rating');
}
if (!has_capability('moodle/rating:viewall', $context) and $USER->id != $item->userid) {
print_error('noviewanyrate', 'rating');
}
$canviewallratings = has_capability('moodle/rating:viewall', $context);
switch ($sort) {
case 'firstname':
@@ -119,6 +118,10 @@ if (!$ratings) {
$maxrating = max(array_keys($scalemenu));
foreach ($ratings as $rating) {
if (!$canviewallratings and $USER->id != $rating->userid) {
continue;
}
// Undo the aliasing of the user id column from user_picture::fields().
// We could clone the rating object or preserve the rating id if we needed it again
// but we don't.