From dadd6f9fcc150fdd1b57ac8e2968a1742e2f418e Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 9 Aug 2017 14:47:35 +0800 Subject: [PATCH] MDL-59671 core_calendar: create calendar_delete_event_allowed function --- calendar/lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/calendar/lib.php b/calendar/lib.php index 45d12971782..9b7b76f3911 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -2493,6 +2493,17 @@ function calendar_edit_event_allowed($event) { return false; } +/** + * Return the capability for deleting a calendar event. + * + * @param calendar_event $event The event object + * @return bool Whether the user has permission to delete the event or not. + */ +function calendar_delete_event_allowed($event) { + // Only allow delete if you have capabilities and it is not an module event. + return (calendar_edit_event_allowed($event) && empty($event->modulename)); +} + /** * Returns the default courses to display on the calendar when there isn't a specific * course to display.