LuminaWebsite/raid_attendance_action.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

77 lines
3 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
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raid_attendance.php';
require_permission('raids.manage');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/raids.php');
}
verify_csrf();
$raidId = (int) ($_POST['raid_id'] ?? 0);
if ($raidId <= 0) {
redirect('/raids.php');
}
$userId = (int) current_user()['id'];
// Eigene Einstellungen (fester Punkt) vor dem "kontrolliert"-Haken anlegen.
raid_settings_ensure_defaults([$raidId]);
$statuses = (array) ($_POST['status'] ?? []);
$names = (array) ($_POST['names'] ?? []);
// Nachgetragenes Mitglied kommt als anwesend dazu.
$addDiscordId = trim((string) ($_POST['add_discord_id'] ?? ''));
if ($addDiscordId !== '' && ctype_digit($addDiscordId)) {
$stmt = db()->prepare("SELECT COALESCE(NULLIF(display_name, ''), username) FROM users WHERE discord_id = ?");
$stmt->execute([$addDiscordId]);
$name = $stmt->fetchColumn();
if ($name !== false) {
$statuses[$addDiscordId] = 'present';
$names[$addDiscordId] = (string) $name;
}
}
$pdo = db();
$pdo->beginTransaction();
$upsert = $pdo->prepare(
'INSERT INTO raid_attendance (raid_id, discord_id, name, status, updated_by, updated_at) VALUES (?, ?, ?, ?, ?, NOW())
ON DUPLICATE KEY UPDATE name = VALUES(name), status = VALUES(status), updated_by = VALUES(updated_by), updated_at = NOW()'
);
$delete = $pdo->prepare('DELETE FROM raid_attendance WHERE raid_id = ? AND discord_id = ?');
$counts = array_fill_keys(array_keys(RAID_ATTENDANCE_STATUSES), 0);
foreach ($statuses as $discordId => $status) {
$discordId = (string) $discordId;
if (!ctype_digit($discordId)) {
continue;
}
$status = (string) $status;
if (isset(RAID_ATTENDANCE_STATUSES[$status])) {
$upsert->execute([$raidId, $discordId, mb_substr((string) ($names[$discordId] ?? ''), 0, 100), $status, $userId]);
$counts[$status]++;
} else {
$delete->execute([$raidId, $discordId]); // "–" = nicht erfasst
}
}
if (!empty($_POST['mark_checked'])) {
$pdo->prepare(
'INSERT INTO raid_settings (raid_id, attendance_checked_at, attendance_checked_by) VALUES (?, NOW(), ?)
ON DUPLICATE KEY UPDATE attendance_checked_at = NOW(), attendance_checked_by = VALUES(attendance_checked_by)'
)->execute([$raidId, $userId]);
}
$pdo->commit();
admin_log('📋 Anwesenheit eingetragen', [
'Raid' => admin_log_raid($raidId),
'Anwesend' => $counts['present'],
'Abwesend' => $counts['absent'],
'Nachgetragen' => $addDiscordId !== '' && isset($names[$addDiscordId]) ? admin_log_discord($addDiscordId, (string) $names[$addDiscordId]) : '',
'Kontrolliert' => !empty($_POST['mark_checked']) ? 'ja, Liste abgeschlossen' : '',
], 'success');
set_flash('success', sprintf(
'Anwesenheit gespeichert: %d anwesend, %d abwesend%s.',
$counts['present'], $counts['absent'],
!empty($_POST['mark_checked']) ? ' - als kontrolliert markiert' : ''
));
redirect('/raid_attendance.php?raid=' . $raidId);