From ae60308e76d504677c16d1d16a1549b49ed50899 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 4 Sep 2014 12:30:11 +1200 Subject: [PATCH] CONTRIB-5245 Check to make sure user can view this attendance before showing related report. --- renderables.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/renderables.php b/renderables.php index 75c5324..40de409 100644 --- a/renderables.php +++ b/renderables.php @@ -353,7 +353,7 @@ class attendance_user_data implements renderable { private $urlparams; public function __construct(attendance $att, $userid) { - global $CFG; + global $CFG, $USER; $this->user = $att->get_user($userid); @@ -388,6 +388,10 @@ class attendance_user_data implements renderable { $this->grade = array(); $this->maxgrade = array(); foreach ($this->coursesatts as $ca) { + // Check to make sure the user can view this cm. + if (!get_fast_modinfo($ca->courseid)->instances['attendance'][$ca->attid]->uservisible) { + continue; + } $statuses = att_get_statuses($ca->attid); $user_taken_sessions_count = att_get_user_taken_sessions_count($ca->attid, $ca->coursestartdate, $userid, $att->cm); $user_statuses_stat = att_get_user_statuses_stat($ca->attid, $ca->coursestartdate, $userid, $att->cm);