LuminaWebsite/raid_move_action.php
Maaxxs fea0cc3a91 Overhaul raid signup/management to match the Discord bot's full feature set
Signup is now a single "Anmelden" button that opens a class-icon
picker + optional group choice. A new raid_wish_is_sensible() mirrors
the bot's exact role-cap algorithm (Tank/Heal 1, DPS 3 per 5-player
group, ROLE_MAPPING copied from teamplaner.py) to decide server-side
whether the requested group is honored or the request falls back to
the bot's own auto-assignment - with a message telling the member to
ping the raid lead if they wanted something specific. Verified the
cap logic with 7 synthetic cases (own-signup exclusion, full group,
role caps, bench always allowed) before wiring it up.

Admins get a per-raid edit-mode toggle (pencil icon) that reveals:
inline raid editing (title/date/requirements/gearscore/groups/slots/
group locks) via PATCH, a premade-invite mini-form via the new
premades endpoint, and native HTML5 drag-and-drop to move a signup
between groups/bench via PATCH .../signup/{user_id}.

New pieces: includes/raids_api.php gained move_signup(), update_raid(),
invite_premade(), fetch_premades(), fetch_raid_by_id() and the wish-
sensibility check; four new JSON action endpoints (raid_signup_action,
raid_move_action, raid_edit_action, raid_premade_invite_action) reusing
the session CSRF token via a new verify_csrf_token()/read_json_body()/
json_response() trio in functions.php; assets/js/raids.js drives the
modal, edit-mode, and drag-and-drop with plain fetch() (no framework).

Read-heavy parts (page render, class icons, signup-wish logic) verified
against real data/live API. Edit, move and premade-invite are NOT
tested against the live API yet since they'd mutate the real raid or
send real Discord DMs to guild members - flagging this for a
supervised live check before considering it fully verified.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-18 18:36:04 +02:00

22 lines
690 B
PHP

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_permission('raids.manage');
$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.');
}
try {
move_signup($raidId, $discordId, (int) $group);
json_response(true, 'Spieler wurde verschoben.');
} catch (Throwable $e) {
json_response(false, 'Verschieben fehlgeschlagen: ' . $e->getMessage());
}