diff --git a/README.md b/README.md index c6b6b87..546ba34 100644 --- a/README.md +++ b/README.md @@ -740,6 +740,25 @@ Zentral in `includes/security.php` (Grenzen in `SECURITY_LIMITS`): - **Sofort eingreifen:** In der Benutzerverwaltung pro Konto „Abmelden erzwingen“ (alle Sitzungen beenden) und „Sperren und überall abmelden“ - über `users.session_epoch`. +## Kalender + +**Kalender** im Menü (`calendar.php`) zeigt Raids (gold) und Events (blau) als Monatsübersicht mit +Terminliste darunter - live aus der Bot-API, also ohne doppelte Datenhaltung: was im Discord bzw. +auf den Seiten Raids/Events angelegt wird, steht automatisch drin. Wiederkehrende Events werden im +Intervall fortgeschrieben. Klick auf einen Termin führt zum Raid bzw. zu den Events; auf dem Handy +zeigt das Raster Punkte und ein Tipp auf den Tag springt zu seinen Terminen. Man sieht, was man +sehen darf (`raids.view` / `events.view`). Mit `events.manage` lässt sich der Kalender unten auf der +Seite **öffentlich** schalten: dann auch ohne Anmeldung sichtbar (nur Titel und Uhrzeit, keine +Anmeldungen/Kanäle) und oben auf der Startseite verlinkt („Termine“). + +**Eigene Termine:** Jedes Mitglied kann über „+ Termin eintragen“ selbst etwas in den Kalender +stellen (grün, Tabelle `calendar_entries`) - z.B. „Mobs farmen um 20 Uhr mit Damaskar“, mit +optionalem Ende und Beschreibung. Andere schließen sich mit „Bin dabei“ an +(`calendar_participants`, Avatare der Teilnehmer). Bearbeiten darf der Veranstalter, löschen auch +die Moderation. Es gelten dieselben Regeln wie bei Kommentaren: Schimpfwortfilter, Termine mit +Links bzw. von neuen Mitgliedern erst nach Freigabe (Moderation → Freigabe), Melden-Knopf, +höchstens 8 neue Termine pro Stunde (`calendar_action.php`). + ## Moderation (Galeriebilder und Kommentare) `includes/moderation.php`, Seite **Admin → Moderation** (`moderation.php`, Berechtigung diff --git a/admin/settings_action.php b/admin/settings_action.php index a9baebd..e56e9f2 100644 --- a/admin/settings_action.php +++ b/admin/settings_action.php @@ -24,6 +24,7 @@ $settingLabels = [ 'discord_unlink_allowed' => 'Mitglieder dürfen ihre Discord-Verknüpfung lösen', 'contributions_history_public' => 'Lumipunkte-Verlauf für alle sichtbar', 'moderation_all' => 'Alle neuen Bilder und Kommentare manuell freigeben', + 'calendar_public' => 'Kalender öffentlich (ohne Anmeldung)', ]; admin_log('⚙️ Einstellung geändert', [ 'Einstellung' => $settingLabels[$key] ?? $key, diff --git a/assets/css/style.css b/assets/css/style.css index a8e4ae3..156dcdc 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -5308,3 +5308,131 @@ span.reaction { cursor: default; } .filter-word-form input[type="text"] { width: auto; } .filter-word select { -webkit-appearance: none; appearance: none; flex: 0 0 auto; padding: 0.05rem 0.45rem; border-radius: 999px; background: rgba(255, 255, 255, 0.06); } .filter-word select:hover { color: var(--text); } + +/* ---- Kalender ---- */ +.calendar-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; } +.calendar-head h1 { margin-bottom: 0.2rem; } +.calendar-nav { display: flex; align-items: center; gap: 0.5rem; } +.calendar-nav .icon-button { font-size: 1.3rem; line-height: 1; text-decoration: none; } +.calendar-month { min-width: 10.5rem; text-align: center; font-size: 1.15rem; color: var(--gold); } +.calendar-legend { display: flex; gap: 0.5rem; margin: 0.9rem 0 0.7rem; } +.calendar-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; } +.calendar-chip .icon { width: 14px; height: 14px; } + +.calendar-grid { + display: grid; + grid-template-columns: repeat(7, minmax(0, 1fr)); + gap: 4px; +} +.calendar-weekday { padding: 0.3rem; text-align: center; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); text-transform: uppercase; } +.calendar-day { + display: flex; + flex-direction: column; + gap: 3px; + min-height: 6.5rem; + padding: 0.35rem; + border-radius: 8px; + border: 1px solid var(--border); + background: rgba(255, 255, 255, 0.02); + min-width: 0; +} +.calendar-day.is-outside { opacity: 0.35; } +.calendar-day.is-today { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: rgba(201, 162, 39, 0.06); } +.calendar-date { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); } +.calendar-day.is-today .calendar-date { color: var(--gold); } +.calendar-entry { + display: block; + padding: 0.1rem 0.35rem; + border-radius: 5px; + font-size: 0.74rem; + line-height: 1.35; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: var(--text); +} +a.calendar-entry:hover { text-decoration: none; filter: brightness(1.25); } +.calendar-entry.is-past { opacity: 0.55; } +.calendar-time { font-weight: 700; font-variant-numeric: tabular-nums; } +.calendar-more { font-size: 0.72rem; color: var(--text-muted); padding-left: 0.35rem; } +.calendar-dots { display: none; gap: 3px; margin-top: auto; } +.calendar-dots i { width: 7px; height: 7px; border-radius: 50%; } + +/* Farben: Raid gold, Event blau */ +.calendar-raid { background: rgba(201, 162, 39, 0.2); border-left: 3px solid var(--gold); } +.calendar-event { background: rgba(88, 101, 242, 0.2); border-left: 3px solid #5865f2; } +.calendar-chip.calendar-raid, .calendar-chip.calendar-event { border-left: none; } +.calendar-dots i.calendar-raid { background: var(--gold); border: 0; } +.calendar-dots i.calendar-event { background: #5865f2; border: 0; } + +.calendar-agenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; } +.calendar-agenda-day { display: flex; gap: 1rem; align-items: flex-start; } +.calendar-agenda-day.is-past { opacity: 0.55; } +.calendar-agenda-date { flex: 0 0 4.5rem; display: flex; flex-direction: column; line-height: 1.15; } +.calendar-agenda-date strong { font-size: 1.35rem; } +.calendar-agenda-date span { font-size: 0.78rem; color: var(--text-muted); } +.calendar-agenda-day.is-today .calendar-agenda-date { color: var(--gold); } +.calendar-agenda-entries { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; } +.calendar-agenda-entry { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.25rem 0.8rem; + padding: 0.45rem 0.75rem; + border-radius: 8px; + color: var(--text); + font-size: 0.9rem; +} +a.calendar-agenda-entry:hover { text-decoration: none; filter: brightness(1.2); } +.calendar-agenda-title { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; } +.calendar-agenda-title .icon { width: 15px; height: 15px; } +.calendar-agenda-entry .text-muted { font-size: 0.8rem; } +.calendar-public-toggle { margin-top: 1.2rem; } +.navbar-calendar .icon { width: 16px; height: 16px; } + +@media (max-width: 700px) { + .calendar-day { min-height: 3.2rem; align-items: center; padding: 0.3rem 0.1rem; } + .calendar-entry, .calendar-more { display: none; } + .calendar-dots { display: flex; } + .calendar-month { min-width: 8rem; } + .calendar-agenda-date { flex-basis: 3.6rem; } +} +.calendar-day { position: relative; } +.calendar-day-link { display: none; } +.calendar-agenda-day { scroll-margin-top: 5rem; } +.calendar-agenda-day:target .calendar-agenda-entries { animation: calendar-flash 1.2s ease; } +@keyframes calendar-flash { 30% { filter: brightness(1.6); } } +@media (max-width: 700px) { .calendar-day-link { display: block; position: absolute; inset: 0; } } + +/* Kalender: Termine der Mitglieder (gruen) */ +.calendar-member { background: rgba(59, 165, 93, 0.18); border-left: 3px solid #3ba55d; } +.calendar-chip.calendar-member { border-left: none; } +.calendar-dots i.calendar-member { background: #3ba55d; border: 0; } +.calendar-new { margin: 0.9rem 0 0.2rem; } +.calendar-new > summary { list-style: none; display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; } +.calendar-new > summary::-webkit-details-marker { display: none; } +.calendar-new[open] > summary { opacity: 0.7; } +.calendar-form { margin-top: 0.8rem; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: rgba(0, 0, 0, 0.2); max-width: 640px; } +.calendar-form label { display: flex; flex-direction: column; gap: 0.3rem; } +.calendar-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; } +.calendar-form input[type="datetime-local"] { color-scheme: dark; } +@media (max-width: 600px) { .calendar-form-row { grid-template-columns: 1fr; } } + +.calendar-member-entry { padding: 0.6rem 0.8rem; border-radius: 10px; display: flex; flex-direction: column; gap: 0.45rem; scroll-margin-top: 5rem; } +.calendar-member-entry:target { box-shadow: 0 0 0 2px #3ba55d; } +.calendar-member-entry.is-pending { border-left-style: dashed; opacity: 0.85; } +.calendar-member-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; } +.calendar-member-title { font-size: 1rem; } +.calendar-member-author { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: auto; font-size: 0.85rem; } +.calendar-member-description { margin: 0; font-size: 0.9rem; overflow-wrap: anywhere; } +.calendar-member-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; } +.calendar-participants { display: flex; align-items: center; } +.calendar-participants .avatar, .calendar-participants .avatar-wrap { margin-right: -6px; border: 2px solid #232323; border-radius: 50%; } +.calendar-participants .text-muted { margin-left: 0.8rem; font-size: 0.82rem; } +.calendar-member-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; } +.calendar-edit { position: relative; } +.calendar-edit > summary { list-style: none; cursor: pointer; } +.calendar-edit > summary::-webkit-details-marker { display: none; } +.calendar-edit[open] .calendar-form { position: absolute; right: 0; z-index: 15; width: min(560px, 90vw); background: #232323; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); } +.moderation-calendar-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 8px; background: rgba(59, 165, 93, 0.15); color: #57d68d; flex-shrink: 0; } +.moderation-calendar-icon .icon { width: 28px; height: 28px; } diff --git a/calendar.php b/calendar.php new file mode 100644 index 0000000..a5803e9 --- /dev/null +++ b/calendar.php @@ -0,0 +1,312 @@ + 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']; +$monthLabel = $monthNames[(int) date('n', $monthStart)] . ' ' . date('Y', $monthStart); + +// ---- Termine sammeln: [timestamp, type, title, detail, url] ---- +$entries = []; +$errors = []; +if ($showRaids) { + try { + foreach (fetch_raids('all') as $raid) { + $time = (int) ($raid['timestamp'] ?? 0); + if ($time < $monthStart || $time >= $monthEnd) { + continue; + } + $signups = is_array($raid['signups'] ?? null) ? count($raid['signups']) : 0; + $max = (int) ($raid['max_slots'] ?? 0); + $archived = !empty($raid['archived']); + $entries[] = [ + 'time' => $time, + 'type' => 'raid', + 'title' => (string) ($raid['title'] ?? 'Raid'), + 'detail' => $loggedIn ? $signups . ($max > 0 ? ' / ' . $max : '') . ' angemeldet' : '', + 'url' => $loggedIn ? '/raids.php' . ($archived ? '?status=archived' : '') . '#raid-' . (int) $raid['raid_id'] : null, + 'past' => $time < time(), + ]; + } + } catch (Throwable $e) { + $errors[] = 'Raids konnten nicht geladen werden.'; + } +} +if ($showEvents) { + try { + foreach (fetch_events() as $event) { + $next = (int) ($event['next_run'] ?? 0); + $interval = (int) ($event['interval_seconds'] ?? 0); + if ($next <= 0) { + continue; + } + // Wiederkehrend: vom naechsten Termin an im Intervall (hoechstens 200 im Monat) + $times = []; + if ($interval > 0) { + $first = $next; + if ($first < $monthStart) { + $first += (int) ceil(($monthStart - $first) / $interval) * $interval; + } + for ($t = $first; $t < $monthEnd && count($times) < 200; $t += $interval) { + $times[] = $t; + } + } elseif ($next >= $monthStart && $next < $monthEnd) { + $times[] = $next; + } + $channel = (string) ($event['channel_name'] ?? ''); + foreach ($times as $time) { + $entries[] = [ + 'time' => $time, + 'type' => 'event', + 'title' => (string) ($event['name'] ?? 'Event'), + 'detail' => $loggedIn ? trim(($interval > 0 ? event_interval_label($interval) : 'einmalig') . ($channel !== '' ? ' · #' . $channel : '')) : '', + 'url' => $loggedIn ? '/events.php' : null, + 'past' => $time < time(), + ]; + } + } + } catch (Throwable $e) { + $errors[] = 'Events konnten nicht geladen werden.'; + } +} +// ---- Termine der Mitglieder ---- +if ($showMember) { + try { + // Noch nicht freigegebene sehen nur der Verfasser und die Moderation + $stmt = db()->prepare( + "SELECT e.*, COALESCE(NULLIF(u.display_name, ''), u.username) AS author, u.avatar_filename, u.username, u.display_name + FROM calendar_entries e JOIN users u ON u.id = e.user_id + WHERE e.starts_at >= ? AND e.starts_at < ? AND u.status = 'active' + AND (e.status = 'visible' OR e.user_id = ? OR ?) + ORDER BY e.starts_at" + ); + $stmt->execute([date('Y-m-d H:i:s', $monthStart), date('Y-m-d H:i:s', $monthEnd), $myId, $isModerator ? 1 : 0]); + $memberEntries = $stmt->fetchAll(); + + $participants = []; + if ($loggedIn && $memberEntries) { + $ids = array_map('intval', array_column($memberEntries, 'id')); + $placeholders = implode(',', array_fill(0, count($ids), '?')); + $p = db()->prepare( + "SELECT p.entry_id, u.id, u.username, u.display_name, u.avatar_filename + FROM calendar_participants p JOIN users u ON u.id = p.user_id + WHERE p.entry_id IN ($placeholders) AND u.status = 'active' ORDER BY p.created_at" + ); + $p->execute($ids); + foreach ($p->fetchAll() as $row) { + $participants[(int) $row['entry_id']][] = $row; + } + } + $reportedEntries = $loggedIn ? moderation_my_reports('calendar', array_map('intval', array_column($memberEntries, 'id'))) : []; + + foreach ($memberEntries as $row) { + $id = (int) $row['id']; + $time = strtotime((string) $row['starts_at']); + $people = $participants[$id] ?? []; + $entries[] = [ + 'time' => $time, + 'type' => 'member', + 'title' => (string) $row['title'], + 'detail' => $loggedIn ? 'von ' . $row['author'] . ' · ' . count($people) . ' dabei' : '', + 'url' => $loggedIn ? '#termin-' . $id : null, + 'past' => $time < time(), + 'id' => $id, + 'row' => $row, + 'people' => $people, + 'joined' => in_array($myId, array_map('intval', array_column($people, 'id')), true), + 'reported' => isset($reportedEntries[$id]), + ]; + } + } catch (PDOException $e) { + // Tabellen kommen erst mit dem naechsten Schema-Abgleich + } +} + +usort($entries, static fn (array $a, array $b): int => $a['time'] <=> $b['time']); +$byDay = []; +foreach ($entries as $entry) { + $byDay[date('Y-m-d', $entry['time'])][] = $entry; +} + +// Raster: volle Wochen von Montag bis Sonntag +$gridStart = strtotime('monday this week', $monthStart); +$gridEnd = strtotime('+1 day', strtotime('sunday this week', $monthEnd - 1)); +$weekdays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']; +$today = date('Y-m-d'); +$dayNames = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag']; + +/** Formularfelder fuer "Termin eintragen" und "Bearbeiten". */ +$entryFields = static function (?array $row): string { + $start = $row ? date('Y-m-d\TH:i', strtotime((string) $row['starts_at'])) : date('Y-m-d\T20:00', strtotime('+1 day')); + $end = $row && $row['ends_at'] ? date('Y-m-d\TH:i', strtotime((string) $row['ends_at'])) : ''; + return '' + . '
' + . '' + . '' + . '
' + . ''; +}; + +$pageTitle = 'Kalender'; +$containerWide = true; +$publicLayout = !$loggedIn; +include __DIR__ . '/includes/header.php'; +?> +
+
+
+

Kalender

+

+ der Legion im Überblick - + dieselben Termine wie im Discord, immer aktuell. +

+
+
+ ‹ + + › + + Heute + +
+
+ + +
+ + Termin eintragen +
+ + +

Du veranstaltest etwas? Trag es ein - z.B. „Mobs farmen um 20 Uhr mit Damaskar. Macht euch keine Hoffnung auf Loot.“ Andere können sich mit „Bin dabei“ anschließen.

+ +
+
+
+ + +
+ Raid + Event + Von Mitgliedern +
+ + +
Bitte später erneut versuchen.
+ + +
+ +
+ + + = $monthStart && $day < $monthEnd; + $dayEntries = $byDay[$key] ?? []; + ?> +
+ + + + < class="calendar-entry calendar-" + + title=""> + + > + + 3): ?> + + weitere + + + + + +
+ +
+
+ +
+

Termine im

+ +

In diesem Monat stehen keine Termine an.

+ +
    + $dayEntries): ?> + +
  1. +
    + + +
    +
    + + + + + + + < class="calendar-agenda-entry calendar-"> + Uhr + 'calendar', 'event' => 'bell', 'member' => 'users'][$entry['type']]) ?> + + > + +
    +
  2. + +
+ + + +
+ + + + +
+ +
+ diff --git a/calendar_action.php b/calendar_action.php new file mode 100644 index 0000000..a659296 --- /dev/null +++ b/calendar_action.php @@ -0,0 +1,163 @@ + 0 ? '#termin-' . $entryId : ''); +}; + +/** Datum aus einem datetime-local-Feld (2026-09-24T19:30), null wenn leer/ungueltig. */ +$parseTime = static function (string $value): ?string { + $time = DateTimeImmutable::createFromFormat('Y-m-d\TH:i', trim($value), new DateTimeZone('Europe/Berlin')); + return $time ? $time->format('Y-m-d H:i:s') : null; +}; + +/** Eingaben pruefen - bei Fehlern mit Meldung zurueck. @return array{0:string,1:?string,2:string,3:?string} */ +$readInput = static function () use ($parseTime, $backTo): array { + $title = trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['title'] ?? ''))); + $description = trim(str_replace("\r\n", "\n", (string) ($_POST['description'] ?? ''))); + $startsAt = $parseTime((string) ($_POST['starts_at'] ?? '')); + $endsAt = trim((string) ($_POST['ends_at'] ?? '')) !== '' ? $parseTime((string) $_POST['ends_at']) : null; + + $error = null; + if ($title === '') { + $error = 'Bitte einen Titel eingeben.'; + } elseif (mb_strlen($title) > CALENDAR_TITLE_MAX) { + $error = 'Der Titel ist zu lang (höchstens ' . CALENDAR_TITLE_MAX . ' Zeichen).'; + } elseif (mb_strlen($description) > CALENDAR_DESCRIPTION_MAX) { + $error = 'Die Beschreibung ist zu lang (höchstens ' . CALENDAR_DESCRIPTION_MAX . ' Zeichen).'; + } elseif ($startsAt === null) { + $error = 'Bitte Datum und Uhrzeit angeben.'; + } elseif (strtotime($startsAt) < strtotime('-1 day') || strtotime($startsAt) > strtotime('+1 year')) { + $error = 'Der Termin muss zwischen heute und in einem Jahr liegen.'; + } elseif (trim((string) ($_POST['ends_at'] ?? '')) !== '' && ($endsAt === null || $endsAt <= $startsAt)) { + $error = 'Das Ende muss nach dem Beginn liegen.'; + } elseif ($endsAt !== null && strtotime($endsAt) - strtotime($startsAt) > 7 * 86400) { + $error = 'Ein Termin darf höchstens eine Woche dauern.'; + } + if ($error !== null) { + set_flash('error', $error); + redirect($backTo($startsAt)); + } + return [$title, $description !== '' ? $description : null, (string) $startsAt, $endsAt]; +}; + +/** Termin laden (oder zurueck zum Kalender). */ +$loadEntry = static function (int $id) use ($pdo, $backTo): array { + $stmt = $pdo->prepare('SELECT * FROM calendar_entries WHERE id = ?'); + $stmt->execute([$id]); + $entry = $stmt->fetch(); + if (!$entry) { + set_flash('error', 'Diesen Termin gibt es nicht (mehr).'); + redirect($backTo(null)); + } + return $entry; +}; + +switch ($action) { + case 'create': + [$title, $description, $startsAt, $endsAt] = $readInput(); + $text = $title . "\n" . (string) $description; + if (moderation_blocks($text, 'Kalender-Termin')) { + set_flash('error', 'Der Termin enthält ein Wort, das hier nicht erlaubt ist.'); + redirect($backTo($startsAt)); + } + if (!security_throttle('calendar')) { + set_flash('error', 'Du hast in der letzten Stunde schon viele Termine eingetragen. Bitte warte etwas.'); + redirect($backTo($startsAt)); + } + [$status, $note] = moderation_initial_status('calendar', $text); + $pdo->prepare( + 'INSERT INTO calendar_entries (user_id, title, description, starts_at, ends_at, status, moderation_note) VALUES (?, ?, ?, ?, ?, ?, ?)' + )->execute([$myId, $title, $description, $startsAt, $endsAt, $status, $note]); + $entryId = (int) $pdo->lastInsertId(); + // Wer einlaedt, ist natuerlich dabei + $pdo->prepare('INSERT INTO calendar_participants (entry_id, user_id) VALUES (?, ?)')->execute([$entryId, $myId]); + set_flash('success', $status === 'pending' + ? 'Termin eingetragen. Für alle sichtbar nach einer kurzen Freigabe durch die Moderation (' . mb_strtolower((string) $note) . ').' + : 'Termin eingetragen.'); + redirect($backTo($startsAt, $entryId)); + + 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.'); + redirect($backTo($entry['starts_at'], (int) $entry['id'])); + } + [$title, $description, $startsAt, $endsAt] = $readInput(); + $text = $title . "\n" . (string) $description; + if (moderation_blocks($text, 'Kalender-Termin')) { + 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) + [$status, $note] = moderation_initial_status('calendar', $text); + if ($entry['status'] === 'pending') { + [$status, $note] = ['pending', $entry['moderation_note']]; + } + $pdo->prepare( + 'UPDATE calendar_entries SET title = ?, description = ?, starts_at = ?, ends_at = ?, status = ?, moderation_note = ?, updated_at = ? WHERE id = ?' + )->execute([$title, $description, $startsAt, $endsAt, $status, $note, date('Y-m-d H:i:s'), (int) $entry['id']]); + set_flash('success', $status === 'pending' ? 'Termin gespeichert - für alle sichtbar nach der Freigabe.' : 'Termin gespeichert.'); + redirect($backTo($startsAt, (int) $entry['id'])); + + case 'delete': + $entry = $loadEntry((int) ($_POST['id'] ?? 0)); + $isAuthor = (int) $entry['user_id'] === $myId; + if (!$isAuthor && !moderation_can()) { + set_flash('error', 'Diesen Termin darfst du nicht löschen.'); + redirect($backTo($entry['starts_at'], (int) $entry['id'])); + } + $pdo->prepare('DELETE FROM calendar_entries WHERE id = ?')->execute([(int) $entry['id']]); + moderation_clear_reports('calendar', (int) $entry['id']); + if (!$isAuthor) { + admin_log('🗓️ Kalender-Termin gelöscht (Moderation)', [ + 'Von' => admin_log_user((int) $entry['user_id']), + 'Termin' => $entry['title'] . ' – ' . date('d.m.Y H:i', strtotime((string) $entry['starts_at'])) . ' Uhr', + ], 'warning', 'events'); + } + set_flash('success', 'Termin gelöscht.'); + redirect($backTo($entry['starts_at'])); + + case 'join': + case 'leave': + $entry = $loadEntry((int) ($_POST['id'] ?? 0)); + $canSee = $entry['status'] === 'visible' || (int) $entry['user_id'] === $myId || moderation_can(); + if (!$canSee) { + set_flash('error', 'Diesen Termin gibt es nicht (mehr).'); + redirect($backTo(null)); + } + if ($action === 'join') { + try { + $pdo->prepare('INSERT INTO calendar_participants (entry_id, user_id) VALUES (?, ?)')->execute([(int) $entry['id'], $myId]); + } catch (PDOException $e) { + // schon dabei + } + } else { + $pdo->prepare('DELETE FROM calendar_participants WHERE entry_id = ? AND user_id = ?')->execute([(int) $entry['id'], $myId]); + } + redirect($backTo($entry['starts_at'], (int) $entry['id'])); + + default: + set_flash('error', 'Unbekannte Aktion.'); + redirect('/calendar.php'); +} diff --git a/includes/calendar_entry.php b/includes/calendar_entry.php new file mode 100644 index 0000000..ec28c0c --- /dev/null +++ b/includes/calendar_entry.php @@ -0,0 +1,90 @@ +' + . csrf_field() . '' + . ''; +}; +?> +
+
+ Uhr + + + Wartet auf Freigabe + + + $row['user_id'], 'username' => $row['username'], 'display_name' => $row['display_name'], 'avatar_filename' => $row['avatar_filename']], 22) ?> + + +
+ +

+ +
+
+ + + + dabei +
+
+ + + + +
+ + + + +
+ + +
+ +
+ + + + +
+
+
+ + +
+ + + +
+ + + + Gemeldet + +
+ + + + +
+ + +
+
+
diff --git a/includes/header.php b/includes/header.php index 1db6090..467946f 100644 --- a/includes/header.php +++ b/includes/header.php @@ -63,6 +63,7 @@ $isProfileActive = $currentScript === 'profile.php'; $isRaidsActive = $currentScript === 'raids.php'; $isPremadesActive = $currentScript === 'premades.php'; $isEventsActive = $currentScript === 'events.php'; +$isCalendarActive = $currentScript === 'calendar.php'; $isMapActive = $currentScript === 'map.php'; $isWarehouseActive = $currentScript === 'warehouse.php'; $isContributionsActive = in_array($currentScript, ['contributions.php', 'contributions_award.php'], true); @@ -83,6 +84,7 @@ $pageBackgrounds = [ 'raids.php' => 'bg-raids', 'premades.php' => 'bg-premades', 'events.php' => 'bg-events', + 'calendar.php' => 'bg-events', 'map.php' => 'bg-map', 'warehouse.php' => 'bg-warehouse', 'contributions.php' => 'bg-contributions', @@ -212,6 +214,11 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($ Premades + + + Kalender + + Events @@ -300,6 +307,9 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($