LuminaWebsite/event_edit_action.php
Maaxxs 300dae4263 Events: new tab for the bot's scheduled event reminders
Mirrors the bot's event planner (/event_planen, /event_liste) on the
website: list all scheduled reminders with a filter for recurring/one-off,
create, edit and delete them. Both sides talk to the same bot database, so
a reminder scheduled in Discord shows up here right away and vice versa -
sending stays with the bot's background job.

Channel and role are real dropdowns pulled from the Discord server instead
of raw IDs (channels the bot cannot post in are disabled), and the form
shows a live preview of the later Discord message, like the bot does before
scheduling. The timestamp is sent as "TT.MM.JJJJ HH:MM" and converted on
the bot side, exactly like the raids, so both ends use the same timezone.

New permissions events.view / events.manage - existing installs have to
add and assign them once under Berechtigungsgruppen.

Needs the matching bot-side API additions (PATCH /api/events/{id},
GET /api/guilds/{id}/channels and /roles, next_run_raw on POST /api/events,
channel/role names in the event list), which live in the separate bot repo.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 12:40:56 +02:00

31 lines
915 B
PHP

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/events_api.php';
require_permission('events.manage');
$input = read_json_body();
verify_csrf_token($input['csrf_token'] ?? '');
$eventId = (int) ($input['event_id'] ?? 0);
if ($eventId <= 0) {
json_response(false, 'Ungültiges Event.');
}
$fields = event_fields_from_input($input);
if (is_string($fields)) {
json_response(false, $fields);
}
try {
update_event($eventId, [
'name' => $fields['name'],
'message' => $fields['message'],
'channel_id' => $fields['channel_id'],
'role_id' => $fields['role_id'],
'next_run_raw' => $fields['next_run_raw'],
'interval_seconds' => $fields['interval_seconds'],
]);
json_response(true, 'Event wurde gespeichert.');
} catch (Throwable $e) {
json_response(false, 'Speichern fehlgeschlagen: ' . $e->getMessage());
}