Permalink
Browse files

MDL-52573 report_grader: only check cap of installed plugins

Previously we were linking to gradebook plugins regardless of whether
they were installed. This should be fixed properly in MDL-52678.
  • Loading branch information...
danpoltawski committed Jan 7, 2016
1 parent 7817f82 commit 114ebc37423e48f9cdf401937bfdd514adfe9b32
Showing with 24 additions and 13 deletions.
  1. +24 −13 grade/report/grader/lib.php
@@ -589,9 +589,16 @@ public function get_left_rows($displayaverages) {
$rows = array();
$showuserimage = $this->get_pref('showuserimage');
$canseeuserreport = has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context);
$canseesingleview = has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall',
// FIXME: MDL-52678 This get_capability_info is hacky and we should have an API for inserting grade row links instead.
$canseeuserreport = false;
$canseesingleview = false;
if (get_capability_info('gradereport/'.$CFG->grade_profilereport.':view')) {
$canseeuserreport = has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context);
}
if (get_capability_info('gradereport/singleview:view')) {
$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");
@@ -838,17 +845,21 @@ public function get_right_rows($displayaverages) {
}
$singleview = '';
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',
'itemid' => $element['object']->id));
$singleview = $OUTPUT->action_icon(
$url,
new pix_icon('t/editstring', get_string('singleview', 'grades', $element['object']->get_name()))
);
// FIXME: MDL-52678 This is extremely hacky we should have an API for inserting grade column links.
if (get_capability_info('gradereport/singleview:view')) {
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',
'itemid' => $element['object']->id));
$singleview = $OUTPUT->action_icon(
$url,
new pix_icon('t/editstring', get_string('singleview', 'grades', $element['object']->get_name()))
);
}
}
$itemcell->colspan = $colspan;

0 comments on commit 114ebc3

Please sign in to comment.