From 39cda4059022f417336b8488545fb3d5714be876 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 19 Dec 2017 16:23:39 +0800 Subject: [PATCH 1/1] MDL-61055 calendar: guest user cannot create events --- calendar/amd/build/calendar.min.js | Bin 2353 -> 2405 bytes calendar/amd/src/calendar.js | 57 +++++++++++---------- calendar/templates/month_detailed.mustache | 3 +- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/calendar/amd/build/calendar.min.js b/calendar/amd/build/calendar.min.js index ffa3f2ed8d529c7c013018f7dee98eeaa2165378..6a786738c119c1417f5097a1016e960c203f7335 100644 GIT binary patch delta 73 zcmdle^i*g=ExV0Qify7sfu6IYkE@@HV^F-Wzh8()e0Y#!K!9tIrd~>7Nuq{Qa(-S( cYDI}|W{Q%gb&*DrPO_#>ikjNyR`xZF0Asoq`Tzg` delta 21 ccmaDVv{7h7Ejx#Gkw%hEvZl`Fo$PBE0aJwsG5`Po diff --git a/calendar/amd/src/calendar.js b/calendar/amd/src/calendar.js index 6102199622d..ecec1a0351d 100644 --- a/calendar/amd/src/calendar.js +++ b/calendar/amd/src/calendar.js @@ -183,35 +183,38 @@ define([ .fail(Notification.exception); }); - var eventFormPromise = CalendarCrud.registerEventFormModal(root); + var eventFormPromise = CalendarCrud.registerEventFormModal(root), + contextId = $(SELECTORS.CALENDAR_MONTH_WRAPPER).data('context-id'); registerCalendarEventListeners(root, eventFormPromise); - // Bind click events to calendar days. - root.on('click', SELECTORS.DAY, function(e) { - - var target = $(e.target); - - if (!target.is(SELECTORS.VIEW_DAY_LINK)) { - var startTime = $(this).attr('data-new-event-timestamp'); - eventFormPromise.then(function(modal) { - var wrapper = target.closest(CalendarSelectors.wrapper); - modal.setCourseId(wrapper.data('courseid')); - - var categoryId = wrapper.data('categoryid'); - if (typeof categoryId !== 'undefined') { - modal.setCategoryId(categoryId); - } - - modal.setContextId(wrapper.data('contextId')); - modal.setStartTime(startTime); - modal.show(); - return; - }) - .fail(Notification.exception); - - e.preventDefault(); - } - }); + if (contextId) { + // Bind click events to calendar days. + root.on('click', SELECTORS.DAY, function (e) { + + var target = $(e.target); + + if (!target.is(SELECTORS.VIEW_DAY_LINK)) { + var startTime = $(this).attr('data-new-event-timestamp'); + eventFormPromise.then(function (modal) { + var wrapper = target.closest(CalendarSelectors.wrapper); + modal.setCourseId(wrapper.data('courseid')); + + var categoryId = wrapper.data('categoryid'); + if (typeof categoryId !== 'undefined') { + modal.setCategoryId(categoryId); + } + + modal.setContextId(wrapper.data('contextId')); + modal.setStartTime(startTime); + modal.show(); + return; + }) + .fail(Notification.exception); + + e.preventDefault(); + } + }); + } }; return { diff --git a/calendar/templates/month_detailed.mustache b/calendar/templates/month_detailed.mustache index 9abff8e2c2a..f3cdfeb696a 100644 --- a/calendar/templates/month_detailed.mustache +++ b/calendar/templates/month_detailed.mustache @@ -60,11 +60,12 @@   {{/prepadding}} {{#days}} -