LuminaWebsite/sanctuary_action.php
Christopher Horndasch 1d6516496f Refugien-Planer umgebaut (sanctuary.php): Die Uebersicht zeigt immer ein Refugium (kein "Alle" mehr; Ludra, Korrosion, Muspel) und filtert zusaetzlich nach Stufe (Easy, Normal, Hard). Die Zeilen zeigen nur noch Mitglied, Klasse - Rolle, Kampfkraft, die Refugien ohne Stufe und "Zusatz" (Raidlead/Shotcaller fuer das gewaehlte Refugium); ein Klick klappt die Zeile auf (details/summary): Charakter mit Gearscore, die genauen Zeiten und je Refugium Stufe, Fortschritt und Notiz - auch fuer die Refugien, nach denen gerade nicht gefiltert ist. Eigener Eintrag: weiter je Charakter, aber je Refugium eigene Angaben - Raidlead, Shotcaller, "Moeglich bei" (Pflicht), aktueller Fortschritt, Notiz (sanctuary_entries.details als JSON, Schema 85; die alte Notiz je Eintrag steht bei aelteren Eintraegen bei jedem Refugium, deren Stufe ist offen und passt zu jedem Stufenfilter). Gearscore und Kampfkraft traegt man immer von Hand ein - die Werte aus dem Spiel kamen nicht immer aktuell an und sind nur noch der Vorschlag im Formular (sanctuary_stats(): Handwert vor Spielwert). Veraltete Eintraege werden nicht mehr ausgeblendet: nach 28 Tagen ohne Speichern oder "Stimmt noch" stehen sie als "updatepflichtig" ausgegraut am Ende der Liste und bleiben aufklappbar (SANCTUARY_EXPIRE_WEEKS = 4, geloescht wird wie bisher nach 90 Tagen). 8 Tage vorher (2 Tage je Woche Laufzeit) und danach erinnert ein Hinweis oben auf jeder Seite mit "Stimmt noch", "Aktualisieren" und "Heute ausblenden" (sanctuary_expiry_notice_html() in includes/header.php; Ausblenden merkt sich nur die Sitzung), dazu weiter das "!" am Menuepunkt. Standard-Sortierung Kampfkraft; "Liste kopieren" und "+ Raid aus Filter" nehmen Stufe, Raidlead und Shotcaller mit. Datenauskunft, Datenschutz (Stand 30.11.2026), README, Patchnote
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-30 17:45:19 +01:00

114 lines
4.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Refugien-Planer (sanctuary.php, includes/sanctuary.php): eigenen Eintrag speichern (Zeitfenster, je Charakter
* Gearscore/Kampfkraft und die Refugien mit ihren Angaben - Raidlead, Shotcaller, Stufe, Fortschritt, Notiz), mit
* "Stimmt noch" wieder als aktuell bestaetigen oder entfernen; dazu "Heute ausblenden" fuer den Hinweis im Seitenkopf.
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/sanctuary.php';
require_login();
if (!sanctuary_can_use()) {
show_not_found();
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/sanctuary.php');
}
verify_csrf();
$userId = (int) current_user()['id'];
$action = (string) ($_POST['action'] ?? '');
// "Stimmt noch" und "Heute ausblenden" kommen auch aus dem Hinweis im Seitenkopf - zurueck nur auf eigene Seiten
$back = (string) ($_POST['back'] ?? '');
$back = preg_match('~^/(?!/)[^\s]*$~', $back) ? $back : '/sanctuary.php';
if ($action === 'confirm') {
if (sanctuary_confirm($userId)) {
set_flash('success', 'Bestätigt – dein Eintrag gilt wieder ' . SANCTUARY_EXPIRE_DAYS . ' Tage als aktuell.');
}
redirect($back);
}
if ($action === 'snooze') {
$_SESSION['sanctuary_notice_snooze'] = date('Y-m-d');
redirect($back);
}
if ($action === 'remove') {
sanctuary_remove($userId);
set_flash('success', 'Dein Eintrag wurde entfernt.');
redirect('/sanctuary.php');
}
if ($action !== 'save') {
redirect('/sanctuary.php');
}
[$windows, $errors] = sanctuary_windows_from_input($_POST);
// Nur eigene Charaktere - was sonst im Formular steht, zaehlt nicht
$stmt = db()->prepare('SELECT id, name FROM member_characters WHERE user_id = ?');
$stmt->execute([$userId]);
$input = static fn (string $key): array => is_array($_POST[$key] ?? null) ? $_POST[$key] : [];
$raidsInput = $input('raids');
$scoreInput = $input('gs');
$powerInput = $input('cp');
// Je Charakter und Refugium: lead[Charakter][Refugium] usw.
$perRaid = static fn (array $values, int $id, string $raid) => is_array($values[$id] ?? null) ? ($values[$id][$raid] ?? null) : null;
$leadInput = $input('lead');
$shotInput = $input('shot');
$difficultyInput = $input('diff');
$progressInput = $input('progress');
$noteInput = $input('rnote');
$entries = [];
foreach ($stmt->fetchAll() as $character) {
$id = (int) $character['id'];
$raids = array_values(array_intersect(array_keys(SANCTUARY_RAIDS), is_array($raidsInput[$id] ?? null) ? $raidsInput[$id] : []));
if (!$raids) {
continue;
}
$score = sanctuary_number_input($scoreInput[$id] ?? '', SANCTUARY_GEARSCORE_MAX);
$power = sanctuary_number_input($powerInput[$id] ?? '', SANCTUARY_POWER_MAX);
if ($score === false) {
$errors[] = $character['name'] . ': Der Gearscore muss eine Zahl bis ' . number_format(SANCTUARY_GEARSCORE_MAX, 0, ',', '.') . ' sein.';
}
if ($power === false) {
$errors[] = $character['name'] . ': Die Kampfkraft muss eine ganze Zahl sein, z. B. 98986.';
}
$details = [];
foreach ($raids as $raid) {
$difficulty = $perRaid($difficultyInput, $id, $raid);
if (!is_string($difficulty) || !isset(SANCTUARY_DIFFICULTIES[$difficulty])) {
$errors[] = $character['name'] . ', ' . SANCTUARY_RAIDS[$raid]['short'] . ': Wähle bei „Möglich bei“ eine Stufe.';
$difficulty = '';
}
$details[$raid] = [
'lead' => !empty($perRaid($leadInput, $id, $raid)),
'shot' => !empty($perRaid($shotInput, $id, $raid)),
'difficulty' => $difficulty,
'progress' => sanctuary_text_input($perRaid($progressInput, $id, $raid), SANCTUARY_PROGRESS_MAX),
'note' => sanctuary_text_input($perRaid($noteInput, $id, $raid), SANCTUARY_NOTE_MAX),
];
}
$entries[$id] = [
'raids' => $raids,
'details' => $details,
'gearscore' => $score === false ? null : $score,
'combat_power' => $power === false ? null : $power,
];
}
if (!$entries) {
$errors[] = 'Wähle bei mindestens einem Charakter ein Refugium aus.';
}
if (!$windows && !$errors) {
$errors[] = 'Trage mindestens ein Zeitfenster ein – Wochentag, Beginn und Ende.';
}
if ($errors) {
set_flash('error', implode(' ', array_unique($errors)));
redirect('/sanctuary.php#mein-eintrag');
}
sanctuary_save($userId, $windows, $entries);
set_flash('success', 'Gespeichert – du stehst jetzt im Refugien-Planer. Der Eintrag gilt ' . SANCTUARY_EXPIRE_DAYS . ' Tage als aktuell; '
. SANCTUARY_WARN_DAYS . ' Tage vorher erinnern wir dich, ihn zu bestätigen.');
redirect('/sanctuary.php');