diff --git a/calendar_action.php b/calendar_action.php
index 6ff8ee1..420d2d0 100644
--- a/calendar_action.php
+++ b/calendar_action.php
@@ -115,8 +115,10 @@ switch ($action) {
case 'update':
$entry = $loadEntry((int) ($_POST['id'] ?? 0));
- if ((int) $entry['user_id'] !== $myId) {
- set_flash('error', 'Nur wer den Termin eingetragen hat, kann ihn bearbeiten.');
+ // Wie beim Loeschen: der Verfasser - und die Moderation bei Terminen, die sie sehen darf
+ $isAuthor = (int) $entry['user_id'] === $myId;
+ if (!$isAuthor && (!moderation_can() || !calendar_can_view($entry, $canLead, $myId))) {
+ set_flash('error', 'Diesen Termin darfst du nicht bearbeiten.');
redirect($backTo($entry['starts_at'], (int) $entry['id']));
}
[$title, $description, $startsAt, $endsAt, $locationPath] = $readInput();
@@ -125,15 +127,23 @@ switch ($action) {
set_flash('error', 'Der Termin enthält ein Wort, das hier nicht erlaubt ist.');
redirect($backTo($startsAt, (int) $entry['id']));
}
- // Wartet er schon auf Freigabe, bleibt das so; sonst neu pruefen (Links, Filterwoerter)
+ // Wartet er schon auf Freigabe, bleibt das so; sonst neu pruefen (Links, Filterwoerter).
+ // Bearbeitet die Moderation, bleibt die Freigabe, wie sie ist.
[$status, $note] = moderation_initial_status('calendar', $text);
- if ($entry['status'] === 'pending') {
- [$status, $note] = ['pending', $entry['moderation_note']];
+ if ($entry['status'] === 'pending' || !$isAuthor) {
+ [$status, $note] = [$entry['status'], $entry['moderation_note']];
}
$audience = calendar_audience_input((string) ($entry['audience'] ?? 'all'), $canLead);
$pdo->prepare(
'UPDATE calendar_entries SET title = ?, description = ?, starts_at = ?, ends_at = ?, location_path = ?, audience = ?, status = ?, moderation_note = ?, updated_at = ? WHERE id = ?'
)->execute([$title, $description, $startsAt, $endsAt, $locationPath, $audience, $status, $note, date('Y-m-d H:i:s'), (int) $entry['id']]);
+ if (!$isAuthor) {
+ admin_log('🗓️ Kalender-Termin bearbeitet (Moderation)', [
+ 'Von' => admin_log_user((int) $entry['user_id']),
+ 'Termin' => $entry['title'] . ' – ' . date('d.m.Y H:i', strtotime((string) $entry['starts_at'])) . ' Uhr',
+ 'Jetzt' => $title . ' – ' . date('d.m.Y H:i', strtotime($startsAt)) . ' Uhr',
+ ], 'info', 'events');
+ }
set_flash('success', $status === 'pending' ? 'Termin gespeichert - für alle sichtbar nach der Freigabe.' : 'Termin gespeichert.');
redirect($backTo($startsAt, (int) $entry['id']));
diff --git a/includes/calendar_entry.php b/includes/calendar_entry.php
index 8c455e4..b79a741 100644
--- a/includes/calendar_entry.php
+++ b/includes/calendar_entry.php
@@ -94,7 +94,8 @@ $actionForm = static function (string $action, string $label, string $class) use
-
+
+
= icon('edit') ?>