$move_to], 'edit'))) { apiDeny("The user linked to this API key does not have access to the target client for this write."); } $client_id = $move_to; } require_once 'event_model.php'; mysqli_query($mysqli, "UPDATE calendar_events SET $event_set WHERE event_id = $event_id"); // A change a calendar that already has it needs to know about moves it on a version $event = calendarEventRow($event_id); $changed = false; foreach (['event_title', 'event_start', 'event_end', 'event_all_day', 'event_location', 'event_location_id', 'event_description', 'event_repeat', 'event_repeat_interval', 'event_repeat_until'] as $field) { if ((string) $event_row[$field] !== (string) $event[$field]) { $changed = true; } } if ($changed) { mysqli_query($mysqli, "UPDATE calendar_events SET event_sequence = event_sequence + 1 WHERE event_id = $event_id"); $event['event_sequence'] = intval($event['event_sequence']) + 1; } $attendees = $event_attendees ? calendarSetAttendees($event_id, $client_id, ...$event_attendees) : ['new' => [], 'removed' => []]; $emailed = 0; if (!empty($_POST['send_invites'])) { $invite = []; $update = []; foreach (calendarEventAttendees($event_id) as $attendee) { if (!in_array(intval($attendee['attendee_id']), $attendees['new'], true) && !empty($attendee['attendee_invited_at'])) { $update[] = $attendee; } else { $invite[] = $attendee; } } $emailed += calendarSendInvites($event, 'invite', $invite); if ($changed) { $emailed += calendarSendInvites($event, 'update', $update); } $emailed += calendarSendInvites($event, 'cancel', array_values(array_filter($attendees['removed'], function ($attendee) { return !empty($attendee['attendee_invited_at']); }))); } $update_count = 1; $return_arr['emailed'] = $emailed; $label = escapeSql($event['event_title']); logAudit("Calendar Event", "Edit", "Edited the event $label via API ($api_key_name)", $client_id, $event_id); logAudit("API", "Success", "Edited the event $label via API ($api_key_name)", $client_id); } // Output require_once '../update_output.php';