From f11fdf9c98dd565820586dc7a9ef9c46d0576aeb Mon Sep 17 00:00:00 2001 From: Neill Magill Date: Tue, 20 Oct 2015 10:05:08 +0100 Subject: [PATCH] MDL-51495 calendar: E_WARNING in core_calendar_get_calendar_events If a user does not have the 'moodle/calendar:manageentries' capability then an E_WARNING can be generated by the core_calendar_external::get_calendar_events() method, that an expected array is null This patch creates an array that is missing when a user does not have the capability. --- calendar/externallib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/calendar/externallib.php b/calendar/externallib.php index 8fdae9b759d..c2053fa9d48 100644 --- a/calendar/externallib.php +++ b/calendar/externallib.php @@ -173,6 +173,8 @@ class core_calendar_external extends external_api { // Let us findout courses that we can return events from. if (!$hassystemcap) { + $courses = enrol_get_my_courses('id'); + $courses = array_keys($courses); foreach ($params['events']['courseids'] as $id) { try { $context = context_course::instance($id); @@ -185,7 +187,6 @@ class core_calendar_external extends external_api { 'warningcode' => 'nopermissions', 'message' => 'No access rights in course context '.$e->getMessage().$e->getTraceAsString() ); - continue; } } } else {