Beitragspunkte: switch for public history, old logo back

Above the history, people with contributions.manage can switch "Verlauf für
alle sichtbar" (default on). Turned off, everyone else sees only the ranking,
without history and without links on the cards. Settings now carry their own
permission and return page, so the same action serves this switch and the
Discord unlink switch in the user list.

The sidebar, login page and mobile top bar show the previous logo again;
the new logo files are removed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-21 09:31:19 +02:00
parent 852eee357d
commit dd7ad2a25b
8 changed files with 63 additions and 22 deletions

View file

@ -412,7 +412,9 @@ Herzform (`assets/images/beitragspunkt.svg`).
- **Abzüge:** Negative Punkte ziehen ab, etwa für Korrekturen.
- **Verlauf** aller Vergaben mit Seiten: Punkte, Anlass, Grund, Datum, wer vergeben hat und die
beteiligten Mitglieder. Eine Vergabe lässt sich ganz löschen oder einzelne Mitglieder daraus
entfernen, die Punkte werden dann wieder abgezogen.
entfernen, die Punkte werden dann wieder abgezogen. Mit dem Schalter **Verlauf für alle
sichtbar** über dem Verlauf legen Leute mit `contributions.manage` fest, ob alle den Verlauf
sehen oder nur sie selbst (Standard: alle). Ist er aus, sehen die übrigen nur die Rangliste.
Der Punktestand wird nicht gespeichert, sondern aus den Vergaben berechnet (Tabellen
`contribution_awards` und `contribution_entries`). So kann er nicht vom Verlauf abweichen, und

View file

@ -1,20 +1,24 @@
<?php
require_once __DIR__ . '/../includes/bootstrap.php';
require_permission('users.edit');
require_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/admin/users.php');
redirect('/dashboard.php');
}
verify_csrf();
$key = (string) ($_POST['setting'] ?? '');
if (!array_key_exists($key, SETTINGS_DEFAULTS)) {
if (!array_key_exists($key, SETTINGS_DEFAULTS) || !isset(SETTINGS_ACCESS[$key])) {
set_flash('error', 'Unbekannte Einstellung.');
redirect('/admin/users.php');
redirect('/dashboard.php');
}
// Jede Einstellung gehoert zu einem Bereich und braucht dessen Recht.
[$permission, $returnTo] = SETTINGS_ACCESS[$key];
require_permission($permission);
// Bisher gibt es nur Ja/Nein-Einstellungen: angehakt = "1", sonst "0".
setting_set($key, isset($_POST['value']) ? '1' : '0');
set_flash('success', 'Einstellung gespeichert.');
redirect('/admin/users.php');
redirect($returnTo);

View file

@ -49,7 +49,7 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
.navbar-brand img {
display: block;
height: 48px;
height: 40px;
width: auto;
}
@ -85,23 +85,22 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
}
.sidebar-brand {
padding: 0 0.65rem 1rem;
padding: 0 0.65rem 1.5rem;
font-size: 1.15rem;
font-weight: bold;
}
.sidebar-brand a { display: block; }
/* Das Logo ist quadratisch (Wappen mit Schriftzug). Ueber die volle Sidebar-Breite waere es
fast 240px hoch - deshalb begrenzt und mittig, mit weichem Goldschein. */
/* Das Logo ist sehr breit (Seitenverhaeltnis 480:108). Mit fester Hoehe waere es breiter
als die Sidebar und wuerde unten eine waagerechte Scrollleiste erzeugen - deshalb
skaliert es ueber die Breite und behaelt seine Hoehe nur als Obergrenze. */
.sidebar-brand img {
display: block;
width: 100%;
max-width: 136px;
max-width: 100%;
height: auto;
margin: 0 auto;
border-radius: 12px;
box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.35), 0 6px 22px rgba(201, 162, 39, 0.18);
max-height: 56px;
}
.sidebar-brand a { color: var(--gold); }
@ -150,7 +149,7 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
.mobile-topbar-brand img {
display: block;
height: 40px;
height: 32px;
width: auto;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View file

@ -5,6 +5,9 @@ require_permission('contributions.view');
$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();
@ -37,7 +40,7 @@ $showMyEntrySeparately = $myEntry !== null && !in_array((int) $myEntry['id'], $v
$hiddenCount = count($balances) - count($visibleBalances);
// Verlauf, optional nur fuer ein Mitglied (Klick auf eine Karte).
$filterUserId = isset($_GET['user']) ? (int) $_GET['user'] : null;
$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.
@ -66,23 +69,27 @@ $perPage = 20;
$totalAwards = contribution_award_count($filterUserId);
$pageCount = max(1, (int) ceil($totalAwards / $perPage));
$page = min($pageCount, max(1, (int) ($_GET['page'] ?? 1)));
$awards = contribution_awards($filterUserId, $perPage, ($page - 1) * $perPage);
$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) use ($currentUser, $canManage, $displayName): void {
$renderCard = static function (array $member) 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))) ?>">
<?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>
</a>
<?= $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>
@ -141,6 +148,7 @@ include __DIR__ . '/includes/header.php';
<?php endif; ?>
</div>
<?php if ($canSeeHistory): ?>
<div class="panel" id="verlauf">
<div class="contribution-head">
<h2>
@ -154,6 +162,19 @@ include __DIR__ . '/includes/header.php';
<?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 Beitragspunkte vergeben.</p>
<?php else: ?>
@ -239,5 +260,7 @@ include __DIR__ . '/includes/header.php';
<?php endif; ?>
</div>
<?php endif; ?>
<script src="/assets/js/contributions.js"></script>
<?php include __DIR__ . '/includes/footer.php'; ?>

View file

@ -109,11 +109,11 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
<button type="button" class="sidebar-toggle" aria-label="Menü öffnen" aria-expanded="false">
<?= icon('menu') ?>
</button>
<a href="/" class="mobile-topbar-brand"><img src="/assets/images/logo-wordmark.webp" alt="Lumina Ascendens" width="409" height="132"></a>
<a href="/" class="mobile-topbar-brand"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a>
</div>
<div class="sidebar-backdrop"></div>
<aside class="sidebar">
<div class="sidebar-brand"><a href="/"><img src="/assets/images/logo-lumina.webp" alt="Lumina Ascendens" width="400" height="400"></a></div>
<div class="sidebar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a></div>
<nav class="sidebar-nav">
<a href="/dashboard.php" class="sidebar-link<?= $isDashboardActive ? ' active' : '' ?>" title="Dashboard">
<?= icon('home') ?><span class="label">Dashboard</span>
@ -206,7 +206,7 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
<?php endforeach; ?>
<?php else: ?>
<header class="navbar">
<div class="navbar-brand"><a href="/"><img src="/assets/images/logo-wordmark.webp" alt="Lumina Ascendens" width="409" height="132"></a></div>
<div class="navbar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a></div>
<div class="navbar-user">
<?php if ($currentUser): ?>
<a href="/logout.php">Abmelden</a>

View file

@ -9,6 +9,13 @@ declare(strict_types=1);
// Einstellungen, die ueber admin/settings_action.php geaendert werden duerfen: Schluessel => Standardwert.
const SETTINGS_DEFAULTS = [
'discord_unlink_allowed' => '1',
'contributions_history_public' => '1',
];
// Wer eine Einstellung aendern darf und wohin es danach zurueckgeht.
const SETTINGS_ACCESS = [
'discord_unlink_allowed' => ['users.edit', '/admin/users.php'],
'contributions_history_public' => ['contributions.manage', '/contributions.php#verlauf'],
];
function setting_get(string $key): string
@ -34,6 +41,12 @@ function setting_set(string $key, string $value): void
->execute([$key, $value]);
}
/** Ist der Verlauf der Beitragspunkte fuer alle sichtbar oder nur fuer contributions.manage? */
function contributions_history_public(): bool
{
return setting_get('contributions_history_public') === '1';
}
/** Duerfen Mitglieder ihre Discord-Verknuepfung selbst loesen? */
function discord_unlink_allowed(): bool
{