LuminaWebsite/includes/header.php
Maaxxs fea0cc3a91 Overhaul raid signup/management to match the Discord bot's full feature set
Signup is now a single "Anmelden" button that opens a class-icon
picker + optional group choice. A new raid_wish_is_sensible() mirrors
the bot's exact role-cap algorithm (Tank/Heal 1, DPS 3 per 5-player
group, ROLE_MAPPING copied from teamplaner.py) to decide server-side
whether the requested group is honored or the request falls back to
the bot's own auto-assignment - with a message telling the member to
ping the raid lead if they wanted something specific. Verified the
cap logic with 7 synthetic cases (own-signup exclusion, full group,
role caps, bench always allowed) before wiring it up.

Admins get a per-raid edit-mode toggle (pencil icon) that reveals:
inline raid editing (title/date/requirements/gearscore/groups/slots/
group locks) via PATCH, a premade-invite mini-form via the new
premades endpoint, and native HTML5 drag-and-drop to move a signup
between groups/bench via PATCH .../signup/{user_id}.

New pieces: includes/raids_api.php gained move_signup(), update_raid(),
invite_premade(), fetch_premades(), fetch_raid_by_id() and the wish-
sensibility check; four new JSON action endpoints (raid_signup_action,
raid_move_action, raid_edit_action, raid_premade_invite_action) reusing
the session CSRF token via a new verify_csrf_token()/read_json_body()/
json_response() trio in functions.php; assets/js/raids.js drives the
modal, edit-mode, and drag-and-drop with plain fetch() (no framework).

Read-heavy parts (page render, class icons, signup-wish logic) verified
against real data/live API. Edit, move and premade-invite are NOT
tested against the live API yet since they'd mutate the real raid or
send real Discord DMs to guild members - flagging this for a
supervised live check before considering it fully verified.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-18 18:36:04 +02:00

93 lines
4.4 KiB
PHP

<?php
/** @var string|null $pageTitle */
$currentUser = current_user();
$canViewUsers = $currentUser && user_has_permission('users.view');
$canManageRoles = $currentUser && user_has_permission('roles.manage');
$canViewRaids = $currentUser && user_has_permission('raids.view');
$showAdminMenu = $canViewUsers || $canManageRoles;
$currentScript = basename((string) ($_SERVER['SCRIPT_NAME'] ?? ''));
$isDashboardActive = $currentScript === 'dashboard.php';
$isProfileActive = $currentScript === 'profile.php';
$isRaidsActive = $currentScript === 'raids.php';
$isUsersActive = in_array($currentScript, ['users.php', 'user_form.php', 'user_delete.php'], true);
$isRolesActive = in_array($currentScript, ['roles.php', 'role_form.php', 'role_delete.php'], true);
// Jeder Bereich bekommt ein eigenes, dezentes Hintergrundbild.
$pageBackgrounds = [
'dashboard.php' => 'bg-dashboard',
'profile.php' => 'bg-profile',
'raids.php' => 'bg-raids',
'users.php' => 'bg-admin',
'user_form.php' => 'bg-admin',
'user_delete.php' => 'bg-admin',
'roles.php' => 'bg-admin',
'role_form.php' => 'bg-admin',
'role_delete.php' => 'bg-admin',
];
$pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="<?= e(csrf_token()) ?>">
<title><?= e(($pageTitle ?? '') !== '' ? $pageTitle . ' - Aion2 Gilde' : 'Aion2 Gilde') ?></title>
<link rel="stylesheet" href="/assets/css/style.css">
</head>
<body>
<?php if ($currentUser): ?>
<div class="app-shell">
<aside class="sidebar">
<div class="sidebar-brand"><a href="/"><img src="/assets/images/logo.png" alt="Aion2 Gilde"></a></div>
<nav class="sidebar-nav">
<a href="/dashboard.php" class="sidebar-link<?= $isDashboardActive ? ' active' : '' ?>" title="Dashboard">
<?= icon('home') ?><span class="label">Dashboard</span>
</a>
<a href="/profile.php" class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil">
<?= icon('profile') ?><span class="label">Mein Profil</span>
</a>
<?php if ($canViewRaids): ?>
<a href="/raids.php" class="sidebar-link<?= $isRaidsActive ? ' active' : '' ?>" title="Raids">
<?= icon('calendar') ?><span class="label">Raids</span>
</a>
<?php endif; ?>
<?php if ($showAdminMenu): ?>
<div class="sidebar-section-label">Admin</div>
<?php if ($canViewUsers): ?>
<a href="/admin/users.php" class="sidebar-link<?= $isUsersActive ? ' active' : '' ?>" title="Benutzerverwaltung">
<?= icon('users') ?><span class="label">Benutzerverwaltung</span>
</a>
<?php endif; ?>
<?php if ($canManageRoles): ?>
<a href="/admin/roles.php" class="sidebar-link<?= $isRolesActive ? ' active' : '' ?>" title="Berechtigungsgruppen">
<?= icon('shield') ?><span class="label">Berechtigungsgruppen</span>
</a>
<?php endif; ?>
<?php endif; ?>
</nav>
<div class="sidebar-footer">
<div class="sidebar-user">Angemeldet als<br><strong><?= e($currentUser['display_name'] !== '' ? $currentUser['display_name'] : $currentUser['username']) ?></strong></div>
<a href="/logout.php" class="sidebar-link" title="Abmelden">
<?= icon('log-out') ?><span class="label">Abmelden</span>
</a>
</div>
</aside>
<div class="app-content<?= $pageBackgroundClass ? ' ' . e($pageBackgroundClass) : '' ?>">
<main class="container">
<?php foreach (get_flashes() as $flash): ?>
<div class="flash flash-<?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
<?php endforeach; ?>
<?php else: ?>
<header class="navbar">
<div class="navbar-brand"><a href="/"><img src="/assets/images/logo.png" alt="Aion2 Gilde"></a></div>
<div class="navbar-user">
<a href="/login.php">Login</a>
</div>
</header>
<main class="container">
<?php foreach (get_flashes() as $flash): ?>
<div class="flash flash-<?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
<?php endforeach; ?>
<?php endif; ?>