From f0089f669c0982d3b5512855c837cbf9d2ee13b9 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 7 Jul 2016 12:14:21 +1200 Subject: [PATCH] Fixes #209 use correct url to redirect to view, fix some missing object warnings. --- classes/structure.php | 13 +++++++++---- manage.php | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/classes/structure.php b/classes/structure.php index 4acc3a7..4e0f0af 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -676,10 +676,15 @@ class mod_attendance_structure { GROUP BY ue.userid, ue.status"; $params = array('zerotime' => 0, 'uid' => $userid, 'estatus' => ENROL_INSTANCE_ENABLED, 'courseid' => $this->course->id); $enrolments = $DB->get_record_sql($sql, $params); - - $user->enrolmentstatus = $enrolments->status; - $user->enrolmentstart = $enrolments->mintime; - $user->enrolmentend = $enrolments->maxtime; + if (!empty($enrolments)) { + $user->enrolmentstatus = $enrolments->status; + $user->enrolmentstart = $enrolments->mintime; + $user->enrolmentend = $enrolments->maxtime; + } else { + $user->enrolmentstatus = ''; + $user->enrolmentstart = 0; + $user->enrolmentend = 0; + } return $user; } diff --git a/manage.php b/manage.php index 55ea0f4..5623013 100644 --- a/manage.php +++ b/manage.php @@ -46,7 +46,8 @@ $capabilities = array( 'mod/attendance:changeattendances' ); if (!has_any_capability($capabilities, $context)) { - redirect($att->url_view()); + $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); + redirect($url); } $pageparams->init($cm);