Allow permanently deleting archived raids
Wires up the bot API's existing DELETE /api/raids/{id}/permanent
endpoint: archived raids now get an "Endgültig löschen" button next
to "Wiederherstellen" (raids.manage only), gated by a confirmation
dialog since it's irreversible - unlike the existing archive action,
which only soft-deletes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
08db95f3a3
commit
22a61d28be
3 changed files with 46 additions and 0 deletions
|
|
@ -122,6 +122,17 @@ function restore_raid(int $raidId): void
|
|||
raids_api_request('POST', '/' . $raidId . '/restore');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loescht einen Raid ENDGUELTIG (keine Historie, keine Wiederherstellung), im
|
||||
* Gegensatz zu archive_raid(). Nur fuer bereits archivierte Raids gedacht.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
function delete_raid_permanently(int $raidId): void
|
||||
{
|
||||
raids_api_request('DELETE', '/' . $raidId . '/permanent');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $group Feste Zielgruppe (0 = Ersatzbank) oder null, damit der Bot
|
||||
* automatisch nach Rollen-Caps zuteilt.
|
||||
|
|
|
|||
29
raid_delete_action.php
Normal file
29
raid_delete_action.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/raids_api.php';
|
||||
require_permission('raids.manage');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/raids.php');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
$status = (string) ($_POST['status'] ?? 'archived');
|
||||
if (!in_array($status, RAID_STATUSES, true)) {
|
||||
$status = 'archived';
|
||||
}
|
||||
$redirectTo = '/raids.php?status=' . urlencode($status);
|
||||
|
||||
$raidId = (int) ($_POST['raid_id'] ?? 0);
|
||||
if ($raidId <= 0) {
|
||||
redirect($redirectTo);
|
||||
}
|
||||
|
||||
try {
|
||||
delete_raid_permanently($raidId);
|
||||
set_flash('success', 'Raid wurde endgültig gelöscht.');
|
||||
} catch (Throwable $e) {
|
||||
set_flash('error', 'Löschen fehlgeschlagen: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
redirect($redirectTo);
|
||||
|
|
@ -173,6 +173,12 @@ include __DIR__ . '/includes/header.php';
|
|||
<input type="hidden" name="status" value="<?= e($status) ?>">
|
||||
<button type="submit" class="text-button">Wiederherstellen</button>
|
||||
</form>
|
||||
<form method="post" action="/raid_delete_action.php" class="inline-form" onsubmit="return confirm('Diesen Raid wirklich ENDGÜLTIG löschen? Das kann nicht rückgängig gemacht werden.');">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="raid_id" value="<?= $raidId ?>">
|
||||
<input type="hidden" name="status" value="<?= e($status) ?>">
|
||||
<button type="submit" class="text-button">Endgültig löschen</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<form method="post" action="/raid_archive.php" class="inline-form" onsubmit="return confirm('Diesen Raid wirklich archivieren?');">
|
||||
<?= csrf_field() ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue