merged fix for MDL-10818, do not display graph if user has no permission

This commit is contained in:
toyomoyo 2007-08-28 07:04:41 +00:00
parent beb67c0526
commit a683deeca6
2 changed files with 9 additions and 4 deletions

View File

@ -959,12 +959,16 @@ function print_log_ods($course, $user, $date, $order='l.time DESC', $modname,
function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
global $CFG;
global $CFG, $USER;
if (empty($CFG->gdversion)) {
echo "(".get_string("gdneed").")";
} else {
echo '<img src="'.$CFG->wwwroot.'/course/report/log/graph.php?id='.$course->id.
'&amp;user='.$userid.'&amp;type='.$type.'&amp;date='.$date.'" alt="" />';
// MDL-10818, do not display broken graph when user has no permission to view graph
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id)) ||
($course->showreports and $USER->id == $userid)) {
echo '<img src="'.$CFG->wwwroot.'/course/report/log/graph.php?id='.$course->id.
'&amp;user='.$userid.'&amp;type='.$type.'&amp;date='.$date.'" alt="" />';
}
}
}

View File

@ -157,7 +157,8 @@
}
// MDL-10818, do not display broken graph when user has no permission to view graph
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $id))) {
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $id)) ||
($course->showreports and $USER->id == $user->id)) {
echo '<center><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.STATS_MODE_DETAILED.'&course='.$course->id.'&time='.$time.'&report='.STATS_REPORT_USER_VIEW.'&userid='.$user->id.'" alt="'.get_string('statisticsgraph').'" /></center>';
}