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

This commit is contained in:
toyomoyo
2007-08-28 07:01:42 +00:00
parent c15b5c3c96
commit 1f7790ffe5
2 changed files with 8 additions and 3 deletions
+6 -2
View File
@@ -955,8 +955,12 @@ function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
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="" />';
}
}
}
+2 -1
View File
@@ -141,7 +141,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>';
}