MDL-49826 grade: hide singleview links when no permissions

Singleview only supports grade editors not viewers at this time.
This commit is contained in:
Dan Poltawski 2015-08-27 10:09:33 +01:00 committed by Eloy Lafuente (stronk7)
parent 1b5034025b
commit 4ae71e93a8
2 changed files with 11 additions and 2 deletions

View File

@ -2887,6 +2887,12 @@ abstract class grade_helper {
continue;
}
// Singleview doesn't doesn't accomodate for all cap combos yet, so this is hardcoded..
if ($plugin === 'singleview' && !has_all_capabilities(array('moodle/grade:viewall',
'moodle/grade:edit'), $context)) {
continue;
}
$pluginstr = get_string('pluginname', 'gradereport_'.$plugin);
$url = new moodle_url('/grade/report/'.$plugin.'/index.php', array('id'=>$courseid));
$gradereports[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr);

View File

@ -590,7 +590,8 @@ class grade_report_grader extends grade_report {
$showuserimage = $this->get_pref('showuserimage');
$canseeuserreport = has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context);
$canseesingleview = has_capability('gradereport/singleview:view', $this->context);
$canseesingleview = has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall',
'moodle/grade:edit'), $this->context);
$hasuserreportcell = $canseeuserreport || $canseesingleview;
$strfeedback = $this->get_lang_string("feedback");
@ -836,7 +837,9 @@ class grade_report_grader extends grade_report {
}
$singleview = '';
if (has_capability('gradereport/singleview:view', $this->context)) {
if (has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall',
'moodle/grade:edit'), $this->context)) {
$url = new moodle_url('/grade/report/singleview/index.php', array(
'id' => $this->course->id,
'item' => 'grade',