Calendar: raids and events as a monthly view plus member entries with "I'm in"
- calendar.php: raids and events live from the bot API (no duplicate data), recurring events projected forward, agenda list, mobile view with dots - Optionally public (without login, titles and times only), linked on the homepage - Members add their own entries (calendar_entries), participants via "I'm in", same protections as comments (filter, approval, report button, rate limit) - Moderation also covers calendar entries Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
6d8747c9e4
commit
0f097dda87
16 changed files with 845 additions and 23 deletions
19
README.md
19
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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
312
calendar.php
Normal file
312
calendar.php
Normal file
|
|
@ -0,0 +1,312 @@
|
|||
<?php
|
||||
/**
|
||||
* Terminkalender: Raids und Event-Erinnerungen im Monatsueberblick - live aus der Bot-API
|
||||
* (dieselben Daten wie auf den Seiten Raids und Events, keine doppelte Datenhaltung).
|
||||
* Wiederkehrende Events werden ab ihrem naechsten Termin im Intervall fortgeschrieben.
|
||||
* Dazu kommen Termine, die Mitglieder selbst eintragen (calendar_entries, calendar_action.php).
|
||||
*
|
||||
* Mit der Einstellung "calendar_public" ist der Kalender auch ohne Anmeldung sichtbar - dann nur
|
||||
* Titel und Uhrzeit, ohne Links, Anmeldungen oder Kanaele.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/raids_api.php';
|
||||
require_once __DIR__ . '/includes/events_api.php';
|
||||
require_once __DIR__ . '/includes/member_profile.php'; // gallery_comment_html() fuer Beschreibungen
|
||||
|
||||
$me = current_user();
|
||||
$loggedIn = $me !== null && $me['status'] === 'active';
|
||||
$isPublic = setting_get('calendar_public') === '1';
|
||||
if (!$loggedIn && !$isPublic) {
|
||||
require_login();
|
||||
}
|
||||
$showRaids = !$loggedIn || user_has_permission('raids.view');
|
||||
$showEvents = !$loggedIn || user_has_permission('events.view');
|
||||
$showMember = !$loggedIn || user_has_permission('members.view');
|
||||
if (!$showRaids && !$showEvents && !$showMember) {
|
||||
show_not_found();
|
||||
}
|
||||
$canCreate = $loggedIn && user_has_permission('members.view');
|
||||
$isModerator = $loggedIn && moderation_can();
|
||||
$myId = $loggedIn ? (int) $me['id'] : 0;
|
||||
$canTogglePublic = $loggedIn && user_has_permission('events.manage');
|
||||
|
||||
// Angezeigter Monat (?month=2026-09), Standard: aktueller Monat
|
||||
$monthParam = (string) ($_GET['month'] ?? '');
|
||||
$monthStart = preg_match('/^\d{4}-\d{2}$/', $monthParam) ? strtotime($monthParam . '-01 00:00:00') : false;
|
||||
if ($monthStart === false) {
|
||||
$monthStart = strtotime(date('Y-m-01 00:00:00'));
|
||||
}
|
||||
$monthEnd = strtotime('+1 month', $monthStart);
|
||||
$prevMonth = date('Y-m', strtotime('-1 month', $monthStart));
|
||||
$nextMonth = date('Y-m', $monthEnd);
|
||||
$monthNames = [1 => '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 '<label>Titel<input type="text" name="title" maxlength="100" required placeholder="z.B. Mobs farmen mit Damaskar" value="' . e((string) ($row['title'] ?? '')) . '"></label>'
|
||||
. '<div class="calendar-form-row">'
|
||||
. '<label>Beginn<input type="datetime-local" name="starts_at" required value="' . e($start) . '"></label>'
|
||||
. '<label><span>Ende <span class="text-muted">(optional)</span></span><input type="datetime-local" name="ends_at" value="' . e($end) . '"></label>'
|
||||
. '</div>'
|
||||
. '<label><span>Beschreibung <span class="text-muted">(optional)</span></span><textarea name="description" rows="3" maxlength="1000" placeholder="Worum geht es, wo trefft ihr euch, was braucht man?">'
|
||||
. e((string) ($row['description'] ?? '')) . '</textarea></label>';
|
||||
};
|
||||
|
||||
$pageTitle = 'Kalender';
|
||||
$containerWide = true;
|
||||
$publicLayout = !$loggedIn;
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel calendar-panel">
|
||||
<div class="calendar-head">
|
||||
<div>
|
||||
<h1>Kalender</h1>
|
||||
<p class="text-muted">
|
||||
<?= $showRaids && $showEvents ? 'Raids und Events' : ($showRaids ? 'Raids' : 'Events') ?> der Legion im Überblick -
|
||||
dieselben Termine wie im Discord, immer aktuell<?= $showMember ? ', dazu Termine, die Mitglieder selbst eintragen' : '' ?>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="calendar-nav">
|
||||
<a class="icon-button" href="/calendar.php?month=<?= e($prevMonth) ?>" title="Voriger Monat" aria-label="Voriger Monat">‹</a>
|
||||
<strong class="calendar-month"><?= e($monthLabel) ?></strong>
|
||||
<a class="icon-button" href="/calendar.php?month=<?= e($nextMonth) ?>" title="Nächster Monat" aria-label="Nächster Monat">›</a>
|
||||
<?php if (date('Y-m', $monthStart) !== date('Y-m')): ?>
|
||||
<a class="button button-secondary button-small" href="/calendar.php">Heute</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($canCreate): ?>
|
||||
<details class="calendar-new">
|
||||
<summary class="button button-small"><?= icon('calendar') ?> + Termin eintragen</summary>
|
||||
<form method="post" action="/calendar_action.php" class="calendar-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="create">
|
||||
<p class="text-muted">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.</p>
|
||||
<?= $entryFields(null) ?>
|
||||
<div class="actions"><button type="submit" class="button-success">Eintragen</button></div>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="calendar-legend">
|
||||
<?php if ($showRaids): ?><span class="calendar-chip calendar-raid"><?= icon('calendar') ?> Raid</span><?php endif; ?>
|
||||
<?php if ($showEvents): ?><span class="calendar-chip calendar-event"><?= icon('bell') ?> Event</span><?php endif; ?>
|
||||
<?php if ($showMember): ?><span class="calendar-chip calendar-member"><?= icon('users') ?> Von Mitgliedern</span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<div class="alert alert-error"><?= e($error) ?> Bitte später erneut versuchen.</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div class="calendar-grid" role="grid" aria-label="<?= e($monthLabel) ?>">
|
||||
<?php foreach ($weekdays as $weekday): ?>
|
||||
<div class="calendar-weekday" role="columnheader"><?= $weekday ?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php for ($day = $gridStart; $day < $gridEnd; $day = strtotime('+1 day', $day)): ?>
|
||||
<?php
|
||||
$key = date('Y-m-d', $day);
|
||||
$inMonth = $day >= $monthStart && $day < $monthEnd;
|
||||
$dayEntries = $byDay[$key] ?? [];
|
||||
?>
|
||||
<div class="calendar-day<?= $inMonth ? '' : ' is-outside' ?><?= $key === $today ? ' is-today' : '' ?><?= $dayEntries ? ' has-entries' : '' ?>" role="gridcell">
|
||||
<span class="calendar-date"><?= (int) date('j', $day) ?></span>
|
||||
<?php foreach (array_slice($dayEntries, 0, 3) as $entry): ?>
|
||||
<?php $tag = $entry['url'] ? 'a' : 'span'; ?>
|
||||
<<?= $tag ?> class="calendar-entry calendar-<?= $entry['type'] ?><?= $entry['past'] ? ' is-past' : '' ?>"
|
||||
<?= $entry['url'] ? 'href="' . e($entry['url']) . '"' : '' ?>
|
||||
title="<?= e(date('H:i', $entry['time']) . ' Uhr · ' . $entry['title'] . ($entry['detail'] !== '' ? ' · ' . $entry['detail'] : '')) ?>">
|
||||
<span class="calendar-time"><?= date('H:i', $entry['time']) ?></span> <?= e($entry['title']) ?>
|
||||
</<?= $tag ?>>
|
||||
<?php endforeach; ?>
|
||||
<?php if (count($dayEntries) > 3): ?>
|
||||
<span class="calendar-more">+<?= count($dayEntries) - 3 ?> weitere</span>
|
||||
<?php endif; ?>
|
||||
<?php if ($dayEntries): ?>
|
||||
<a class="calendar-day-link" href="#tag-<?= e($key) ?>" aria-label="Termine am <?= e(date('d.m.', $day)) ?>"></a>
|
||||
<span class="calendar-dots" aria-hidden="true">
|
||||
<?php foreach (array_slice($dayEntries, 0, 4) as $entry): ?><i class="calendar-<?= $entry['type'] ?>"></i><?php endforeach; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h2>Termine im <?= e($monthLabel) ?> <span class="chip-count"><?= count($entries) ?></span></h2>
|
||||
<?php if (!$entries): ?>
|
||||
<p class="text-muted">In diesem Monat stehen keine Termine an.</p>
|
||||
<?php else: ?>
|
||||
<ol class="calendar-agenda">
|
||||
<?php foreach ($byDay as $key => $dayEntries): ?>
|
||||
<?php $dayTime = strtotime($key); ?>
|
||||
<li id="tag-<?= e($key) ?>" class="calendar-agenda-day<?= $key === $today ? ' is-today' : '' ?><?= $key < $today ? ' is-past' : '' ?>">
|
||||
<div class="calendar-agenda-date">
|
||||
<strong><?= date('d.', $dayTime) ?></strong>
|
||||
<span><?= $key === $today ? 'Heute' : $dayNames[(int) date('w', $dayTime)] ?></span>
|
||||
</div>
|
||||
<div class="calendar-agenda-entries">
|
||||
<?php foreach ($dayEntries as $entry): ?>
|
||||
<?php if ($entry['type'] === 'member' && $loggedIn): ?>
|
||||
<?php include __DIR__ . '/includes/calendar_entry.php'; ?>
|
||||
<?php continue; ?>
|
||||
<?php endif; ?>
|
||||
<?php $tag = $entry['url'] ? 'a' : 'div'; ?>
|
||||
<<?= $tag ?> class="calendar-agenda-entry calendar-<?= $entry['type'] ?>"<?= $entry['url'] ? ' href="' . e($entry['url']) . '"' : '' ?>>
|
||||
<span class="calendar-time"><?= date('H:i', $entry['time']) ?> Uhr</span>
|
||||
<span class="calendar-agenda-title"><?= icon(['raid' => 'calendar', 'event' => 'bell', 'member' => 'users'][$entry['type']]) ?> <?= e($entry['title']) ?></span>
|
||||
<?php if ($entry['detail'] !== ''): ?><span class="text-muted"><?= e($entry['detail']) ?></span><?php endif; ?>
|
||||
</<?= $tag ?>>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canTogglePublic): ?>
|
||||
<form class="settings-toggle calendar-public-toggle" method="post" action="/admin/settings_action.php">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="setting" value="calendar_public">
|
||||
<label>
|
||||
<input type="checkbox" name="value" value="1" <?= $isPublic ? 'checked' : '' ?> onchange="this.form.submit()">
|
||||
<span>Kalender öffentlich zeigen - auch ohne Anmeldung sichtbar (nur Titel und Uhrzeit), mit Link auf der Startseite</span>
|
||||
</label>
|
||||
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
163
calendar_action.php
Normal file
163
calendar_action.php
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
/**
|
||||
* Termine der Mitglieder im Kalender: eintragen, bearbeiten, loeschen, "Bin dabei".
|
||||
* Es gelten dieselben Schutzregeln wie bei Kommentaren (Schimpfwortfilter, Links und neue
|
||||
* Mitglieder erst nach Freigabe, Tempolimit).
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_permission('members.view');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/calendar.php');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
const CALENDAR_TITLE_MAX = 100;
|
||||
const CALENDAR_DESCRIPTION_MAX = 1000;
|
||||
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
$me = current_user();
|
||||
$myId = (int) $me['id'];
|
||||
$pdo = db();
|
||||
|
||||
/** Zurueck in den Monat des Termins, direkt zum Eintrag. */
|
||||
$backTo = static function (?string $startsAt, int $entryId = 0): string {
|
||||
return '/calendar.php' . ($startsAt ? '?month=' . date('Y-m', strtotime($startsAt)) : '') . ($entryId > 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');
|
||||
}
|
||||
90
includes/calendar_entry.php
Normal file
90
includes/calendar_entry.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/**
|
||||
* Ein Termin eines Mitglieds in der Terminliste des Kalenders (eingebunden in calendar.php).
|
||||
*
|
||||
* @var array $entry mit row, people, joined, reported
|
||||
* @var bool $isModerator
|
||||
* @var int $myId
|
||||
* @var callable $entryFields
|
||||
*/
|
||||
$row = $entry['row'];
|
||||
$entryId = (int) $row['id'];
|
||||
$isAuthor = (int) $row['user_id'] === $myId;
|
||||
$ends = $row['ends_at'] ? strtotime((string) $row['ends_at']) : null;
|
||||
$actionForm = static function (string $action, string $label, string $class, string $confirm = '') use ($entryId): string {
|
||||
return '<form class="inline-form" method="post" action="/calendar_action.php"' . ($confirm !== '' ? ' onsubmit="return confirm("' . e($confirm) . '");"' : '') . '>'
|
||||
. csrf_field() . '<input type="hidden" name="action" value="' . $action . '"><input type="hidden" name="id" value="' . $entryId . '">'
|
||||
. '<button type="submit" class="button-small ' . $class . '">' . $label . '</button></form>';
|
||||
};
|
||||
?>
|
||||
<div class="calendar-member-entry calendar-member<?= $row['status'] === 'pending' ? ' is-pending' : '' ?>" id="termin-<?= $entryId ?>">
|
||||
<div class="calendar-member-head">
|
||||
<span class="calendar-time"><?= date('H:i', $entry['time']) ?><?= $ends ? '–' . (date('Y-m-d', $ends) === date('Y-m-d', $entry['time']) ? date('H:i', $ends) : date('d.m. H:i', $ends)) : '' ?> Uhr</span>
|
||||
<strong class="calendar-member-title"><?= e((string) $row['title']) ?></strong>
|
||||
<?php if ($row['status'] === 'pending'): ?>
|
||||
<span class="pending-badge-inline" title="<?= e((string) $row['moderation_note']) ?>">Wartet auf Freigabe</span>
|
||||
<?php endif; ?>
|
||||
<span class="calendar-member-author">
|
||||
<?= avatar_html(['id' => $row['user_id'], 'username' => $row['username'], 'display_name' => $row['display_name'], 'avatar_filename' => $row['avatar_filename']], 22) ?>
|
||||
<a href="/member.php?id=<?= (int) $row['user_id'] ?>"><?= e((string) $row['author']) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
<?php if (!empty($row['description'])): ?>
|
||||
<p class="calendar-member-description"><?= gallery_comment_html((string) $row['description']) ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="calendar-member-foot">
|
||||
<div class="calendar-participants" title="<?= e(implode(', ', array_map(static fn ($p) => $p['display_name'] !== '' ? $p['display_name'] : $p['username'], $entry['people']))) ?>">
|
||||
<?php foreach (array_slice($entry['people'], 0, 8) as $person): ?>
|
||||
<?= avatar_html($person, 24) ?>
|
||||
<?php endforeach; ?>
|
||||
<span class="text-muted"><?= count($entry['people']) ?> dabei</span>
|
||||
</div>
|
||||
<div class="calendar-member-actions">
|
||||
<?php if (!$entry['past']): ?>
|
||||
<?= $entry['joined']
|
||||
? $actionForm('leave', 'Absagen', 'button-secondary')
|
||||
: $actionForm('join', '✋ Bin dabei', 'button-success') ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($isModerator && $row['status'] === 'pending'): ?>
|
||||
<form class="inline-form" method="post" action="/moderation_action.php">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="approve"><input type="hidden" name="type" value="calendar">
|
||||
<input type="hidden" name="id" value="<?= $entryId ?>"><input type="hidden" name="back" value="calendar">
|
||||
<button type="submit" class="button-small button-success">Freigeben</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php if ($isAuthor): ?>
|
||||
<details class="calendar-edit">
|
||||
<summary class="icon-button" title="Bearbeiten" aria-label="Bearbeiten"><?= icon('edit') ?></summary>
|
||||
<form method="post" action="/calendar_action.php" class="calendar-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="update">
|
||||
<input type="hidden" name="id" value="<?= $entryId ?>">
|
||||
<?= $entryFields($row) ?>
|
||||
<div class="actions"><button type="submit">Speichern</button></div>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
<?php if ($isAuthor || $isModerator): ?>
|
||||
<form class="inline-form" method="post" action="/calendar_action.php" onsubmit="return confirm('Diesen Termin löschen?');">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete"><input type="hidden" name="id" value="<?= $entryId ?>">
|
||||
<button type="submit" class="icon-button icon-button-danger" title="Löschen" aria-label="Löschen"><?= icon('trash') ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php if (!$isAuthor): ?>
|
||||
<?php if ($entry['reported']): ?>
|
||||
<span class="report-done" title="Du hast das gemeldet - danke!"><?= icon('flag') ?> Gemeldet</span>
|
||||
<?php else: ?>
|
||||
<form class="inline-form" method="post" action="/moderation_action.php"
|
||||
onsubmit="var r = prompt("Was ist daran nicht in Ordnung? (optional)"); if (r === null) return false; this.reason.value = r; return true;">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="report"><input type="hidden" name="type" value="calendar">
|
||||
<input type="hidden" name="id" value="<?= $entryId ?>"><input type="hidden" name="reason" value="">
|
||||
<button type="submit" class="icon-button report-button" title="Melden" aria-label="Melden"><?= icon('flag') ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -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 => ($
|
|||
<?= icon('shield') ?><span class="label">Premades</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewRaids || $canViewEvents): ?>
|
||||
<a href="/calendar.php" class="sidebar-link<?= $isCalendarActive ? ' active' : '' ?>" title="Kalender">
|
||||
<?= icon('calendar') ?><span class="label">Kalender</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewEvents): ?>
|
||||
<a href="/events.php" class="sidebar-link<?= $isEventsActive ? ' active' : '' ?>" title="Events">
|
||||
<?= icon('bell') ?><span class="label">Events</span>
|
||||
|
|
@ -300,6 +307,9 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
<header class="navbar">
|
||||
<div class="navbar-brand"><a href="/"><img src="<?= e(asset_url('/assets/images/logo-lumina-ascendens.webp')) ?>" alt="Lumina Ascendens" width="410" height="168"></a></div>
|
||||
<div class="navbar-user">
|
||||
<?php if ($publicLayout && setting_get('calendar_public') === '1'): ?>
|
||||
<a href="/calendar.php" class="navbar-discord navbar-calendar"><?= icon('calendar') ?>Termine</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($publicLayout): ?>
|
||||
<a href="<?= e(DISCORD_INVITE_URL) ?>" target="_blank" rel="noopener" class="navbar-discord" aria-label="Discord"><?= discord_logo(18) ?>Discord</a>
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@ declare(strict_types=1);
|
|||
|
||||
const MODERATION_TRUST_DAYS = 14;
|
||||
const MODERATION_REPORT_THRESHOLD = 2;
|
||||
// Inhaltsarten: Schluessel => [Tabelle, Beschriftung]
|
||||
// Inhaltsarten: Schluessel => [Tabelle, Beschriftung, Spalte mit dem Verfasser, Spalte mit dem Text]
|
||||
const MODERATION_TYPES = [
|
||||
'picture' => ['member_gallery', 'Bild'],
|
||||
'comment' => ['gallery_comments', 'Kommentar'],
|
||||
'picture' => ['member_gallery', 'Bild', 'user_id', 'caption'],
|
||||
'comment' => ['gallery_comments', 'Kommentar', 'author_id', 'body'],
|
||||
'calendar' => ['calendar_entries', 'Termin', 'user_id', 'title'],
|
||||
];
|
||||
|
||||
/** Darf das angemeldete Konto moderieren? */
|
||||
|
|
@ -83,14 +84,15 @@ function moderation_initial_status(string $type, string $text = ''): array
|
|||
/** Wartende Inhalte (fuer die Zahl in der Seitenleiste). */
|
||||
function moderation_pending_count(): int
|
||||
{
|
||||
try {
|
||||
return (int) db()->query(
|
||||
"SELECT (SELECT COUNT(*) FROM member_gallery WHERE status = 'pending')
|
||||
+ (SELECT COUNT(*) FROM gallery_comments WHERE status = 'pending')"
|
||||
)->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
return 0; // Spalten/Tabellen noch nicht angelegt
|
||||
$count = 0;
|
||||
foreach (MODERATION_TYPES as [$table]) {
|
||||
try {
|
||||
$count += (int) db()->query("SELECT COUNT(*) FROM $table WHERE status = 'pending'")->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
// Spalten/Tabellen noch nicht angelegt
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,8 +103,7 @@ function moderation_pending_count(): int
|
|||
function moderation_report(string $type, int $contentId, string $reason): string
|
||||
{
|
||||
$me = current_user();
|
||||
[$table, $label] = MODERATION_TYPES[$type];
|
||||
$owner = $type === 'picture' ? 'user_id' : 'author_id';
|
||||
[$table, $label, $owner] = MODERATION_TYPES[$type];
|
||||
$stmt = db()->prepare("SELECT id, $owner AS owner_id, status FROM $table WHERE id = ?");
|
||||
$stmt->execute([$contentId]);
|
||||
$content = $stmt->fetch();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ const CORE_PERMISSIONS = [
|
|||
['key' => 'shop.view', 'description' => 'Lumishop: Angebot ansehen und Gegenstände gegen Lumipunkte beantragen'],
|
||||
['key' => 'shop.manage', 'description' => 'Lumishop: Kategorien, Gegenstände, Bestand und Preise verwalten, Anträge bewilligen oder ablehnen'],
|
||||
['key' => 'members.view', 'description' => 'Mitgliederliste einsehen'],
|
||||
['key' => 'comments.moderate', 'description' => 'Moderation: Galeriebilder und Kommentare freigeben, ausblenden und löschen (Freigabe-Liste, Meldungen)'],
|
||||
['key' => 'comments.moderate', 'description' => 'Moderation: Galeriebilder, Kommentare und Kalender-Termine der Mitglieder freigeben, ausblenden und löschen (Freigabe-Liste, Meldungen)'],
|
||||
['key' => 'audit.view', 'description' => 'Audit-Log einsehen: alle Verwaltungsaktionen und Sicherheitsereignisse der Website'],
|
||||
['key' => 'reports.view', 'description' => 'Eingegangene Reports einsehen'],
|
||||
['key' => 'reports.manage', 'description' => 'Reports löschen/archivieren und die Punkte-Gewichtung verwalten'],
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||
const SCHEMA_VERSION = 20;
|
||||
const SCHEMA_VERSION = 21;
|
||||
|
||||
/**
|
||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||
|
|
@ -370,6 +370,34 @@ CREATE TABLE IF NOT EXISTS reactions (
|
|||
UNIQUE KEY uq_reactions (content_type, content_id, user_id, emoji),
|
||||
INDEX idx_reactions_content (content_type, content_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
'calendar_entries' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS calendar_entries (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
-- Von Mitgliedern eingetragene Termine (Raids und Events kommen aus der Bot-API)
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
title VARCHAR(100) NOT NULL,
|
||||
description TEXT NULL,
|
||||
starts_at DATETIME NOT NULL,
|
||||
ends_at DATETIME NULL,
|
||||
-- visible / pending (Moderation wie bei Kommentaren)
|
||||
status VARCHAR(10) NOT NULL DEFAULT 'visible',
|
||||
moderation_note VARCHAR(255) NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
INDEX idx_calendar_entries_start (starts_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
'calendar_participants' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS calendar_participants (
|
||||
entry_id INT UNSIGNED NOT NULL,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (entry_id, user_id),
|
||||
FOREIGN KEY (entry_id) REFERENCES calendar_entries(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
'content_reports' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS content_reports (
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ const SECURITY_LIMITS = [
|
|||
'comment' => [6, 300], // Kommentare unter Galeriebildern pro Konto
|
||||
'report' => [10, 600], // Meldungen (Melden-Knopf) pro Konto
|
||||
'reaction' => [60, 300], // Reaktionen (Emojis) pro Konto
|
||||
'calendar' => [8, 3600], // eigene Kalender-Termine pro Konto
|
||||
'bug' => [5, 3600], // Fehlermeldungen pro Konto
|
||||
'login_ip' => [15, 900], // fehlgeschlagene Logins pro IP (egal welches Konto)
|
||||
'login_pair' => [5, 900], // fehlgeschlagene Logins pro IP + Benutzername
|
||||
|
|
@ -53,7 +54,7 @@ function audit_area_for_script(string $script): string
|
|||
$prefixes = [
|
||||
'raid' => 'raids', 'premade' => 'premades', 'event' => 'events', 'tactics' => 'map', 'map' => 'map',
|
||||
'warehouse' => 'warehouse', 'contributions' => 'contributions', 'shop' => 'shop',
|
||||
'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'reaction' => 'members', 'wiki' => 'wiki', 'report' => 'reports', 'bug' => 'bugs',
|
||||
'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'reaction' => 'members', 'calendar' => 'events', 'wiki' => 'wiki', 'report' => 'reports', 'bug' => 'bugs',
|
||||
'user' => 'users', 'role' => 'users', 'discord' => 'users', 'settings' => 'users',
|
||||
];
|
||||
foreach ($prefixes as $prefix => $area) {
|
||||
|
|
@ -194,6 +195,7 @@ function security_bucket_label(string $bucket): string
|
|||
'comment' => 'Kommentare',
|
||||
'report' => 'Meldungen',
|
||||
'reaction' => 'Reaktionen',
|
||||
'calendar' => 'Kalender-Termine',
|
||||
'bug' => 'Fehlermeldungen',
|
||||
'destructive' => 'Löschungen',
|
||||
][$bucket] ?? $bucket;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ const SETTINGS_DEFAULTS = [
|
|||
'contributions_history_public' => '1',
|
||||
// Moderation: alle neuen Bilder/Kommentare warten auf Freigabe (z.B. bei einer Spam-Welle)
|
||||
'moderation_all' => '0',
|
||||
// Kalender auch ohne Anmeldung sichtbar (nur Titel und Uhrzeit)
|
||||
'calendar_public' => '0',
|
||||
];
|
||||
|
||||
// Wer eine Einstellung aendern darf und wohin es danach zurueckgeht.
|
||||
|
|
@ -19,6 +21,7 @@ const SETTINGS_ACCESS = [
|
|||
'discord_unlink_allowed' => ['users.edit', '/admin/users.php'],
|
||||
'contributions_history_public' => ['contributions.manage', '/contributions.php#verlauf'],
|
||||
'moderation_all' => ['comments.moderate', '/moderation.php'],
|
||||
'calendar_public' => ['events.manage', '/calendar.php'],
|
||||
];
|
||||
|
||||
function setting_get(string $key): string
|
||||
|
|
|
|||
|
|
@ -20,6 +20,16 @@ $pendingComments = $pdo->query(
|
|||
WHERE c.status = 'pending' ORDER BY c.created_at"
|
||||
)->fetchAll();
|
||||
|
||||
// Kalender-Termine der Mitglieder (Tabelle kommt mit Schema 21)
|
||||
$calendarSql = "SELECT e.id, e.title, e.description, e.starts_at, e.moderation_note, e.created_at, e.user_id, $name AS author
|
||||
FROM calendar_entries e JOIN users u ON u.id = e.user_id WHERE ";
|
||||
try {
|
||||
$pendingCalendar = $pdo->query($calendarSql . "e.status = 'pending' ORDER BY e.created_at")->fetchAll();
|
||||
$reportedCalendar = $pdo->query($calendarSql . "e.status = 'visible' AND EXISTS (SELECT 1 FROM content_reports r WHERE r.content_type = 'calendar' AND r.content_id = e.id)")->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
$pendingCalendar = $reportedCalendar = [];
|
||||
}
|
||||
|
||||
// Gemeldet, aber (noch) sichtbar - unter der Schwelle fuers automatische Ausblenden
|
||||
$reportedPictures = $pdo->query(
|
||||
"SELECT g.id, g.filename, g.caption, g.created_at, g.user_id, $name AS author
|
||||
|
|
@ -41,8 +51,8 @@ foreach ($pdo->query(
|
|||
$reports[$row['content_type'] . ':' . $row['content_id']][] = $row;
|
||||
}
|
||||
|
||||
$pendingTotal = count($pendingPictures) + count($pendingComments);
|
||||
$reportedTotal = count($reportedPictures) + count($reportedComments);
|
||||
$pendingTotal = count($pendingPictures) + count($pendingComments) + count($pendingCalendar);
|
||||
$reportedTotal = count($reportedPictures) + count($reportedComments) + count($reportedCalendar);
|
||||
|
||||
/** Knoepfe fuer einen Inhalt. */
|
||||
$actions = static function (string $type, int $id, array $which, string $back = ''): string {
|
||||
|
|
@ -80,6 +90,21 @@ $reportList = static function (string $type, int $id) use ($reports): string {
|
|||
return $html . '</ul>';
|
||||
};
|
||||
|
||||
/** Karte fuer einen Kalender-Termin in der Freigabe-Liste. */
|
||||
$calendarCard = static function (array $entry, array $which) use ($actions, $reportList): string {
|
||||
$when = date('d.m.Y H:i', strtotime((string) $entry['starts_at'])) . ' Uhr';
|
||||
$link = '/calendar.php?month=' . date('Y-m', strtotime((string) $entry['starts_at'])) . '#termin-' . (int) $entry['id'];
|
||||
return '<div class="moderation-card moderation-comment"><div class="moderation-calendar-icon">' . icon('calendar') . '</div>'
|
||||
. '<div class="moderation-body"><div class="moderation-meta"><span class="badge">Termin</span>'
|
||||
. '<a href="/member.php?id=' . (int) $entry['user_id'] . '"><strong>' . e((string) $entry['author']) . '</strong></a>'
|
||||
. '<a href="' . e($link) . '" class="text-muted">' . e($when) . '</a></div>'
|
||||
. '<p class="moderation-text"><strong>' . e((string) $entry['title']) . '</strong>'
|
||||
. (!empty($entry['description']) ? '<br>' . nl2br(e((string) $entry['description']), false) : '') . '</p>'
|
||||
. (!empty($entry['moderation_note']) ? '<p class="moderation-reason">Grund: ' . e((string) $entry['moderation_note']) . '</p>' : '')
|
||||
. $reportList('calendar', (int) $entry['id'])
|
||||
. $actions('calendar', (int) $entry['id'], $which) . '</div></div>';
|
||||
};
|
||||
|
||||
// Reiter: Freigabe (Standard), alle Kommentare, Schimpfwortfilter
|
||||
$tab = in_array($_GET['tab'] ?? '', ['comments', 'filter'], true) ? (string) $_GET['tab'] : 'queue';
|
||||
|
||||
|
|
@ -141,7 +166,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<div class="panel">
|
||||
<h1>Moderation</h1>
|
||||
<p class="text-muted">
|
||||
Bilder und Kommentare neuer Mitglieder (erste <?= MODERATION_TRUST_DAYS ?> Tage), Beiträge mit Links und alles,
|
||||
Bilder, Kommentare und Kalender-Termine neuer Mitglieder (erste <?= MODERATION_TRUST_DAYS ?> Tage), Beiträge mit Links und alles,
|
||||
was <?= MODERATION_REPORT_THRESHOLD ?>-mal gemeldet wurde, warten hier auf eine Entscheidung. Bis dahin sieht sie
|
||||
nur der Verfasser. Alle Entscheidungen landen im Audit-Log.
|
||||
</p>
|
||||
|
|
@ -192,6 +217,10 @@ include __DIR__ . '/includes/header.php';
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($pendingCalendar as $calendarEntry): ?>
|
||||
<?= $calendarCard($calendarEntry, ['approve', 'delete']) ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php foreach ($pendingComments as $comment): ?>
|
||||
<div class="moderation-card moderation-comment">
|
||||
<a href="/member_picture.php?id=<?= (int) $comment['gallery_id'] ?>#kommentar-<?= (int) $comment['id'] ?>" class="moderation-thumb moderation-thumb-small" title="Zum Bild">
|
||||
|
|
@ -216,6 +245,9 @@ include __DIR__ . '/includes/header.php';
|
|||
<div class="panel">
|
||||
<h2>Gemeldet, aber noch sichtbar <span class="chip-count"><?= $reportedTotal ?></span></h2>
|
||||
<p class="text-muted">Weniger als <?= MODERATION_REPORT_THRESHOLD ?> Meldungen - noch nicht automatisch ausgeblendet.</p>
|
||||
<?php foreach ($reportedCalendar as $calendarEntry): ?>
|
||||
<?= $calendarCard($calendarEntry, ['hide', 'dismiss', 'delete']) ?>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($reportedPictures as $picture): ?>
|
||||
<div class="moderation-card moderation-comment">
|
||||
<a href="/member_picture.php?id=<?= (int) $picture['id'] ?>" class="moderation-thumb moderation-thumb-small">
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ if (!isset(MODERATION_TYPES[$type]) || $id <= 0) {
|
|||
set_flash('error', 'Unbekannter Inhalt.');
|
||||
redirect('/members.php');
|
||||
}
|
||||
[$table, $label] = MODERATION_TYPES[$type];
|
||||
[$table, $label, $owner, $textColumn] = MODERATION_TYPES[$type];
|
||||
$pdo = db();
|
||||
|
||||
// Wohin danach: zur Bildseite (von dort aus gemeldet/freigegeben) oder zur Freigabe-Liste
|
||||
|
|
@ -74,6 +74,13 @@ if ($type === 'comment') {
|
|||
$back = ($action === 'report' || ($_POST['back'] ?? '') === 'picture')
|
||||
? '/member_picture.php?id=' . $pictureId . ($type === 'comment' ? '#kommentare' : '')
|
||||
: (($_POST['back'] ?? '') === 'comments' ? '/moderation.php?tab=comments' : '/moderation.php');
|
||||
// Kalender-Termine: zurueck in den Monat des Termins
|
||||
if ($type === 'calendar' && ($action === 'report' || ($_POST['back'] ?? '') === 'calendar')) {
|
||||
$stmt = $pdo->prepare('SELECT starts_at FROM calendar_entries WHERE id = ?');
|
||||
$stmt->execute([$id]);
|
||||
$startsAt = (string) $stmt->fetchColumn();
|
||||
$back = '/calendar.php' . ($startsAt !== '' ? '?month=' . date('Y-m', strtotime($startsAt)) : '') . '#termin-' . $id;
|
||||
}
|
||||
|
||||
if ($action === 'report') {
|
||||
if (!security_throttle('report')) {
|
||||
|
|
@ -90,7 +97,6 @@ if (!moderation_can()) {
|
|||
show_not_found();
|
||||
}
|
||||
|
||||
$owner = $type === 'picture' ? 'user_id' : 'author_id';
|
||||
$stmt = $pdo->prepare("SELECT * , $owner AS owner_id FROM $table WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$content = $stmt->fetch();
|
||||
|
|
@ -100,7 +106,7 @@ if (!$content) {
|
|||
}
|
||||
$logFields = [
|
||||
'Von' => admin_log_user((int) $content['owner_id']),
|
||||
$type === 'picture' ? 'Bildunterschrift' : 'Text' => mb_strimwidth((string) ($type === 'picture' ? ($content['caption'] ?? '') : $content['body']), 0, 300, '…'),
|
||||
['picture' => 'Bildunterschrift', 'comment' => 'Text', 'calendar' => 'Termin'][$type] => mb_strimwidth((string) ($content[$textColumn] ?? ''), 0, 300, '…'),
|
||||
'Grund der Prüfung' => (string) ($content['moderation_note'] ?? ''),
|
||||
];
|
||||
|
||||
|
|
@ -139,7 +145,7 @@ switch ($action) {
|
|||
}
|
||||
admin_log('🗑️ ' . $label . ' gelöscht (Moderation)', $logFields, 'warning', 'members');
|
||||
set_flash('success', $label . ' gelöscht.');
|
||||
if (str_starts_with($back, '/member_picture.php')) {
|
||||
if (str_starts_with($back, '/member_picture.php') || str_starts_with($back, '/calendar.php')) {
|
||||
$back = '/moderation.php';
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ include __DIR__ . '/includes/header.php';
|
|||
$mySignupGroupNumber = $mySignup ? (int) ($mySignup['group'] ?? 0) : null;
|
||||
$mySignupGroupLabel = $mySignupGroupNumber === 0 ? 'Ersatzbank' : ($mySignupGroupNumber ? ($groupNames[$mySignupGroupNumber - 1] ?? ('#' . $mySignupGroupNumber)) : null);
|
||||
?>
|
||||
<div class="panel raid-card<?= $isArchived ? ' panel-archived' : '' ?>"
|
||||
<div class="panel raid-card<?= $isArchived ? ' panel-archived' : '' ?>" id="raid-<?= $raidId ?>"
|
||||
data-raid-id="<?= $raidId ?>"
|
||||
data-groups='<?= e(json_encode($groupNames, JSON_UNESCAPED_UNICODE)) ?>'
|
||||
data-locked-groups='<?= e(json_encode($lockedGroups)) ?>'
|
||||
|
|
|
|||
|
|
@ -497,3 +497,30 @@ CREATE TABLE IF NOT EXISTS reactions (
|
|||
UNIQUE KEY uq_reactions (content_type, content_id, user_id, emoji),
|
||||
INDEX idx_reactions_content (content_type, content_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Termine, die Mitglieder selbst in den Kalender eintragen, und wer dabei ist
|
||||
CREATE TABLE IF NOT EXISTS calendar_entries (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
-- Von Mitgliedern eingetragene Termine (Raids und Events kommen aus der Bot-API)
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
title VARCHAR(100) NOT NULL,
|
||||
description TEXT NULL,
|
||||
starts_at DATETIME NOT NULL,
|
||||
ends_at DATETIME NULL,
|
||||
-- visible / pending (Moderation wie bei Kommentaren)
|
||||
status VARCHAR(10) NOT NULL DEFAULT 'visible',
|
||||
moderation_note VARCHAR(255) NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
INDEX idx_calendar_entries_start (starts_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS calendar_participants (
|
||||
entry_id INT UNSIGNED NOT NULL,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (entry_id, user_id),
|
||||
FOREIGN KEY (entry_id) REFERENCES calendar_entries(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
|
|
|||
Loading…
Reference in a new issue