Skip to content

Commit

Permalink
MDL-52573 report_grader: only check cap of installed plugins
Browse files Browse the repository at this point in the history
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 14, 2016
1 parent e65dfd9 commit 2811831
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2811831

Please sign in to comment.