MDL-12122 Applied Petr's suggested capability fix
This commit is contained in:
@@ -36,15 +36,18 @@ if (!$course = get_record('course', 'id', $courseid)) {
|
||||
}
|
||||
require_login($course);
|
||||
|
||||
|
||||
if ($userid !== 0 && !$user = get_complete_user_data('id', $userid)) {
|
||||
error("Incorrect userid");
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $userid);
|
||||
require_capability('gradereport/user:view', $context);
|
||||
|
||||
if (empty($userid)) {
|
||||
require_capability('moodle/grade:viewall', $context);
|
||||
|
||||
} else {
|
||||
if (!get_complete_user_data('id', $userid)) {
|
||||
error("Incorrect userid");
|
||||
}
|
||||
}
|
||||
|
||||
$access = true;
|
||||
if (has_capability('moodle/grade:viewall', $context)) {
|
||||
//ok - can view all course grades
|
||||
@@ -52,7 +55,7 @@ if (has_capability('moodle/grade:viewall', $context)) {
|
||||
} else if ($userid == $USER->id and has_capability('moodle/grade:view', $context) and $course->showgrades) {
|
||||
//ok - can view own grades
|
||||
|
||||
} else if (has_capability('moodle/grade:viewall', $usercontext) and $course->showgrades) {
|
||||
} else if ($has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_USER, $userid)) and $course->showgrades) {
|
||||
// ok - can view grades of this user- parent most probably
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user