LuminaWebsite/raid_archive.php
Maaxxs 2623236173 Members create raids as raid lead; points, restore and deletion stay with the leadership
- New permission raids.create (granted on update to every group that has raids.view): whoever
  creates a raid on the website becomes its raid lead (raid_settings.lead_user_id, schema v49),
  shown with a crown on the raid card and in the signup list.
- The raid lead manages their own raid: edit, move players, invite premades, fill in the attendance
  list and archive it. Restoring, deleting for good and the Lumipunkte stay with the leadership
  (raids.manage, raids.points). Checked on the server via raid_can_manage() in every raid action.
- Raids created by a member without raids.points bring no automatic points (0/0) until the
  leadership sets them when editing; raids of the leadership keep the fixed +1.
- The attendance reminder of the bot (bot_api.php) goes to the raid lead, even if not signed up;
  raids without a lead (created in Discord) remind the signed-up raids.manage members as before.
- Core permission descriptions are cut to the 255 characters of the column when synced - a longer
  one made the schema sync throw on every request (found while testing this change).
- Privacy policy (raid lead is visible to all), data export, patch notes, README and the tour updated;
  raid_created_at() folded into raid_posted_at().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 00:04:53 +02:00

53 lines
1.6 KiB
PHP

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_once __DIR__ . '/includes/raid_attendance.php';
require_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/raids.php');
}
verify_csrf();
$status = (string) ($_POST['status'] ?? 'active');
if (!in_array($status, RAID_STATUSES, true)) {
$status = 'active';
}
$redirectTo = '/raids.php?status=' . urlencode($status);
$raidId = (int) ($_POST['raid_id'] ?? 0);
if ($raidId <= 0) {
redirect($redirectTo);
}
// Archivieren darf die Leitung jeden Raid, der Raid-Lead seinen eigenen - wiederherstellen nur die Leitung
if (!raid_can_manage($raidId)) {
set_flash('error', 'Diesen Raid darfst du nicht archivieren.');
redirect($redirectTo);
}
try {
try {
$raidBefore = fetch_raid_by_id($raidId); // nur fuers Audit-Log
} catch (Throwable $e) {
$raidBefore = null;
}
raid_settings_ensure_defaults([$raidId]); // fester Punkt auch fuer im Discord erstellte Raids
archive_raid($raidId);
set_flash('success', 'Raid wurde archiviert.');
$autoMessages = [];
foreach (raid_process_auto_points() as $autoMessage) {
if ($autoMessage !== '') {
set_flash('info', $autoMessage);
$autoMessages[] = $autoMessage;
}
}
admin_log('📦 Raid archiviert', [
'Raid' => admin_log_raid($raidId),
'Anmeldungen' => admin_log_raid_signups($raidBefore),
'Lumipunkte' => implode("\n", $autoMessages),
], 'warning');
} catch (Throwable $e) {
set_flash('error', 'Archivieren fehlgeschlagen: ' . $e->getMessage());
}
redirect($redirectTo);