- Raids: "Max. Spieler" only whole numbers up to groups x 5 (max. 10 groups / 50), gearscore only a number; fixed +1 Lumipunkt per participation, other values only with the new raids.points permission; pick an existing premade per group when creating a raid; unchanged legacy values no longer block editing - Raid page updates itself every 15 s while visible (raids_live.php, cards rendered by includes/raid_card.php), open editors and confirm dialogs are kept - Restore takes the new raid_id from the bot (archived messages are now deleted in Discord) and moves settings, attendance and awards; website signups send the server display name - Premades: dissolve by leadership needs a reason, lead gets DMs on join/assign/decline/remove (source/actor_id sent to the bot), transfer picker skips players who already lead a group, website accept keeps the one-group rule, no commas in names - Site-wide Lumina dialog (assets/js/confirm-dialog.js) replaces confirm/prompt/alert via data-confirm; error flashes are a dialog you confirm with OK - Calendar: audience per entry (all / leadership takes part / internal) with the new calendar.leadership permission; day cells list all entries and scroll - Gear planner: main-hand picker filtered by the set's class, mismatches marked, "keine Klasse" option, link to an external skill/Daevanion plan per set - Map: correct kisk icons (Elyos on Verteron/Abyss, Altgard fixed), per-map max zoom and bounded panning, German texts, data source note - Tactics: toolbar as a uniform grid, whole-tactic copy, automatic versions with restore and a 90-day trash, official tactics protected - Global thin gold scrollbars, readable hover colours, "Sedes Luminis" spelling, patch notes and README, schema version 34 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.9 KiB
PHP
77 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
* Rueckkanal fuer den Discord-Bot (cogs/attendance.py im Bot).
|
|
*
|
|
* Wenn die Uhrzeit eines Raids erreicht ist, fragt der Bot hier nach, wer von den Angemeldeten
|
|
* eine Erinnerung zur Anwesenheitsliste bekommen soll: alle mit einem aktiven Website-Konto und
|
|
* der Berechtigung raids.manage. Die Discord-PN schickt der Bot selbst.
|
|
*
|
|
* GET /bot_api.php?action=attendance_recipients&raid_id=...&discord_ids=1,2,3
|
|
* Header: X-Bot-Key: <config.php bot_callback.key>
|
|
*/
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/raid_attendance.php';
|
|
|
|
header('Content-Type: application/json; charset=UTF-8');
|
|
|
|
function bot_api_reply(int $status, array $data): void
|
|
{
|
|
http_response_code($status);
|
|
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
exit;
|
|
}
|
|
|
|
$expectedKey = bot_callback_key();
|
|
if ($expectedKey === null) {
|
|
bot_api_reply(503, ['status' => 'error', 'message' => 'bot_callback.key ist in config.php nicht eingetragen.']);
|
|
}
|
|
$givenKey = (string) ($_SERVER['HTTP_X_BOT_KEY'] ?? '');
|
|
if (!hash_equals($expectedKey, $givenKey)) {
|
|
bot_api_reply(403, ['status' => 'error', 'message' => 'Ungültiger Schlüssel.']);
|
|
}
|
|
|
|
$action = (string) ($_GET['action'] ?? '');
|
|
if ($action !== 'attendance_recipients') {
|
|
bot_api_reply(400, ['status' => 'error', 'message' => 'Unbekannte Aktion.']);
|
|
}
|
|
|
|
$raidId = (string) ($_GET['raid_id'] ?? '');
|
|
if (!ctype_digit($raidId)) {
|
|
bot_api_reply(400, ['status' => 'error', 'message' => 'raid_id fehlt.']);
|
|
}
|
|
|
|
$discordIds = array_values(array_filter(
|
|
array_map('trim', explode(',', (string) ($_GET['discord_ids'] ?? ''))),
|
|
static fn (string $id): bool => $id !== '' && ctype_digit($id)
|
|
));
|
|
|
|
$recipients = [];
|
|
if (!empty($discordIds)) {
|
|
$placeholders = implode(',', array_fill(0, count($discordIds), '?'));
|
|
$stmt = db()->prepare(
|
|
"SELECT DISTINCT u.discord_id FROM users u
|
|
WHERE u.status = 'active' AND u.discord_id IN ($placeholders)
|
|
AND (u.is_admin = 1 OR EXISTS (
|
|
SELECT 1 FROM user_roles ur
|
|
JOIN role_permissions rp ON rp.role_id = ur.role_id
|
|
JOIN permissions p ON p.id = rp.permission_id
|
|
WHERE ur.user_id = u.id AND p.`key` = 'raids.manage'
|
|
))"
|
|
);
|
|
$stmt->execute($discordIds);
|
|
$recipients = array_map('strval', $stmt->fetchAll(PDO::FETCH_COLUMN));
|
|
}
|
|
|
|
// Raidbeginn: Einstellungen (fester Punkt) auch fuer im Discord erstellte Raids anlegen.
|
|
raid_settings_ensure_defaults([(int) $raidId]);
|
|
$settings = raid_settings_get((int) $raidId);
|
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
$host = (string) ($_SERVER['HTTP_HOST'] ?? '');
|
|
|
|
bot_api_reply(200, [
|
|
'status' => 'success',
|
|
'recipients' => $recipients,
|
|
// Schon kontrolliert (z.B. vor Raidbeginn)? Dann braucht es keine Erinnerung mehr.
|
|
'checked' => $settings['attendance_checked_at'] !== null,
|
|
'url' => $scheme . '://' . $host . '/raid_attendance.php?raid=' . $raidId,
|
|
]);
|