Roles at the default weight (1) are no longer listed - only roles with
an explicit, non-default point value show up, each editable/removable
inline. A new green "+ Rolle hinzufuegen" button opens a two-step popup:
pick one or more still-unconfigured roles, then set a single point
value applied to all of them at once (new report_action.php action
add_weights). Fixed two CSS specificity bugs while building this
(input[type=text] beating a plain class on width, and the generic
form{flex-direction:column} rule leaking into the inline edit row).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
83 lines
3.3 KiB
PHP
83 lines
3.3 KiB
PHP
<?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') {
|
|
// Bearbeiten/Entfernen einzelner bereits konfigurierter Rollen (siehe role-weight-list) -
|
|
// "Entfernen" schickt hier einfach wieder den Default-Wert 1 mit.
|
|
$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.');
|
|
} elseif ($action === 'add_weights') {
|
|
// "Rolle hinzufügen"-Popup: eine oder mehrere neue Rollen bekommen denselben Punktwert.
|
|
$roleIds = is_array($_POST['role_ids'] ?? null) ? array_map('intval', $_POST['role_ids']) : [];
|
|
$points = (int) ($_POST['points'] ?? 1);
|
|
$roleIds = array_values(array_filter($roleIds, fn ($id) => $id > 0));
|
|
|
|
if (empty($roleIds)) {
|
|
set_flash('error', 'Bitte mindestens eine Rolle auswählen.');
|
|
redirect('/reports.php');
|
|
}
|
|
if ($points < 0) {
|
|
set_flash('error', 'Der Punktwert darf nicht negativ sein.');
|
|
redirect('/reports.php');
|
|
}
|
|
|
|
foreach ($roleIds as $roleId) {
|
|
set_report_weight($roleId, $points);
|
|
}
|
|
set_flash('success', 'Rollen-Gewichtung wurde hinzugefügt.');
|
|
}
|
|
} catch (Throwable $e) {
|
|
set_flash('error', 'Aktion fehlgeschlagen: ' . $e->getMessage());
|
|
}
|
|
|
|
redirect('/reports.php');
|