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>
62 lines
2.3 KiB
PHP
62 lines
2.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') {
|
|
$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');
|