- 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>
52 lines
1.8 KiB
PHP
52 lines
1.8 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();
|
|
|
|
$input = read_json_body();
|
|
verify_csrf_token($input['csrf_token'] ?? '');
|
|
|
|
$raidId = (int) ($input['raid_id'] ?? 0);
|
|
$discordId = (int) ($input['user_id'] ?? 0);
|
|
$group = $input['group'] ?? null;
|
|
|
|
if ($raidId <= 0 || $discordId <= 0 || !is_numeric($group) || (int) $group < 0) {
|
|
json_response(false, 'Ungültige Anfrage.');
|
|
}
|
|
// Die Leitung in jedem Raid, der Raid-Lead in seinem eigenen
|
|
if (!raid_can_manage($raidId)) {
|
|
http_response_code(403);
|
|
json_response(false, 'In diesem Raid darfst du niemanden verschieben.');
|
|
}
|
|
|
|
$group = (int) $group;
|
|
|
|
try {
|
|
$raid = fetch_raid_by_id($raidId);
|
|
// Bisherige Gruppe und Klasse fuers Audit-Log
|
|
$signup = null;
|
|
foreach ((array) ($raid['signups'] ?? []) as $row) {
|
|
if ((int) ($row['user_id'] ?? 0) === $discordId) {
|
|
$signup = $row;
|
|
}
|
|
}
|
|
if ($group > 0) {
|
|
$lockedGroups = is_array($raid['locked_groups'] ?? null) ? array_map('intval', $raid['locked_groups']) : [];
|
|
if (in_array($group, $lockedGroups, true)) {
|
|
json_response(false, 'Diese Gruppe ist gesperrt.');
|
|
}
|
|
}
|
|
|
|
move_signup($raidId, $discordId, $group);
|
|
admin_log('↔️ Spieler im Raid verschoben', [
|
|
'Raid' => admin_log_raid($raidId),
|
|
'Spieler' => admin_log_discord($discordId, (string) ($signup['name'] ?? '')),
|
|
'Klasse' => (string) ($signup['class'] ?? ''),
|
|
'Von' => $signup !== null ? admin_log_raid_group($raid, (int) ($signup['group'] ?? 0)) : '',
|
|
'Nach' => admin_log_raid_group($raid, $group),
|
|
]);
|
|
json_response(true, 'Spieler wurde verschoben.');
|
|
} catch (Throwable $e) {
|
|
json_response(false, 'Verschieben fehlgeschlagen: ' . $e->getMessage());
|
|
}
|