- 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>
54 lines
2.1 KiB
PHP
54 lines
2.1 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);
|
||
$premadeId = (int) ($input['premade_id'] ?? 0);
|
||
$group = (int) ($input['group'] ?? 0);
|
||
|
||
if ($raidId <= 0 || $premadeId <= 0 || $group <= 0) {
|
||
json_response(false, 'Bitte Premade und Zielgruppe auswählen.');
|
||
}
|
||
// Die Leitung in jeden Raid, der Raid-Lead in seinen eigenen
|
||
if (!raid_can_manage($raidId)) {
|
||
http_response_code(403);
|
||
json_response(false, 'In diesen Raid darfst du keine Premade einladen.');
|
||
}
|
||
|
||
try {
|
||
// Name und Mitglieder der Premade sowie der Gruppenname fuers Audit-Log (vor dem Umbenennen)
|
||
$premadeName = '#' . $premadeId;
|
||
$premadeMembers = [];
|
||
$raidBefore = null;
|
||
try {
|
||
foreach (fetch_premades() as $p) {
|
||
if ((int) ($p['id'] ?? 0) === $premadeId) {
|
||
$premadeName = (string) ($p['name'] ?? $premadeName);
|
||
foreach ($p['members'] ?? [] as $m) {
|
||
if (($m['status'] ?? '') === 'accepted') {
|
||
$premadeMembers[] = (string) ($m['name'] ?? admin_log_discord_name((string) ($m['user_id'] ?? '')));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$raidBefore = fetch_raid_by_id($raidId);
|
||
} catch (Throwable $e) {
|
||
// nur fuers Log
|
||
}
|
||
$count = invite_premade($raidId, $premadeId, $group);
|
||
admin_log('🤝 Premade zum Raid eingeladen', [
|
||
'Raid' => admin_log_raid($raidId),
|
||
'Premade' => $premadeName,
|
||
'Zielgruppe' => admin_log_raid_group($raidBefore, $group) . ' – umbenannt und gesperrt',
|
||
'Eingeladen' => $count . ' Mitglied(er) per DM',
|
||
'Mitglieder' => implode(', ', $premadeMembers),
|
||
]);
|
||
json_response(true, $count . ' Mitglied(er) wurden per DM eingeladen, die Gruppe ist jetzt gesperrt.');
|
||
} catch (Throwable $e) {
|
||
json_response(false, 'Einladen fehlgeschlagen: ' . $e->getMessage());
|
||
}
|