LuminaWebsite/report_action.php
Maaxxs 8588c2fd58 Reports: exclude roles from auto-mute; wire up new landscape backgrounds
Adds a per-role opt-out from the auto-mute mechanic (e.g. Gildenleitung):
members with an excluded role keep accumulating report points normally,
but the timeout itself is skipped, same as the existing server-owner
exemption. Configured the same way as the point weighting - a list of
currently-excluded roles plus a green "+ Rolle ausschliessen" popup for
adding more. Split reports.js into two independently-guarded modal
initializers so the weights and exclusions popups do not depend on each
other being present.

Also wires in the 7 new landscape images as page backgrounds
(web-optimized JPEGs generated via Pillow): raids gets landscape6 as
requested, and the rest are split out for Premades, Mitglieder,
Berechtigungsgruppen, Reports and the logged-out login/homepage view,
which previously had no themed background at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-20 02:27:37 +02:00

105 lines
4.2 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.');
} elseif ($action === 'remove_exclusion') {
$roleId = (int) ($_POST['role_id'] ?? 0);
if ($roleId <= 0) {
set_flash('error', 'Ungültige Rolle.');
redirect('/reports.php');
}
set_mute_exclusion($roleId, false);
set_flash('success', 'Ausnahme wurde entfernt.');
} elseif ($action === 'add_exclusions') {
// "Rolle ausschließen"-Popup: eine oder mehrere Rollen werden auf einmal ausgeschlossen.
$roleIds = is_array($_POST['role_ids'] ?? null) ? array_map('intval', $_POST['role_ids']) : [];
$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');
}
foreach ($roleIds as $roleId) {
set_mute_exclusion($roleId, true);
}
set_flash('success', 'Rollen wurden von der Timeout-Mechanik ausgeschlossen.');
}
} catch (Throwable $e) {
set_flash('error', 'Aktion fehlgeschlagen: ' . $e->getMessage());
}
redirect('/reports.php');