var modalParams = {
title: eventData.name,
type: SummaryModal.TYPE,
- body: Templates.render('core_calendar/event_summary_body', eventData)
+ body: Templates.render('core_calendar/event_summary_body', eventData),
+ templateContext: {
+ canedit: eventData.canedit,
+ candelete: eventData.candelete
+ }
};
- if (!eventData.caneditevent) {
- modalParams.footer = '';
- }
+
// Create the modal.
return ModalFactory.create(modalParams);
*/
var ModalEventSummary = function(root) {
Modal.call(this, root);
-
- if (!this.getEditButton().length) {
- Notification.exception({message: 'No edit button found'});
- }
-
- if (!this.getDeleteButton().length) {
- Notification.exception({message: 'No delete button found'});
- }
};
ModalEventSummary.TYPE = 'core_calendar-event_summary';
'optional' => true,
'default' => null,
'null' => NULL_ALLOWED
- ]
+ ],
+ 'isactionevent' => ['type' => PARAM_BOOL],
+ 'candelete' => ['type' => PARAM_BOOL]
];
}
$legacyevent = container::get_event_mapper()->from_event_to_legacy_event($event);
$context = $this->related['context'];
+ $values['isactionevent'] = false;
if ($moduleproxy = $event->get_course_module()) {
$modulename = $moduleproxy->get('modname');
$moduleid = $moduleproxy->get('id');
$url = new \moodle_url(sprintf('/mod/%s/view.php', $modulename), ['id' => $moduleid]);
+ $values['isactionevent'] = true;
} else {
// TODO MDL-58866 We do not have any way to find urls for events outside of course modules.
global $CFG;
$coursesummaryexporter = new course_summary_exporter($course, ['context' => $context]);
$values['course'] = $coursesummaryexporter->export($output);
}
+
$values['canedit'] = calendar_edit_event_allowed($legacyevent);
+ $values['candelete'] = (!$values['isactionevent'] && $values['canedit']);
// Handle event subscription.
$values['subscription'] = null;