MDL-61055 calendar: guest user cannot create events
authorSimey Lameze <simey@moodle.com>
Tue, 19 Dec 2017 08:23:39 +0000 (16:23 +0800)
committerSimey Lameze <simey@moodle.com>
Tue, 19 Dec 2017 08:30:08 +0000 (16:30 +0800)
calendar/amd/build/calendar.min.js
calendar/amd/src/calendar.js
calendar/templates/month_detailed.mustache

index ffa3f2e..6a78673 100644 (file)
Binary files a/calendar/amd/build/calendar.min.js and b/calendar/amd/build/calendar.min.js differ
index 6102199..ecec1a0 100644 (file)
@@ -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 {
index 9abff8e..f3cdfeb 100644 (file)
                     <td class="dayblank">&nbsp;</td>
                 {{/prepadding}}
                 {{#days}}
-                    <td class="clickable day text-sm-center text-md-left{{!
+                    <td class="day text-sm-center text-md-left{{!
                             }}{{#istoday}} today{{/istoday}}{{!
                             }}{{#isweekend}} weekend{{/isweekend}}{{!
                             }}{{#durationevents.0}} duration{{/durationevents.0}}{{!
                             }}{{#durationevents}} duration_{{.}}{{/durationevents}}{{!
+                            }}{{#defaulteventcontext}} clickable{{/defaulteventcontext}}{{!
                         }}"
                         data-day-timestamp="{{timestamp}}"
                         data-drop-zone="month-view-day"