}
$values['canedit'] = calendar_edit_event_allowed($legacyevent);
- $values['candelete'] = (!$values['isactionevent'] && $values['canedit']);
+ $values['candelete'] = calendar_delete_event_allowed($legacyevent);
// Handle event subscription.
$values['subscription'] = null;
if (!$course) {
$PAGE->set_context(context_system::instance()); //TODO: wrong
}
-
-// Check the user has the required capabilities to edit an event
-if (!calendar_edit_event_allowed($event)) {
- print_error('nopermissions');
+$title = get_string('deleteevent', 'calendar');
+// Check the user has the required capabilities to delete an event
+if (!calendar_delete_event_allowed($event)) {
+ print_error('nopermissions', 'error', $PAGE->url, $title);
}
// Count the repeats, do we need to consider the possibility of deleting repeats
}
// Prepare the page to show the confirmation form
-$title = get_string('deleteevent', 'calendar');
$strcalendar = get_string('calendar', 'calendar');
$PAGE->navbar->add($strcalendar, $viewcalendarurl);
$eventobj = calendar_event::load($event['eventid']);
// Let's check if the user is allowed to delete an event.
- if (!calendar_edit_event_allowed($eventobj)) {
- throw new moodle_exception("nopermissions");
+ if (!calendar_delete_event_allowed($eventobj)) {
+ throw new moodle_exception('nopermissions', 'error', '', get_string('deleteevent', 'calendar'));
}
// Time to do the magic.
$eventobj->delete($event['repeat']);
$output .= $this->output->box_start('card-header clearfix');
if (calendar_edit_event_allowed($event) && $showactions) {
- if (empty($event->cmid)) {
+ if (calendar_delete_event_allowed($event)) {
$editlink = new moodle_url(CALENDAR_URL.'event.php', array('action' => 'edit', 'id' => $event->id));
$deletelink = new moodle_url(CALENDAR_URL.'delete.php', array('id' => $event->id));
if (!empty($event->calendarcourseid)) {