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

282 lines
15 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/contributions.php';
require_once __DIR__ . '/includes/raid_attendance.php';
require_permission('contributions.view');
// Automatische Punkte fuer inzwischen archivierte Raids, bevor die Punktestaende angezeigt werden.
raid_process_auto_points();
// Lumipunkte fuer abgeschlossene Aktivitaetschecks (includes/activity_points.php)
require_once __DIR__ . '/includes/activity_points.php';
activity_process_points();
$canManage = user_has_permission('contributions.manage');
$canViewAll = $canManage || user_has_permission('contributions.view_all');
// Der Verlauf ist einstellbar oeffentlich oder nur fuer Leute mit Bearbeitungsrechten.
$historyPublic = contributions_history_public();
$canSeeHistory = $canManage || $historyPublic;
$currentUser = current_user();
$balances = contribution_balances();
$myBalance = contribution_user_balance((int) $currentUser['id']);
// Rang: gleiche Punktzahl = gleicher Platz.
$rank = 0;
$lastPoints = null;
foreach ($balances as $index => $member) {
if ($lastPoints === null || (int) $member['points'] !== $lastPoints) {
$rank = $index + 1;
$lastPoints = (int) $member['points'];
}
$balances[$index]['rank'] = $rank;
}
// Ohne volle Sicht nur die besten Plaetze - bei Gleichstand an der Grenze alle, die sich den
// letzten Platz teilen. Der eigene Platz wird trotzdem angezeigt.
$myEntry = null;
foreach ($balances as $member) {
if ((int) $member['id'] === (int) $currentUser['id']) {
$myEntry = $member;
}
}
// Gezeigt werden immer nur die ersten Plaetze (genau CONTRIBUTION_PUBLIC_RANKS Karten). Mit voller
// Sicht kommen die uebrigen mit auf die Seite, bleiben aber eingeklappt (aufklappen / Suche).
$visibleBalances = $canViewAll ? $balances : array_slice($balances, 0, CONTRIBUTION_PUBLIC_RANKS);
$visibleIds = array_map(static fn (array $m): int => (int) $m['id'], $visibleBalances);
$showMyEntrySeparately = $myEntry !== null && !in_array((int) $myEntry['id'], $visibleIds, true);
$hiddenCount = count($balances) - count($visibleBalances);
// Verlauf, optional nur fuer ein Mitglied (Klick auf eine Karte).
$filterUserId = $canSeeHistory && isset($_GET['user']) ? (int) $_GET['user'] : null;
$filterUser = null;
// Den Verlauf von Mitgliedern ausserhalb der sichtbaren Plaetze nur mit voller Sicht - sonst
// liesse sich die Rangliste ueber den Filter doch vollstaendig abfragen.
if ($filterUserId !== null && !$canViewAll && $filterUserId !== (int) $currentUser['id'] && !in_array($filterUserId, $visibleIds, true)) {
$filterUserId = null;
}
if ($filterUserId !== null) {
foreach ($balances as $member) {
if ((int) $member['id'] === $filterUserId) {
$filterUser = $member;
}
}
if ($filterUser === null) {
$stmt = db()->prepare("SELECT id, username, display_name, avatar_filename FROM users WHERE id = ?");
$stmt->execute([$filterUserId]);
$filterUser = $stmt->fetch() ?: null;
if ($filterUser) {
$filterUser['points'] = contribution_user_balance($filterUserId);
} else {
$filterUserId = null;
}
}
}
$perPage = 20;
$totalAwards = contribution_award_count($filterUserId);
$pageCount = max(1, (int) ceil($totalAwards / $perPage));
$page = min($pageCount, max(1, (int) ($_GET['page'] ?? 1)));
$awards = $canSeeHistory ? contribution_awards($filterUserId, $perPage, ($page - 1) * $perPage) : [];
$displayName = static fn (array $u): string => (string) ($u['display_name'] !== '' ? $u['display_name'] : $u['username']);
$renderCard = static function (array $member, bool $extra = false) use ($currentUser, $canManage, $canSeeHistory, $displayName): void {
?>
<?php
$isMe = (int) $member['id'] === (int) $currentUser['id'];
$rankClass = in_array((int) $member['rank'], [1, 2, 3], true) && (int) $member['points'] > 0 ? ' rank-' . (int) $member['rank'] : '';
?>
<div class="contribution-card<?= $isMe ? ' is-me' : '' ?><?= $rankClass ?>" data-name="<?= e(mb_strtolower($displayName($member))) ?>"<?= $extra ? ' data-extra hidden' : '' ?>>
<?php if ($canSeeHistory): ?>
<a class="contribution-card-link" href="/contributions.php?user=<?= (int) $member['id'] ?>#verlauf" title="Verlauf von <?= e($displayName($member)) ?>">
<?php else: ?>
<div class="contribution-card-link">
<?php endif; ?>
<span class="contribution-rank">#<?= (int) $member['rank'] ?></span>
<?= avatar_html($member, 52) ?>
<span class="contribution-card-name"><?= e($displayName($member)) ?></span>
<span class="contribution-card-points"><?= contribution_coin(18) ?> <?= contribution_format((int) $member['points']) ?></span>
<?= $canSeeHistory ? '</a>' : '</div>' ?>
<?php if ($canManage): ?>
<a class="icon-button contribution-card-add" href="/contributions_award.php?user=<?= (int) $member['id'] ?>"
title="Punkte an <?= e($displayName($member)) ?> vergeben" aria-label="Punkte vergeben">+</a>
<?php endif; ?>
</div>
<?php
};
$pageTitle = 'Lumipunkte';
$containerWide = true;
include __DIR__ . '/includes/header.php';
?>
<div class="panel contribution-hero">
<img class="contribution-hero-coin" src="/assets/images/lumipunkt.svg" alt="" width="72" height="72">
<div class="contribution-hero-text">
<h1>Lumipunkte</h1>
<p class="text-muted">Punkte für Raids, Events und alles, was die Legion voranbringt.</p>
</div>
<div class="contribution-hero-balance" title="Dein Punktestand">
<span class="text-muted">Dein Punktestand</span>
<strong><?= contribution_coin(26) ?> <?= contribution_format($myBalance) ?></strong>
</div>
<?php if ($canManage): ?>
<a class="button" href="/contributions_award.php">Punkte vergeben</a>
<?php endif; ?>
</div>
<div class="panel">
<div class="contribution-head">
<h2>Rangliste <span class="contribution-top-label">Top <?= CONTRIBUTION_PUBLIC_RANKS ?></span></h2>
<input type="search" id="contribution-search" placeholder="Mitglied suchen …" autocomplete="off">
</div>
<?php if (empty($balances)): ?>
<p class="text-muted">Noch keine Mitglieder.</p>
<?php else: ?>
<div class="contribution-grid" id="contribution-ranking" data-limit="<?= CONTRIBUTION_PUBLIC_RANKS ?>">
<?php foreach ($visibleBalances as $index => $member): ?>
<?php $renderCard($member, $index >= CONTRIBUTION_PUBLIC_RANKS); ?>
<?php endforeach; ?>
</div>
<p class="text-muted" id="contribution-no-match" hidden>Kein Mitglied passt zur Suche.</p>
<?php if (count($visibleBalances) > CONTRIBUTION_PUBLIC_RANKS): ?>
<div class="contribution-more">
<button type="button" class="button button-secondary" id="contribution-show-all"
data-more="Alle <?= count($visibleBalances) ?> anzeigen" data-less="Nur die besten <?= CONTRIBUTION_PUBLIC_RANKS ?> anzeigen">
Alle <?= count($visibleBalances) ?> anzeigen
</button>
</div>
<?php endif; ?>
<?php if ($showMyEntrySeparately): ?>
<div class="contribution-own">
<h3>Dein Platz</h3>
<div class="contribution-grid">
<?php $renderCard($myEntry); ?>
</div>
</div>
<?php endif; ?>
<?php if ($hiddenCount > 0): ?>
<p class="text-muted contribution-limit-note">
Angezeigt werden die besten <?= CONTRIBUTION_PUBLIC_RANKS ?> Plätze. Die vollständige Rangliste
(<?= count($balances) ?> Mitglieder) ist der Legionsleitung vorbehalten.
</p>
<?php endif; ?>
<?php endif; ?>
</div>
<?php if ($canSeeHistory): ?>
<div class="panel" id="verlauf">
<div class="contribution-head">
<h2>
Verlauf<?= $filterUser ? ': ' . e($displayName($filterUser)) : '' ?>
<?php if ($filterUser): ?>
<span class="contribution-filter-balance"><?= contribution_coin(20) ?> <?= contribution_format((int) $filterUser['points']) ?></span>
<?php endif; ?>
</h2>
<?php if ($filterUser): ?>
<a href="/contributions.php#verlauf">Alle Vergaben anzeigen</a>
<?php endif; ?>
</div>
<?php if ($canManage): ?>
<form class="settings-toggle" method="post" action="/admin/settings_action.php">
<?= csrf_field() ?>
<input type="hidden" name="setting" value="contributions_history_public">
<label>
<input type="checkbox" name="value" value="1" <?= $historyPublic ? 'checked' : '' ?> onchange="this.form.submit()">
Verlauf für alle sichtbar
<span class="text-muted">- sonst sehen ihn nur Leute, die Punkte vergeben dürfen</span>
</label>
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
</form>
<?php endif; ?>
<?php if (empty($awards)): ?>
<p class="text-muted">Noch keine Lumipunkte vergeben.</p>
<?php else: ?>
<div class="contribution-awards">
<?php foreach ($awards as $award): ?>
<?php
$entries = $award['entries'];
$pointValues = array_unique(array_map(static fn (array $entry): int => (int) $entry['points'], $entries));
$uniform = count($pointValues) === 1 ? (int) reset($pointValues) : null;
$mine = null;
if ($filterUserId !== null) {
foreach ($entries as $entry) {
if ((int) $entry['user_id'] === $filterUserId) {
$mine = (int) $entry['points'];
}
}
}
$shownPoints = $mine ?? $uniform;
$isSystem = isset(CONTRIBUTION_SYSTEM_CATEGORIES[(string) $award['category']]);
?>
<article class="contribution-award">
<div class="contribution-award-points<?= $shownPoints !== null && $shownPoints < 0 ? ' negative' : '' ?>">
<?= contribution_coin(22) ?>
<strong><?= $shownPoints !== null ? contribution_format($shownPoints, true) : 'versch.' ?></strong>
<?php if ($mine === null && count($entries) > 1): ?>
<span class="text-muted">je Mitglied</span>
<?php endif; ?>
</div>
<div class="contribution-award-body">
<div class="contribution-award-title">
<span class="badge contribution-badge-<?= e((string) $award['category']) ?>"><?= e(contribution_category_label((string) $award['category'])) ?></span>
<strong><?= e((string) $award['title']) ?></strong>
</div>
<?php if (!empty($award['note'])): ?>
<p class="contribution-award-note"><?= e((string) $award['note']) ?></p>
<?php endif; ?>
<div class="contribution-award-meta text-muted">
<?= e(contribution_format_time($award['awarded_at'])) ?>
· <?= count($entries) ?> <?= count($entries) === 1 ? 'Mitglied' : 'Mitglieder' ?>
<?php if (!empty($award['author'])): ?>· <?= $isSystem ? 'bewilligt' : 'vergeben' ?> von <?= e((string) $award['author']) ?><?php endif; ?>
</div>
<details class="contribution-award-members"<?= count($entries) <= 6 ? ' open' : '' ?>>
<summary>Mitglieder anzeigen</summary>
<div class="contribution-chips">
<?php foreach ($entries as $entry): ?>
<span class="contribution-chip<?= (int) $entry['user_id'] === $filterUserId ? ' highlight' : '' ?>">
<a href="/contributions.php?user=<?= (int) $entry['user_id'] ?>#verlauf"><?= e((string) $entry['name']) ?></a>
<?php if ($uniform === null): ?>
<span class="text-muted"><?= contribution_format((int) $entry['points'], true) ?></span>
<?php endif; ?>
<?php if ($canManage && !$isSystem): ?>
<form class="inline-form" method="post" action="/contributions_action.php"
data-confirm="<?= e('„' . $entry['name'] . '“ aus dieser Vergabe entfernen? Die Punkte werden abgezogen.') ?>" data-confirm-title="Aus der Vergabe entfernen" data-confirm-danger data-confirm-ok="Entfernen">
<?= csrf_field() ?>
<input type="hidden" name="action" value="remove_entry">
<input type="hidden" name="entry_id" value="<?= (int) $entry['id'] ?>">
<button type="submit" class="contribution-chip-remove" title="Aus der Vergabe entfernen" aria-label="Entfernen">×</button>
</form>
<?php endif; ?>
</span>
<?php endforeach; ?>
</div>
</details>
</div>
<?php if ($canManage && !$isSystem): ?>
<form class="contribution-award-delete" method="post" action="/contributions_action.php"
data-confirm="<?= e('Vergabe „' . $award['title'] . '“ komplett löschen? Allen ' . count($entries) . ' Mitgliedern werden die Punkte wieder abgezogen.') ?>" data-confirm-title="Vergabe löschen" data-confirm-danger data-confirm-ok="Löschen">
<?= csrf_field() ?>
<input type="hidden" name="action" value="delete_award">
<input type="hidden" name="award_id" value="<?= (int) $award['id'] ?>">
<button type="submit" class="icon-button icon-button-danger" title="Vergabe löschen" aria-label="Vergabe löschen"><?= icon('trash') ?></button>
</form>
<?php endif; ?>
</article>
<?php endforeach; ?>
</div>
<div class="contribution-pages">
<span class="text-muted">
Vergaben <?= ($page - 1) * $perPage + 1 ?>–<?= min($page * $perPage, $totalAwards) ?>
von <?= number_format($totalAwards, 0, ',', '.') ?>
</span>
<?php render_pagination('/contributions.php?' . ($filterUserId !== null ? 'user=' . $filterUserId . '&' : ''), $page, $pageCount, '#verlauf'); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<script src="<?= e(asset_url('/assets/js/contributions.js')) ?>"></script>
<?php include __DIR__ . '/includes/footer.php'; ?>