Add Reports tab: view/delete/archive reports, points-based mute weighting

New reports.php lists incoming Discord reports (active/archived/all
filter) with delete and archive actions, gated by new reports.view/
reports.manage permissions. Auto-mute weighting is now configurable
from the same page: a settings panel lets admins set the mute point
threshold and a per-Discord-role point value (a report counts as many
points as the highest-weighted role its reporter holds, unconfigured
roles default to 1). Talks to the bot's extended reports API via new
helpers in includes/raids_api.php.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-20 02:05:21 +02:00
parent c8a1748ae5
commit 60661ef5fc
7 changed files with 527 additions and 1 deletions

View file

@ -182,6 +182,28 @@ Die Klassenangabe braucht eine Erweiterung der Bot-API/-Datenbank (`premade_memb
(Aion2_RaidPlaner), nicht dieses hier. Nach dem Deployen der Bot-Änderung muss der Bot-Prozess
neu gestartet werden, damit die neue Spalte/der neue Endpunkt aktiv werden.
### Reports
Zeigt die über den Discord-Bot eingegangenen Spieler-Meldungen (Reports) mit Filter nach
aktiv/archiviert/alle. Reports können hier gelöscht (endgültig entfernt) oder archiviert werden -
archivierte Reports bleiben einsehbar, zählen aber nicht mehr für den Auto-Mute.
Der Auto-Mute richtet sich nicht mehr nach der reinen Anzahl an Reports, sondern nach
Report-**Punkten**: jeder Report zählt so viele Punkte, wie die höchste Discord-Rolle des Melders
im Einstellungs-Panel dieser Seite hinterlegt hat (unkonfigurierte Rollen zählen 1 Punkt). Dort
lässt sich auch die Punkte-Schwelle für den Auto-Mute einstellen (vorher fix 10 Reports im
Bot-Code).
Neue Berechtigungen `reports.view` (Reports einsehen) und `reports.manage` (löschen/archivieren,
Gewichtung/Schwelle einstellen) müssen bei einem vor diesem Update installierten Account
nachträglich unter Berechtigungsgruppen angelegt/zugewiesen werden.
Das Feature braucht eine Erweiterung der Bot-API/-Datenbank (Punkte-/Archiv-Spalten an `reports`,
neue Tabelle `role_report_weights`, neue Endpunkte `/api/reports/weights` und `PATCH
/api/reports/{id}`, `mute_threshold` in `/api/settings/{guild_id}`) - das ist Teil des separaten
Bot-Repos (Aion2_RaidPlaner), nicht dieses hier. Nach dem Deployen der Bot-Änderung muss der
Bot-Prozess neu gestartet werden.
### Mitgliederliste
Zeigt alle aktiven Gildenmitglieder mit Profilbild und Rollen. Unter Berechtigungsgruppen ->

View file

@ -124,6 +124,7 @@ function icon(string $name): string
'trash' => '<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/>',
'crown' => '<path d="M4 8l4 3 4-6 4 6 4-3-2 9H6z"/><path d="M6 20h12"/>',
'menu' => '<line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="17" x2="20" y2="17"/>',
'flag' => '<path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" y1="22" x2="4" y2="15"/>',
];
$path = $paths[$name] ?? '';

View file

@ -6,7 +6,8 @@ $canManageRoles = $currentUser && user_has_permission('roles.manage');
$canViewRaids = $currentUser && user_has_permission('raids.view');
$canViewPremades = $currentUser && user_has_permission('premades.view');
$canViewMembers = $currentUser && user_has_permission('members.view');
$showAdminMenu = $canViewUsers || $canManageRoles;
$canViewReports = $currentUser && user_has_permission('reports.view');
$showAdminMenu = $canViewUsers || $canManageRoles || $canViewReports;
$currentScript = basename((string) ($_SERVER['SCRIPT_NAME'] ?? ''));
$isDashboardActive = $currentScript === 'dashboard.php';
@ -14,6 +15,7 @@ $isProfileActive = $currentScript === 'profile.php';
$isRaidsActive = $currentScript === 'raids.php';
$isPremadesActive = $currentScript === 'premades.php';
$isMembersActive = $currentScript === 'members.php';
$isReportsActive = $currentScript === 'reports.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);
@ -30,6 +32,7 @@ $pageBackgrounds = [
'roles.php' => 'bg-admin',
'role_form.php' => 'bg-admin',
'role_delete.php' => 'bg-admin',
'reports.php' => 'bg-admin',
];
$pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
?>
@ -97,6 +100,11 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
<?= icon('shield') ?><span class="label">Berechtigungsgruppen</span>
</a>
<?php endif; ?>
<?php if ($canViewReports): ?>
<a href="/reports.php" class="sidebar-link<?= $isReportsActive ? ' active' : '' ?>" title="Reports">
<?= icon('flag') ?><span class="label">Reports</span>
</a>
<?php endif; ?>
<?php endif; ?>
</nav>
<div class="sidebar-footer">

View file

@ -17,6 +17,8 @@ const CORE_PERMISSIONS = [
['key' => 'premades.view', 'description' => 'Premade-Gruppen einsehen'],
['key' => 'premades.manage', 'description' => 'Alle Premade-Gruppen verwalten (nicht nur die eigene)'],
['key' => 'members.view', 'description' => 'Mitgliederliste einsehen'],
['key' => 'reports.view', 'description' => 'Eingegangene Reports einsehen'],
['key' => 'reports.manage', 'description' => 'Reports löschen/archivieren und die Punkte-Gewichtung verwalten'],
];
function user_has_permission(string $key): bool

View file

@ -511,3 +511,215 @@ function raid_wish_is_sensible(array $signups, int $discordId, string $className
return $counts[$role] < RAID_ROLE_CAPS[$role];
}
/**
* Discord-Server-ID aus config.php - identisch zur Quelle, die create_raid() fuer die
* Raid-Erstellung nutzt. Reports/Einstellungen sind (wie Raids/Premades) an genau den einen
* dort konfigurierten Server gebunden.
*
* @throws RuntimeException
*/
function reports_guild_id(): int
{
$configPath = __DIR__ . '/../config.php';
if (!file_exists($configPath)) {
throw new RuntimeException('Konfigurationsdatei fehlt.');
}
$config = require $configPath;
$guildId = $config['raids_api']['guild_id'] ?? null;
if (!$guildId) {
throw new RuntimeException('Reports sind nicht konfiguriert (config.php: raids_api.guild_id fehlt).');
}
return (int) $guildId;
}
/**
* Fuehrt einen Request gegen die Reports-API aus (/api/reports/...) - analog zu
* premades_api_request(), nur mit Unterstuetzung fuer Query-Parameter (z.B. guild_id).
*
* @param array<string, mixed> $queryParams
* @param array<string, mixed>|null $jsonBody
* @return array<string, mixed>
* @throws RuntimeException
*/
function reports_api_request(string $method, string $path = '', array $queryParams = [], ?array $jsonBody = null): array
{
if (!function_exists('curl_init')) {
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
}
$config = raids_api_config();
// /api/reports liegt eine Ebene ueber /api/raids.
$base = preg_replace('#/raids$#', '', $config['url']);
$url = $base . '/reports' . $path;
if (!empty($queryParams)) {
$url .= '?' . http_build_query($queryParams);
}
$headers = ['X-API-Key: ' . $config['key']];
$ch = curl_init($url);
$options = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => true,
];
if ($jsonBody !== null) {
$headers[] = 'Content-Type: application/json';
$options[CURLOPT_POSTFIELDS] = json_encode($jsonBody, JSON_UNESCAPED_UNICODE);
}
$options[CURLOPT_HTTPHEADER] = $headers;
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
if ($response === false) {
throw new RuntimeException('Verbindung zur Reports-API fehlgeschlagen: ' . $curlError);
}
$data = json_decode($response, true);
if ($httpCode < 200 || $httpCode >= 300) {
$detail = is_array($data) ? ($data['detail'] ?? '') : '';
$message = 'Reports-API antwortete mit Statuscode ' . $httpCode . '.';
if ($detail !== '') {
$message .= ' (' . $detail . ')';
}
throw new RuntimeException($message);
}
if (!is_array($data)) {
throw new RuntimeException('Unerwartetes Antwortformat der Reports-API.');
}
return $data;
}
/**
* @return array<int, array<string, mixed>>
* @throws RuntimeException
*/
function fetch_reports(bool $includeArchived = true): array
{
$data = reports_api_request('GET', '', ['guild_id' => reports_guild_id(), 'include_archived' => $includeArchived ? 'true' : 'false']);
if (($data['status'] ?? '') !== 'success' || !is_array($data['reports'] ?? null)) {
throw new RuntimeException('Unerwartetes Antwortformat der Reports-API.');
}
return $data['reports'];
}
/** @throws RuntimeException */
function delete_report(int $reportId): void
{
reports_api_request('DELETE', '/' . $reportId);
}
/** @throws RuntimeException */
function set_report_archived(int $reportId, bool $archived): void
{
reports_api_request('PATCH', '/' . $reportId, [], ['archived' => $archived]);
}
/**
* @return array<int, array<string, mixed>>
* @throws RuntimeException
*/
function fetch_report_weights(): array
{
$data = reports_api_request('GET', '/weights', ['guild_id' => reports_guild_id()]);
if (($data['status'] ?? '') !== 'success' || !is_array($data['roles'] ?? null)) {
throw new RuntimeException('Unerwartetes Antwortformat der Reports-API.');
}
return $data['roles'];
}
/** @throws RuntimeException */
function set_report_weight(int $roleId, int $points): void
{
reports_api_request('PATCH', '/weights/' . $roleId, [], ['guild_id' => reports_guild_id(), 'points' => $points]);
}
/**
* Liest/schreibt die Mute-Punkte-Schwelle ueber den generischen Server-Settings-Endpunkt des
* Bots (/api/settings/{guild_id}), der auch Log-/Report-/Raid-Kanal verwaltet - die Website
* nutzt davon bisher nur die Schwelle.
*
* @throws RuntimeException
*/
function fetch_mute_threshold(): int
{
if (!function_exists('curl_init')) {
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
}
$guildId = reports_guild_id();
$config = raids_api_config();
$base = preg_replace('#/raids$#', '', $config['url']);
$url = $base . '/settings/' . $guildId;
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . $config['key']],
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => true,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
if ($response === false) {
throw new RuntimeException('Verbindung zur Settings-API fehlgeschlagen: ' . $curlError);
}
$data = json_decode($response, true);
if ($httpCode < 200 || $httpCode >= 300 || !is_array($data)) {
throw new RuntimeException('Settings-API antwortete mit Statuscode ' . $httpCode . '.');
}
return (int) ($data['mute_threshold'] ?? 10);
}
/** @throws RuntimeException */
function set_mute_threshold(int $threshold): void
{
if (!function_exists('curl_init')) {
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
}
$guildId = reports_guild_id();
$config = raids_api_config();
$base = preg_replace('#/raids$#', '', $config['url']);
$url = $base . '/settings/' . $guildId;
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => ['X-API-Key: ' . $config['key'], 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['mute_threshold' => $threshold], JSON_UNESCAPED_UNICODE),
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => true,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
if ($response === false) {
throw new RuntimeException('Verbindung zur Settings-API fehlgeschlagen: ' . $curlError);
}
if ($httpCode < 200 || $httpCode >= 300) {
throw new RuntimeException('Settings-API antwortete mit Statuscode ' . $httpCode . '.');
}
}

62
report_action.php Normal file
View file

@ -0,0 +1,62 @@
<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_permission('reports.view');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/reports.php');
}
verify_csrf();
// Alle Aktionen hier sind reine Verwaltungsaktionen (loeschen/archivieren/Einstellungen) -
// anders als bei Premades gibt es kein "eigenes" Report, das man ohne reports.manage
// bearbeiten duerfte.
if (!user_has_permission('reports.manage')) {
set_flash('error', 'Du darfst Reports nicht verwalten.');
redirect('/reports.php');
}
$action = (string) ($_POST['action'] ?? '');
try {
if ($action === 'delete') {
$reportId = (int) ($_POST['report_id'] ?? 0);
if ($reportId <= 0) {
set_flash('error', 'Ungültiger Report.');
redirect('/reports.php');
}
delete_report($reportId);
set_flash('success', 'Report wurde gelöscht.');
} elseif ($action === 'archive' || $action === 'unarchive') {
$reportId = (int) ($_POST['report_id'] ?? 0);
if ($reportId <= 0) {
set_flash('error', 'Ungültiger Report.');
redirect('/reports.php');
}
set_report_archived($reportId, $action === 'archive');
set_flash('success', $action === 'archive' ? 'Report wurde archiviert.' : 'Report wurde wiederhergestellt.');
} elseif ($action === 'set_threshold') {
$threshold = (int) ($_POST['threshold'] ?? 0);
if ($threshold < 1) {
set_flash('error', 'Die Mute-Schwelle muss mindestens 1 sein.');
redirect('/reports.php');
}
set_mute_threshold($threshold);
set_flash('success', 'Mute-Schwelle wurde gespeichert.');
} elseif ($action === 'set_weights') {
$weights = is_array($_POST['weights'] ?? null) ? $_POST['weights'] : [];
foreach ($weights as $roleId => $points) {
$roleId = (int) $roleId;
$points = (int) $points;
if ($roleId <= 0 || $points < 0) {
continue;
}
set_report_weight($roleId, $points);
}
set_flash('success', 'Punktwerte wurden gespeichert.');
}
} catch (Throwable $e) {
set_flash('error', 'Aktion fehlgeschlagen: ' . $e->getMessage());
}
redirect('/reports.php');

219
reports.php Normal file
View file

@ -0,0 +1,219 @@
<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_permission('reports.view');
$canManageReports = user_has_permission('reports.manage');
$status = (string) ($_GET['status'] ?? 'active');
if (!in_array($status, ['active', 'archived', 'all'], true)) {
$status = 'active';
}
$allReports = [];
$apiError = null;
try {
$allReports = fetch_reports(true);
} catch (Throwable $e) {
$apiError = $e->getMessage();
}
$reports = array_values(array_filter($allReports, function (array $r) use ($status) {
$isArchived = !empty($r['archived']);
if ($status === 'active') {
return !$isArchived;
}
if ($status === 'archived') {
return $isArchived;
}
return true;
}));
// Discord-IDs aus den Reports auf verknuepfte Website-Accounts abbilden, damit echte
// Avatare/Anzeigenamen statt roher Discord-Tags gezeigt werden koennen (wie bei Premades).
$allDiscordIds = [];
foreach ($allReports as $r) {
$allDiscordIds[] = (int) ($r['reported_id'] ?? 0);
$allDiscordIds[] = (int) ($r['reporter_id'] ?? 0);
}
$allDiscordIds = array_values(array_unique(array_filter($allDiscordIds)));
$namesByDiscordId = [];
$linkedUsersByDiscordId = [];
if (!empty($allDiscordIds)) {
$placeholders = implode(',', array_fill(0, count($allDiscordIds), '?'));
$stmt = db()->prepare("SELECT id, discord_id, discord_username, display_name, avatar_filename FROM users WHERE discord_id IN ($placeholders)");
$stmt->execute($allDiscordIds);
foreach ($stmt->fetchAll() as $row) {
$name = $row['display_name'] !== '' ? $row['display_name'] : $row['discord_username'];
$namesByDiscordId[(int) $row['discord_id']] = $name;
$linkedUsersByDiscordId[(int) $row['discord_id']] = $row;
}
}
$statusLabels = ['active' => 'Aktiv', 'archived' => 'Archiviert', 'all' => 'Alle'];
$emptyLabels = [
'active' => 'Aktuell liegen keine aktiven Reports vor.',
'archived' => 'Es sind keine archivierten Reports vorhanden.',
'all' => 'Aktuell liegen keine Reports vor.',
];
// Einstellungen nur laden, wenn sie auch angezeigt werden - unnoetige API-Calls fuer reine
// Betrachter ohne reports.manage vermeiden.
$muteThreshold = null;
$roleWeights = [];
$settingsError = null;
if ($canManageReports) {
try {
$muteThreshold = fetch_mute_threshold();
$roleWeights = fetch_report_weights();
} catch (Throwable $e) {
$settingsError = $e->getMessage();
}
}
$pageTitle = 'Reports';
include __DIR__ . '/includes/header.php';
?>
<div class="panel">
<div class="raid-header">
<h1>Reports</h1>
</div>
<p class="text-muted">Eingegangene Spieler-Meldungen aus Discord. Reports zählen für den Auto-Mute Punkte statt einer reinen Anzahl - die Gewichtung lässt sich unten pro Rolle einstellen.</p>
<div class="filter-tabs">
<?php foreach ($statusLabels as $value => $label): ?>
<a href="/reports.php?status=<?= e($value) ?>" class="filter-tab<?= $status === $value ? ' active' : '' ?>"><?= e($label) ?></a>
<?php endforeach; ?>
</div>
</div>
<?php if ($apiError): ?>
<div class="panel">
<div class="flash flash-error">Reports konnten nicht geladen werden: <?= e($apiError) ?></div>
</div>
<?php elseif (empty($reports)): ?>
<div class="panel">
<p class="text-muted"><?= e($emptyLabels[$status]) ?></p>
</div>
<?php else: ?>
<div class="panel">
<div class="table-scroll">
<table>
<thead>
<tr>
<th>Gemeldet</th>
<th>Melder</th>
<th>Zeitpunkt</th>
<th>Grund</th>
<th>Punkte</th>
<th>Status</th>
<?php if ($canManageReports): ?><th></th><?php endif; ?>
</tr>
</thead>
<tbody>
<?php foreach ($reports as $report): ?>
<?php
$reportId = (int) ($report['report_id'] ?? 0);
$reportedId = (int) ($report['reported_id'] ?? 0);
$reporterId = (int) ($report['reporter_id'] ?? 0);
$reportedUser = premade_avatar_user($reportedId, $linkedUsersByDiscordId, (string) ($report['reported_name'] ?? ''));
$reportedName = premade_name_for($reportedId, $namesByDiscordId, (string) ($report['reported_name'] ?? ''));
$reporterName = premade_name_for($reporterId, $namesByDiscordId, (string) ($report['reporter_name'] ?? ''));
$incidentTime = (string) ($report['incident_time'] ?? '');
$reason = (string) ($report['reason'] ?? '');
$evidence = trim((string) ($report['evidence'] ?? ''));
$points = (int) ($report['points'] ?? 1);
$isArchived = !empty($report['archived']);
$timestamp = (int) ($report['timestamp'] ?? 0);
?>
<tr>
<td>
<div style="display:flex;align-items:center;gap:0.5rem;">
<?= avatar_html($reportedUser, 28) ?>
<strong><?= e($reportedName) ?></strong>
</div>
</td>
<td class="text-muted"><?= e($reporterName) ?></td>
<td class="text-muted">
<?= e($incidentTime) ?>
<?php if ($timestamp): ?><br><span style="font-size:0.75rem;">gemeldet: <?= date('d.m.Y H:i', $timestamp) ?></span><?php endif; ?>
</td>
<td style="max-width:320px;white-space:pre-wrap;">
<?= e($reason) ?>
<?php if ($evidence !== ''): ?><br><a href="<?= e($evidence) ?>" target="_blank" rel="noopener noreferrer">Beweis-Link</a><?php endif; ?>
</td>
<td><span class="badge"><?= $points ?> Pkt.</span></td>
<td>
<?php if ($isArchived): ?>
<span class="badge badge-disabled">Archiviert</span>
<?php else: ?>
<span class="badge badge-active">Aktiv</span>
<?php endif; ?>
</td>
<?php if ($canManageReports): ?>
<td class="actions">
<form method="post" action="/report_action.php" class="inline-form">
<?= csrf_field() ?>
<input type="hidden" name="report_id" value="<?= $reportId ?>">
<input type="hidden" name="action" value="<?= $isArchived ? 'unarchive' : 'archive' ?>">
<button type="submit" class="icon-button" title="<?= $isArchived ? 'Wiederherstellen' : 'Archivieren' ?>"><?= icon($isArchived ? 'restore' : 'archive') ?></button>
</form>
<form method="post" action="/report_action.php" class="inline-form" onsubmit="return confirm('Diesen Report wirklich endgültig löschen?');">
<?= csrf_field() ?>
<input type="hidden" name="report_id" value="<?= $reportId ?>">
<input type="hidden" name="action" value="delete">
<button type="submit" class="icon-button icon-button-danger" title="Löschen"><?= icon('trash') ?></button>
</form>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
<?php if ($canManageReports): ?>
<div class="panel">
<h2>Einstellungen</h2>
<?php if ($settingsError): ?>
<div class="flash flash-error">Einstellungen konnten nicht geladen werden: <?= e($settingsError) ?></div>
<?php else: ?>
<form method="post" action="/report_action.php" class="raid-premade-row" style="margin-bottom:1.5rem;">
<?= csrf_field() ?>
<input type="hidden" name="action" value="set_threshold">
<label style="margin:0;display:flex;align-items:center;gap:0.5rem;">
Mute-Schwelle (Punkte)
<input type="text" name="threshold" value="<?= (int) $muteThreshold ?>" style="width:100px;">
</label>
<button type="submit" class="button-secondary">Speichern</button>
</form>
<h3>Punktwert pro Discord-Rolle</h3>
<p class="text-muted">Ein Report zählt so viele Punkte, wie die höchste Rolle des Melders hier einträgt (unkonfigurierte Rollen zählen 1 Punkt).</p>
<?php if (empty($roleWeights)): ?>
<p class="text-muted">Keine Rollen gefunden - ist der Discord-Bot gerade online?</p>
<?php else: ?>
<form method="post" action="/report_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="set_weights">
<div class="checkbox-grid">
<?php foreach ($roleWeights as $role): ?>
<div>
<label>
<span style="color: <?= e((string) ($role['color'] ?? '')) ?>;">●</span>
<?= e((string) ($role['name'] ?? '')) ?>
<input type="text" name="weights[<?= (int) ($role['role_id'] ?? 0) ?>]" value="<?= (int) ($role['points'] ?? 1) ?>">
</label>
</div>
<?php endforeach; ?>
</div>
<button type="submit" style="margin-top:1rem;">Alle speichern</button>
</form>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php include __DIR__ . '/includes/footer.php'; ?>