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>
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
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);
|
|
if ($raidId <= 0) {
|
|
json_response(false, 'Ungültige Anfrage.');
|
|
}
|
|
|
|
$fields = [];
|
|
foreach (['title', 'date_raw', 'requirements', 'gearscore', 'group_names'] as $key) {
|
|
if (isset($input[$key]) && trim((string) $input[$key]) !== '') {
|
|
$fields[$key] = trim((string) $input[$key]);
|
|
}
|
|
}
|
|
if (isset($input['max_slots']) && is_numeric($input['max_slots'])) {
|
|
$fields['max_slots'] = (int) $input['max_slots'];
|
|
}
|
|
if (isset($input['locked_groups']) && is_array($input['locked_groups'])) {
|
|
$fields['locked_groups'] = array_values(array_map('intval', $input['locked_groups']));
|
|
}
|
|
|
|
if (empty($fields)) {
|
|
json_response(false, 'Keine Änderungen übermittelt.');
|
|
}
|
|
|
|
try {
|
|
update_raid($raidId, $fields);
|
|
json_response(true, 'Raid wurde aktualisiert.');
|
|
} catch (Throwable $e) {
|
|
json_response(false, 'Speichern fehlgeschlagen: ' . $e->getMessage());
|
|
}
|