Brainstorm fix
This commit is contained in:
@@ -1047,6 +1047,71 @@ try {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 15. Outlook Agenda-afspraak verwijderen
|
||||
if ($action === 'delete_outlook_event') {
|
||||
$rawInput = json_decode(file_get_contents('php://input'), true);
|
||||
$data = is_array($rawInput) ? $rawInput : $_POST;
|
||||
$eventId = trim($data['event_id'] ?? '');
|
||||
|
||||
if (empty($eventId)) {
|
||||
echo json_encode(['success' => false, 'error' => 'Geen event ID opgegeven']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!function_exists('microsoft_delete_event')) {
|
||||
echo json_encode(['success' => false, 'error' => 'Microsoft integratie niet beschikbaar']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$ok = microsoft_delete_event((int)$user['id'], $eventId);
|
||||
if ($ok) {
|
||||
echo json_encode(['success' => true, 'message' => 'Afspraak succesvol verwijderd uit Outlook']);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'Kon afspraak niet verwijderen uit Outlook (mogelijk al verwijderd of geen bevoegdheid)']);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// 16. Outlook Agenda-afspraak bijwerken
|
||||
if ($action === 'update_outlook_event') {
|
||||
$rawInput = json_decode(file_get_contents('php://input'), true);
|
||||
$data = is_array($rawInput) ? $rawInput : $_POST;
|
||||
$eventId = trim($data['event_id'] ?? '');
|
||||
$subject = trim($data['title'] ?? ($data['subject'] ?? ''));
|
||||
$date = trim($data['date'] ?? date('Y-m-d'));
|
||||
$startTime = trim($data['time_block_start'] ?? ($data['start_time'] ?? '09:00'));
|
||||
$endTime = trim($data['time_block_end'] ?? ($data['end_time'] ?? '09:30'));
|
||||
$description = trim($data['description'] ?? '');
|
||||
|
||||
if (empty($eventId) || empty($subject)) {
|
||||
echo json_encode(['success' => false, 'error' => 'Titel of event ID ontbreekt']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!function_exists('microsoft_update_event')) {
|
||||
echo json_encode(['success' => false, 'error' => 'Microsoft integratie niet beschikbaar']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$updateData = [
|
||||
'subject' => $subject,
|
||||
'date' => $date,
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
if ($description !== '') {
|
||||
$updateData['description'] = $description;
|
||||
}
|
||||
|
||||
$ok = microsoft_update_event((int)$user['id'], $eventId, $updateData);
|
||||
if ($ok) {
|
||||
echo json_encode(['success' => true, 'date' => $date, 'message' => 'Afspraak succesvol bijgewerkt in Outlook']);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'Kon afspraak niet bijwerken in Microsoft Outlook']);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['error' => 'Onbekende actie']);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
|
||||
Reference in New Issue
Block a user