'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; } // Wie der Kader in der Raid-Nachricht: in einer Gruppe, ohne Abgemeldete und offene Premade-Einladungen $signups = count(array_filter((array) ($raid['signups'] ?? []), static fn ($s): bool => (int) ($s['group'] ?? 0) >= 1 && ($s['class'] ?? '') !== 'Ausstehend')); $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, interne Termine nur die // Leitung (auch im oeffentlichen Kalender nicht). $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 ?) AND (e.audience <> 'internal' OR ? OR e.user_id = ?) 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, $canLead ? 1 : 0, $myId]); $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]), 'audience' => (string) ($row['audience'] ?? 'all'), ]; } } 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']; /** Treffpunkt auf der Karte: verstecktes Feld + Knopf, der die Karte zum Auswaehlen oeffnet (assets/js/calendar.js). */ $locationField = static function (?array $row): string { $link = !empty($row['location_path']) ? map_link_parse((string) $row['location_path']) : null; return '
' . 'Treffpunkt auf der Karte (optional)' . '' . '
' . '' . ($link ? '📍 ' . e(map_link_label($link)) : 'Kein Ort gewählt') . '' . '' . '' . '
'; }; /** Nur fuer die Leitung: fuer wen der Termin ist (includes/calendar_audience.php). */ $audienceField = static function (?array $row): string { $current = (string) ($row['audience'] ?? 'all'); $options = ''; foreach (CALENDAR_AUDIENCES as $value => $label) { $options .= ''; } return ''; }; /** Formularfelder fuer "Termin eintragen" und "Bearbeiten". */ $entryFields = static function (?array $row) use ($locationField, $audienceField, $canLead): 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 '' . '
' . '' . '' . '
' . '' . $locationField($row) . ($canLead ? $audienceField($row) : ''); }; $pageTitle = 'Kalender'; $containerWide = true; $publicLayout = !$loggedIn; include __DIR__ . '/includes/header.php'; ?>

Kalender

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

+ 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 In deinem Kalender abonnieren
Bitte später erneut versuchen.
= $monthStart && $day < $monthEnd; $dayEntries = $byDay[$key] ?? []; ?>
< class="calendar-entry calendar-" title=""> >

Termine im

In diesem Monat stehen keine Termine an.

    $dayEntries): ?>
  1. < class="calendar-agenda-entry calendar-"> Uhr 'calendar', 'event' => 'bell', 'member' => 'users'][$entry['type']]) ?> >