The bot (Aion2_RaidPlaner, deployed 2026-09-25) has no slash commands any more. Raids,
premades, events, activity checks and reports are created and managed only here; in Discord
members sign up for raids, answer invitations and activity checks and report players.
- Raid signup works the same in Discord and here: the bot assigns the group (perform_signup),
the website only sends the wish (raid_signup(..., $wish)) and shows the reason when it did
not fit (locked, role full, raid full). raid_wish_is_sensible() and the role constants are
gone. Declining ("Abmelden") now keeps the player under "Abgemeldet" (raid_decline, new bot
endpoint .../decline) like in Discord; the raid card shows "Du hast dich abgemeldet" with
"Doch anmelden". Class input is checked against AION_CLASSES.
- The Discord message shows the raid lead and the Lumipunkte: raid_create_action/raid_edit_action
send lead_id/lead_name/points_text, raid_sync_extras() on raids.php pushes them for raids
where the bot is missing them (at most 3 per page view, follows changed raid IDs).
- bot_api.php?action=member: main class (profile choice) and whether the person has an
(active) account - the bot preselects the class and hints that Lumipunkte need an account.
- New page Verwaltung -> Discord-Bot (admin/bot.php, includes/discord_bot.php, permission
bot.manage, on update granted to groups with raids.manage; schema 53): raid, log and report
channel, post the premade overview (updates itself) and the report panel (the bot replaces
the previous one), resync all raid messages (reposted raids move their settings via
raid_rename_id). Audit area "Discord-Bot", sidebar entry with a new bot icon.
- Reports: after picking a player in the filter, delete all of their reports at once
(DELETE /api/reports/user/{id}), which also lifts the auto-mute.
- Calendar and raid logs no longer count declined players as signed up / on the bench.
- Texts that mentioned bot commands (events, activity check, config example, README) updated;
privacy policy mentions the main-class lookup and that declines stay visible. Patch notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
158 lines
6.9 KiB
PHP
158 lines
6.9 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'] ?? '');
|
|
|
|
/** Wer wen gemeldet hat - fuer den Discord-Log (vor dem Loeschen abfragen). */
|
|
function report_log_label(int $reportId): string
|
|
{
|
|
try {
|
|
foreach (fetch_reports(true) as $report) {
|
|
if ((int) ($report['report_id'] ?? 0) === $reportId) {
|
|
return '#' . $reportId . ': ' . admin_log_discord($report['reported_id'] ?? '', (string) ($report['reported_name'] ?? ''))
|
|
. ', gemeldet von ' . admin_log_discord($report['reporter_id'] ?? '', (string) ($report['reporter_name'] ?? ''));
|
|
}
|
|
}
|
|
} catch (Throwable $e) {
|
|
// nur fuer den Log
|
|
}
|
|
return '#' . $reportId;
|
|
}
|
|
|
|
/** Rollen-IDs als Discord-Erwaehnungen. */
|
|
function report_log_roles(array $roleIds): string
|
|
{
|
|
return implode(', ', array_map(static fn ($id) => '<@&' . (int) $id . '>', $roleIds));
|
|
}
|
|
|
|
try {
|
|
if ($action === 'delete') {
|
|
$reportId = (int) ($_POST['report_id'] ?? 0);
|
|
if ($reportId <= 0) {
|
|
set_flash('error', 'Ungültiger Report.');
|
|
redirect('/reports.php');
|
|
}
|
|
$reportLabel = report_log_label($reportId);
|
|
delete_report($reportId);
|
|
admin_log('🗑️ Report gelöscht', ['Report' => $reportLabel], 'danger');
|
|
set_flash('success', 'Report wurde gelöscht.');
|
|
} elseif ($action === 'clear_user') {
|
|
$reportedId = (int) ($_POST['reported_id'] ?? 0);
|
|
if ($reportedId <= 0) {
|
|
set_flash('error', 'Ungültiger Spieler.');
|
|
redirect('/reports.php');
|
|
}
|
|
$count = 0;
|
|
$name = '';
|
|
foreach (fetch_reports(true) as $report) {
|
|
if ((int) ($report['reported_id'] ?? 0) === $reportedId) {
|
|
$count++;
|
|
$name = (string) ($report['reported_name'] ?? '');
|
|
}
|
|
}
|
|
clear_user_reports($reportedId);
|
|
admin_log('🗑️ Alle Reports eines Spielers gelöscht', [
|
|
'Spieler' => admin_log_discord($reportedId, $name),
|
|
'Reports' => (string) $count,
|
|
], 'danger');
|
|
set_flash('success', 'Alle Reports gegen diesen Spieler wurden gelöscht, ein Auto-Mute ist aufgehoben.');
|
|
} 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');
|
|
admin_log($action === 'archive' ? '📦 Report archiviert' : '♻️ Report wiederhergestellt',
|
|
['Report' => report_log_label($reportId)], $action === 'archive' ? 'warning' : 'success');
|
|
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);
|
|
admin_log('⚙️ Mute-Schwelle geändert', ['Neue Schwelle' => $threshold . ' Punkte']);
|
|
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'] : [];
|
|
$changedWeights = [];
|
|
foreach ($weights as $roleId => $points) {
|
|
$roleId = (int) $roleId;
|
|
$points = (int) $points;
|
|
if ($roleId <= 0 || $points < 0) {
|
|
continue;
|
|
}
|
|
set_report_weight($roleId, $points);
|
|
$changedWeights[] = '<@&' . $roleId . '>: ' . $points . ($points === 1 ? ' (Standard)' : '') . ' Pkt.';
|
|
}
|
|
admin_log('⚙️ Report-Gewichtung geändert', ['Rollen' => implode("\n", $changedWeights)]);
|
|
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);
|
|
}
|
|
admin_log('⚙️ Report-Gewichtung hinzugefügt', ['Rollen' => report_log_roles($roleIds), 'Punkte pro Report' => $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);
|
|
admin_log('⚙️ Timeout-Ausnahme entfernt', ['Rolle' => report_log_roles([$roleId])], 'warning');
|
|
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);
|
|
}
|
|
admin_log('⚙️ Rollen von Timeouts ausgeschlossen', ['Rollen' => report_log_roles($roleIds)]);
|
|
set_flash('success', 'Rollen wurden von der Timeout-Mechanik ausgeschlossen.');
|
|
}
|
|
} catch (Throwable $e) {
|
|
set_flash('error', 'Aktion fehlgeschlagen: ' . $e->getMessage());
|
|
}
|
|
|
|
redirect('/reports.php');
|