LuminaWebsite/raids_live.php
Maaxxs c4f94bf84a Member feedback: raid input checks and fixed raid points, premades in the raid form, live raid page, Lumina-style dialogs, leadership calendar entries, class-based weapon picker, map and tactics fixes
- Raids: "Max. Spieler" only whole numbers up to groups x 5 (max. 10 groups / 50), gearscore only a number; fixed +1 Lumipunkt per participation, other values only with the new raids.points permission; pick an existing premade per group when creating a raid; unchanged legacy values no longer block editing
- Raid page updates itself every 15 s while visible (raids_live.php, cards rendered by includes/raid_card.php), open editors and confirm dialogs are kept
- Restore takes the new raid_id from the bot (archived messages are now deleted in Discord) and moves settings, attendance and awards; website signups send the server display name
- Premades: dissolve by leadership needs a reason, lead gets DMs on join/assign/decline/remove (source/actor_id sent to the bot), transfer picker skips players who already lead a group, website accept keeps the one-group rule, no commas in names
- Site-wide Lumina dialog (assets/js/confirm-dialog.js) replaces confirm/prompt/alert via data-confirm; error flashes are a dialog you confirm with OK
- Calendar: audience per entry (all / leadership takes part / internal) with the new calendar.leadership permission; day cells list all entries and scroll
- Gear planner: main-hand picker filtered by the set's class, mismatches marked, "keine Klasse" option, link to an external skill/Daevanion plan per set
- Map: correct kisk icons (Elyos on Verteron/Abyss, Altgard fixed), per-map max zoom and bounded panning, German texts, data source note
- Tactics: toolbar as a uniform grid, whole-tactic copy, automatic versions with restore and a 90-day trash, official tactics protected
- Global thin gold scrollbars, readable hover colours, "Sedes Luminis" spelling, patch notes and README, schema version 34

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 16:12:18 +02:00

95 lines
3 KiB
PHP

<?php
/**
* Live-Aktualisierung der Raid-Seite (assets/js/raids.js fragt hier regelmaessig nach).
*
* GET /raids_live.php?status=active&known=<raid_id>:<rev>,<raid_id>:<rev>,...
*
* Antwort: Reihenfolge der Raids, ihr aktueller Fingerabdruck (rev) und fertig gerenderte Karten
* fuer alle Raids, deren Fingerabdruck sich gegenueber "known" geaendert hat. Aenderungen aus dem
* Discord kommen so ebenfalls an, weil die Daten wie auf der Seite live von der Raid-API stammen.
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raid_card.php';
// Wird per fetch() aufgerufen - Fehler deshalb als JSON statt Weiterleitung auf die Login-Seite.
if (!current_user()) {
http_response_code(401);
json_response(false, 'Bitte neu anmelden.');
}
if (!user_has_permission('raids.view')) {
http_response_code(403);
json_response(false, 'Dir fehlt die Berechtigung, Raids zu sehen.');
}
$status = (string) ($_GET['status'] ?? 'active');
if (!in_array($status, RAID_STATUSES, true)) {
$status = 'active';
}
$known = [];
foreach (explode(',', (string) ($_GET['known'] ?? '')) as $pair) {
$parts = explode(':', trim($pair), 2);
if (count($parts) === 2 && ctype_digit($parts[0])) {
$known[$parts[0]] = $parts[1];
}
}
$currentUser = current_user();
$canManageRaids = user_has_permission('raids.manage');
$canSetRaidPoints = $canManageRaids && user_has_permission('raids.points');
// Die Formulare in den Karten brauchen das CSRF-Token der Sitzung - danach die Sitzung freigeben,
// damit eine langsame Raid-API andere Tabs derselben Person nicht blockiert.
csrf_token();
session_write_close();
try {
$raids = fetch_raids($status);
} catch (Throwable $e) {
http_response_code(502);
json_response(false, 'Raid-Daten konnten nicht geladen werden.');
}
try {
$raidSettings = raid_settings_all();
} catch (PDOException $e) {
$raidSettings = [];
}
$order = [];
$revs = [];
$changed = [];
foreach ($raids as $raid) {
$raidId = (string) (int) ($raid['raid_id'] ?? 0);
$rev = raid_card_rev($raid, $raidSettings[$raidId] ?? null);
$order[] = $raidId;
$revs[$raidId] = $rev;
if (isset($known[$raidId]) && $known[$raidId] !== $rev) {
$changed[$raidId] = $raid;
}
}
$cards = [];
if (!empty($changed)) {
$premades = [];
if ($canManageRaids) {
try {
$premades = fetch_premades();
} catch (Throwable $e) {
$premades = [];
}
}
$context = [
'status' => $status,
'current_discord_id' => $currentUser['discord_id'] ?? null,
'can_manage' => $canManageRaids,
'can_set_points' => $canSetRaidPoints,
'settings' => $raidSettings,
'premades' => $premades,
];
foreach ($changed as $raidId => $raid) {
ob_start();
render_raid_card($raid, $context);
$cards[$raidId] = trim((string) ob_get_clean());
}
}
header('Cache-Control: no-store');
json_response(true, '', ['order' => $order, 'revs' => $revs, 'cards' => (object) $cards]);