Add a "Mein Profil" page and align raids with the real bot logic

- New profile.php (display name, password, Discord link/unlink),
  reachable from the sidebar; removed the duplicate Discord section
  from the dashboard.
- Corrected class names/icon mapping to match the actual bot config
  (Beschwörer, Kantor) instead of the guessed German terms used
  earlier.
- raids.php now understands the bot's full group model: group 0 is
  the bench ("Ersatzbank"), -1 is a decline ("Abgemeldet"), and class
  "Ausstehend" marks a pending premade invite (now shown with an
  hourglass instead of being silently dropped or mis-rendered). The
  "X / max" counter matches the bot's own active-count logic (pending
  invites don't count). Signup form also lets a member choose the
  bench explicitly.
- A few more inline icons (profile, list) for general visual polish.

Verified grouping/active-count/icon logic with synthetic bench/
declined/pending signups, and the real raids.php flow (profile
update, sidebar nav) against a local DB plus the live raids API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-18 13:49:41 +02:00
parent 8c703f0e1f
commit 706cf97d64
8 changed files with 194 additions and 47 deletions

View file

@ -18,6 +18,7 @@ und wird später ausgebaut. Fokus dieser Version ist der Mitglieder-/Admin-Berei
- Jeder Benutzer kann mehreren Berechtigungsgruppen angehören
- Raids-Seite: zeigt anstehende Raid-Termine, Anforderungen, Gruppen und Anmeldungen,
bezogen von einer externen API (`config.php: raids_api`), Filter Aktiv/Archiviert/Alle
- "Mein Profil"-Seite: Anzeigename ändern, Passwort ändern, Discord-Verknüpfung verwalten
- Discord-Verknüpfung: Mitglieder können ihren Discord-Account per OAuth mit ihrem
Website-Account verknüpfen (nötig, um sich über die Website zu Raids anzumelden)
- Raid-Anmeldung: verknüpfte Mitglieder können sich direkt über die Website zu einem Raid

View file

@ -401,6 +401,34 @@ input:focus, select:focus, textarea:focus {
flex-shrink: 0;
}
.class-icon-placeholder {
display: inline-flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
margin-right: 0.5rem;
flex-shrink: 0;
font-size: 1rem;
}
.raid-group-bench { border-style: dashed; }
.raid-signup-pending { color: var(--text-muted); font-style: italic; }
.raid-declined {
margin-top: 0.75rem;
padding-top: 0.75rem;
border-top: 1px solid var(--border);
}
.raid-meta-line {
display: flex;
align-items: center;
gap: 0.4rem;
}
.raid-meta-line .icon { color: var(--text-muted); }
.panel-archived { opacity: 0.7; }
.raid-signup-note {

View file

@ -15,33 +15,26 @@ include __DIR__ . '/includes/header.php';
<p class="text-muted">Dies ist dein Mitgliederbereich. Die eigentliche Gilden-Homepage folgt hier später.</p>
</div>
<div class="panel">
<h2>Discord-Verknüpfung</h2>
<?php if (!empty($user['discord_id'])): ?>
<p>Verknüpft als <strong><?= e((string) $user['discord_username']) ?></strong></p>
<form method="post" action="/discord_unlink.php" class="inline-form" onsubmit="return confirm('Discord-Verknüpfung wirklich entfernen?');">
<?= csrf_field() ?>
<button type="submit" class="button-secondary">Verknüpfung entfernen</button>
</form>
<?php else: ?>
<p class="text-muted">Verknüpfe deinen Discord-Account, um dich über die Website zu Raids anmelden zu können.</p>
<a class="button" href="/discord_login.php">Mit Discord verknüpfen</a>
<?php endif; ?>
</div>
<?php if ($canViewRaids): ?>
<div class="panel">
<div class="card-grid">
<div class="panel stat-card">
<div class="icon-badge"><?= icon('calendar') ?></div>
<div class="icon-badge"><?= icon('profile') ?></div>
<div>
<h3>Raids</h3>
<p class="text-muted"><a href="/raids.php">Anstehende Raid-Termine ansehen</a></p>
<h3>Mein Profil</h3>
<p class="text-muted"><a href="/profile.php">Anzeigename, Passwort &amp; Discord verwalten</a></p>
</div>
</div>
<?php if ($canViewRaids): ?>
<div class="panel stat-card">
<div class="icon-badge"><?= icon('calendar') ?></div>
<div>
<h3>Raids</h3>
<p class="text-muted"><a href="/raids.php">Anstehende Raid-Termine ansehen</a></p>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ($canViewUsers || $canManageRoles): ?>
<div class="panel">

View file

@ -70,6 +70,9 @@ function icon(string $name): string
'log-out' => '<path d="M9 20H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h3"/><path d="m14 16 4-4-4-4"/><path d="M18 12H9"/>',
'lock' => '<rect x="4" y="11" width="16" height="9" rx="2"/><path d="M7.5 11V7.5a4.5 4.5 0 0 1 9 0V11"/>',
'calendar' => '<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M16 3v4"/><path d="M8 3v4"/><path d="M3 10h18"/>',
'profile' => '<circle cx="12" cy="8" r="4"/><path d="M4.5 20c0-4 3.5-6.5 7.5-6.5s7.5 2.5 7.5 6.5"/>',
'link' => '<path d="M9 17H7a5 5 0 0 1 0-10h2"/><path d="M15 7h2a5 5 0 0 1 0 10h-2"/><line x1="8" y1="12" x2="16" y2="12"/>',
'list' => '<line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4.5" cy="6" r="1"/><circle cx="4.5" cy="12" r="1"/><circle cx="4.5" cy="18" r="1"/>',
];
$path = $paths[$name] ?? '';
@ -99,6 +102,8 @@ function class_icon_url(string $className): ?string
'magier' => 'Sorcerer_ICO.png',
'spiritmaster' => 'Spiritmaster_ICO.png',
'geisterbeschwörer' => 'Spiritmaster_ICO.png',
'beschwörer' => 'Spiritmaster_ICO.png',
'kantor' => 'Chanter_ICO.png',
'templar' => 'Templar_ICO.png',
'templer' => 'Templar_ICO.png',
];

View file

@ -8,6 +8,7 @@ $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);
@ -29,6 +30,9 @@ $isRolesActive = in_array($currentScript, ['roles.php', 'role_form.php', 'role_d
<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>

68
profile.php Normal file
View file

@ -0,0 +1,68 @@
<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_login();
$user = current_user();
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verify_csrf();
$displayName = trim((string) ($_POST['display_name'] ?? ''));
if ($displayName === '') {
$error = 'Anzeigename darf nicht leer sein.';
} else {
db()->prepare('UPDATE users SET display_name = ? WHERE id = ?')->execute([$displayName, $user['id']]);
set_flash('success', 'Profil wurde aktualisiert.');
redirect('/profile.php');
}
$user['display_name'] = $displayName;
}
$pageTitle = 'Mein Profil';
include __DIR__ . '/includes/header.php';
?>
<div class="panel">
<h1>Mein Profil</h1>
<p class="text-muted">Benutzername: <strong><?= e($user['username']) ?></strong></p>
</div>
<div class="panel">
<h2>Anzeigename</h2>
<?php if ($error): ?>
<div class="flash flash-error"><?= e($error) ?></div>
<?php endif; ?>
<form method="post" action="/profile.php">
<?= csrf_field() ?>
<div>
<label for="display_name">Anzeigename</label>
<input type="text" id="display_name" name="display_name" value="<?= e($user['display_name']) ?>" required>
</div>
<button type="submit">Speichern</button>
</form>
</div>
<div class="panel">
<h2>Passwort</h2>
<p class="text-muted">Du kannst dein Passwort jederzeit ändern.</p>
<a class="button button-secondary" href="/change_password.php">Passwort ändern</a>
</div>
<div class="panel stat-card">
<div class="icon-badge"><?= icon('link') ?></div>
<div>
<h3>Discord-Verknüpfung</h3>
<?php if (!empty($user['discord_id'])): ?>
<p>Verknüpft als <strong><?= e((string) $user['discord_username']) ?></strong></p>
<form method="post" action="/discord_unlink.php" class="inline-form" onsubmit="return confirm('Discord-Verknüpfung wirklich entfernen?');">
<?= csrf_field() ?>
<button type="submit" class="button-secondary">Verknüpfung entfernen</button>
</form>
<?php else: ?>
<p class="text-muted">Verknüpfe deinen Discord-Account, um dich über die Website zu Raids anmelden zu können.</p>
<a class="button" href="/discord_login.php">Mit Discord verknüpfen</a>
<?php endif; ?>
</div>
</div>
<?php include __DIR__ . '/includes/footer.php'; ?>

View file

@ -22,13 +22,15 @@ if (empty($user['discord_id'])) {
$raidId = (int) ($_POST['raid_id'] ?? 0);
$class = trim((string) ($_POST['class'] ?? ''));
$group = (int) ($_POST['group'] ?? 0);
$groupRaw = $_POST['group'] ?? '';
if ($raidId <= 0 || $class === '' || $group <= 0) {
if ($raidId <= 0 || $class === '' || !is_numeric($groupRaw) || (int) $groupRaw < 0) {
set_flash('error', 'Bitte Klasse und Gruppe auswählen.');
redirect($redirectTo);
}
$group = (int) $groupRaw;
try {
raid_signup($raidId, (int) $user['discord_id'], (string) $user['discord_username'], $class, $group);
set_flash('success', 'Anmeldung gespeichert.');

View file

@ -3,11 +3,38 @@ require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_permission('raids.view');
function render_signup_list(array $members): void
{
?>
<ul>
<?php foreach ($members as $member): ?>
<?php
$memberName = (string) ($member['name'] ?? '?');
$memberClass = (string) ($member['class'] ?? '');
$isPending = $memberClass === 'Ausstehend';
$classIconUrl = $isPending ? null : class_icon_url($memberClass);
?>
<li<?= $isPending ? ' class="raid-signup-pending"' : '' ?>>
<?php if ($isPending): ?>
<span class="class-icon-placeholder" title="Einladung ausstehend">⏳</span>
<?php elseif ($classIconUrl): ?>
<img src="<?= e($classIconUrl) ?>" alt="<?= e($memberClass) ?>" title="<?= e($memberClass) ?>" class="class-icon">
<?php endif; ?>
<?= e($memberName) ?>
<?php if (!$isPending && !$classIconUrl && $memberClass !== ''): ?>
<span class="text-muted">(<?= e($memberClass) ?>)</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php
}
$currentUser = current_user();
$currentDiscordId = $currentUser['discord_id'] ?? null;
$canManageRaids = user_has_permission('raids.manage');
$classOptions = ['Gladiator', 'Templer', 'Assassine', 'Jäger', 'Magier', 'Geisterbeschwörer', 'Kleriker', 'Barde'];
$classOptions = ['Templer', 'Gladiator', 'Assassine', 'Jäger', 'Magier', 'Beschwörer', 'Kleriker', 'Kantor'];
$status = (string) ($_GET['status'] ?? 'active');
if (!in_array($status, RAID_STATUSES, true)) {
@ -72,15 +99,34 @@ include __DIR__ . '/includes/header.php';
$groupNames = array_values(array_filter(array_map('trim', explode(',', (string) ($raid['groups'] ?? '')))));
// Gruppennummern folgen der Logik des Bots: >=1 echte Gruppe, 0 Ersatzbank, -1 abgemeldet.
$signupsByGroup = [];
$benchSignups = [];
$declinedSignups = [];
$mySignup = null;
foreach ($signups as $signup) {
$groupNumber = (int) ($signup['group'] ?? 0);
$signupsByGroup[$groupNumber][] = $signup;
if ($currentDiscordId && (string) ($signup['user_id'] ?? '') === (string) $currentDiscordId) {
if ($groupNumber >= 1) {
$signupsByGroup[$groupNumber][] = $signup;
} elseif ($groupNumber === 0) {
$benchSignups[] = $signup;
} else {
$declinedSignups[] = $signup;
}
if ($currentDiscordId && (string) ($signup['user_id'] ?? '') === (string) $currentDiscordId && $groupNumber >= 0) {
$mySignup = $signup;
}
}
// Wie im Bot-Embed zaehlen nur echte, bestaetigte Anmeldungen als "aktiv".
$activeCount = 0;
foreach ($signupsByGroup as $groupMembers) {
foreach ($groupMembers as $groupMember) {
if (($groupMember['class'] ?? '') !== 'Ausstehend') {
$activeCount++;
}
}
}
?>
<div class="panel<?= $isArchived ? ' panel-archived' : '' ?>">
<div class="raid-header">
@ -89,7 +135,7 @@ include __DIR__ . '/includes/header.php';
<?php if ($isArchived): ?>
<span class="badge badge-disabled">Archiviert<?= $archivedAt ? ' (' . e((string) $archivedAt) . ')' : '' ?></span>
<?php endif; ?>
<span class="badge"><?= count($signups) ?> / <?= $maxSlots ?> angemeldet</span>
<span class="badge"><?= $activeCount ?> / <?= $maxSlots ?> angemeldet</span>
<?php if ($canManageRaids): ?>
<?php if ($isArchived): ?>
<form method="post" action="/raid_restore.php" class="inline-form">
@ -111,7 +157,7 @@ include __DIR__ . '/includes/header.php';
</div>
<p class="text-muted"><?= e($dateLabel) ?></p>
<?php if ($requirements !== ''): ?>
<p><strong>Anforderungen:</strong> <?= e($requirements) ?></p>
<p class="raid-meta-line"><?= icon('list') ?> <strong>Anforderungen:</strong> <?= e($requirements) ?></p>
<?php endif; ?>
<?php if ($gearscore !== ''): ?>
<p><strong>Gearscore:</strong> <?= e($gearscore) ?></p>
@ -122,43 +168,42 @@ include __DIR__ . '/includes/header.php';
<?php foreach ($groupNames as $index => $groupName): ?>
<?php $members = $signupsByGroup[$index + 1] ?? []; ?>
<div class="raid-group">
<h3><?= e($groupName) ?></h3>
<h3><?= e($groupName) ?> (<?= count($members) ?>)</h3>
<?php if (empty($members)): ?>
<p class="text-muted">Keine Anmeldungen</p>
<?php else: ?>
<ul>
<?php foreach ($members as $member): ?>
<?php
$memberClass = (string) ($member['class'] ?? '');
$classIconUrl = class_icon_url($memberClass);
?>
<li>
<?php if ($classIconUrl): ?>
<img src="<?= e($classIconUrl) ?>" alt="<?= e($memberClass) ?>" title="<?= e($memberClass) ?>" class="class-icon">
<?php endif; ?>
<?= e((string) ($member['name'] ?? '?')) ?>
<?php if (!$classIconUrl && $memberClass !== ''): ?>
<span class="text-muted">(<?= e($memberClass) ?>)</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php render_signup_list($members); ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php if (!empty($benchSignups)): ?>
<div class="raid-group raid-group-bench">
<h3>Ersatzbank (<?= count($benchSignups) ?>)</h3>
<?php render_signup_list($benchSignups); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if (!empty($declinedSignups)): ?>
<p class="text-muted raid-declined">
Abgemeldet: <?= e(implode(', ', array_map(static fn ($s) => (string) ($s['name'] ?? '?'), $declinedSignups))) ?>
</p>
<?php endif; ?>
<?php
$mySignupGroupNumber = $mySignup ? (int) ($mySignup['group'] ?? 0) : null;
$mySignupGroupLabel = $mySignupGroupNumber === 0 ? 'Ersatzbank' : ($mySignupGroupNumber ? ($groupNames[$mySignupGroupNumber - 1] ?? ('#' . $mySignupGroupNumber)) : null);
?>
<?php if ($isArchived): ?>
<p class="text-muted raid-signup-note">Dieser Raid ist archiviert – Anmeldungen sind geschlossen.</p>
<?php elseif (!$currentDiscordId): ?>
<p class="text-muted raid-signup-note">Verknüpfe deinen <a href="/dashboard.php">Discord-Account</a>, um dich anzumelden.</p>
<p class="text-muted raid-signup-note">Verknüpfe deinen <a href="/profile.php">Discord-Account</a>, um dich anzumelden.</p>
<?php else: ?>
<?php if ($mySignup): ?>
<div class="raid-signup-note">
<p>
Du bist angemeldet als <strong><?= e((string) ($mySignup['class'] ?? '')) ?></strong>
in Gruppe <strong><?= e($groupNames[((int) ($mySignup['group'] ?? 1)) - 1] ?? ('#' . ($mySignup['group'] ?? '?'))) ?></strong>.
in <strong><?= e($mySignupGroupLabel) ?></strong>.
</p>
<form method="post" action="/raid_unsignup.php" class="inline-form">
<?= csrf_field() ?>
@ -181,8 +226,9 @@ include __DIR__ . '/includes/header.php';
</select>
<select name="group" required>
<?php foreach ($groupNames as $index => $groupName): ?>
<option value="<?= $index + 1 ?>" <?= ($mySignup && (int) ($mySignup['group'] ?? 0) === $index + 1) ? 'selected' : '' ?>><?= e($groupName) ?></option>
<option value="<?= $index + 1 ?>" <?= $mySignupGroupNumber === $index + 1 ? 'selected' : '' ?>><?= e($groupName) ?></option>
<?php endforeach; ?>
<option value="0" <?= $mySignupGroupNumber === 0 ? 'selected' : '' ?>>Ersatzbank</option>
</select>
<button type="submit"><?= $mySignup ? 'Aktualisieren' : 'Anmelden' ?></button>
</form>