From: Ryan Wyllie Date: Fri, 10 Nov 2017 02:20:32 +0000 (+0000) Subject: MDL-60766 block_calendar_upcoming: stop summary modal not logged in X-Git-Tag: v3.4.0-rc3~8^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=08b7558483af4440100f2f97c90afa23c84dc662 MDL-60766 block_calendar_upcoming: stop summary modal not logged in Stopped the JS from running on the block when the user is not logged in because it attempts to load a summary modal when an event is clicked on which results in a failed call to a webservice. --- diff --git a/calendar/classes/external/calendar_upcoming_exporter.php b/calendar/classes/external/calendar_upcoming_exporter.php index 42fe7b923ec..aead6d1dc88 100644 --- a/calendar/classes/external/calendar_upcoming_exporter.php +++ b/calendar/classes/external/calendar_upcoming_exporter.php @@ -87,6 +87,9 @@ class calendar_upcoming_exporter extends exporter { 'optional' => true, 'default' => 0, ], + 'isloggedin' => [ + 'type' => PARAM_BOOL, + ], ]; } @@ -106,6 +109,7 @@ class calendar_upcoming_exporter extends exporter { 'course' => $this->calendar->course->id, ]); $this->url = $url; + $return['isloggedin'] = isloggedin(); $return['events'] = array_map(function($event) use ($cache, $output, $url) { $context = $cache->get_context($event); $course = $cache->get_course($event); diff --git a/calendar/templates/calendar_upcoming_mini.mustache b/calendar/templates/calendar_upcoming_mini.mustache index 8f276be1762..c2317bd955f 100644 --- a/calendar/templates/calendar_upcoming_mini.mustache +++ b/calendar/templates/calendar_upcoming_mini.mustache @@ -34,8 +34,10 @@
{{> core_calendar/upcoming_mini}}
+{{#isloggedin}} {{#js}} require(['jquery', 'core_calendar/calendar_view'], function($, CalendarView) { CalendarView.init($("#calendar-upcoming-block-{{uniqid}}"), 'upcoming'); }); {{/js}} +{{/isloggedin}}