LuminaWebsite/raid_signup_action.php
Maaxxs 5aaf44eaec Consilium Elyseum: allied legions get their own view - own raids, calendar entries, member tab and shared live map sessions
Asked for: alliances ("Consilium Elyseum") with their own view, a member-list tab with the allied legions and their
members, an own raid area, a calendar that shows them only alliance entries, and live map sessions the legion can
share with them - watching only, or drawing only with an extra permission. There is one Discord role "Consilium
Elyseum" for all allies, so which legion each ally belongs to is stored on the website.

- Permissions consilium.view / consilium.draw / consilium.manage. An account with consilium.view but without
  dashboard.view is a guest of the Consilium (consilium_only(), sql_is_consilium_only()) and sees only the alliance
  area; raids, calendar and map stay restricted even with extra rights like raids.view or map.view.
- includes/consilium.php; consilium.php is the allies' start page instead of the dashboard (next raids and entries,
  legions, running shared map sessions); admin/consilium.php: setup hints, allied legions, member assignment.
  users.consilium_legion_id, table consilium_legions (schema 69); allies pick their legion under Mein Profil.
- Members: new tab "Consilium Elyseum" (legions with their members), the only tab allies see. Legion-only lists
  (dues, Lumipunkte, member pickers, raid and activity points) leave allies out.
- Raids: two areas, legion and Consilium, told apart by the Discord channel ("Consilium-Raids" under Verwaltung ->
  Discord-Bot, settings.consilium_raid_channel; the bot API returns channel_id). Allies only see and sign up for
  Consilium raids, which give no Lumipunkte; raids created in the Consilium area are posted to its channel.
- Calendar: audience "Consilium Elyseum". Allies see only those entries and the Consilium raids (also in their iCal
  subscription), their own entries are always Consilium entries; the public calendar shows no Consilium raids; the
  legion sees them marked with 🤝.
- Map: whoever may edit a public tactic shares its running live session with the Consilium (consilium_share, logged).
  The share lives in the bot's live relay and only for that session: it ends with "Freigabe beenden" or 60 s after
  the last legion member left; making the tactic private or deleting it ends it as well. Allies see only running
  shared sessions under Karte (and on their start page), join and watch; with consilium.draw they add strokes,
  areas, points and text - no figures, nothing moved, erased or undone, no tactics, steps, copies or history.
  Enforced in tactics_api.php (guest branch: shared tactics only, only live_token and shape_create) and in the relay
  (guest tickets, event whitelist, guests are disconnected when the share ends). Needs the bot update (api.py,
  database/db.py, live_tactics.py).
- Navigation, privacy page, patch note, README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 01:36:49 +02:00

72 lines
3.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_login();
// Legion oder Consilium Elyseum - ob man sich fuer genau diesen Raid anmelden darf, entscheidet sein Bereich (unten)
if (!raid_area_visible('legion') && !raid_area_visible('consilium')) {
show_not_found();
}
$input = read_json_body();
verify_csrf_token($input['csrf_token'] ?? '');
$user = current_user();
if (empty($user['discord_id'])) {
json_response(false, 'Bitte verknüpfe zuerst deinen Discord-Account in "Mein Profil".');
}
$raidId = (int) ($input['raid_id'] ?? 0);
$class = trim((string) ($input['class'] ?? ''));
$groupRaw = $input['group'] ?? null; // null/"auto" = automatische Zuteilung, sonst gewuenschte Gruppe (0 = Bank)
if ($raidId <= 0 || !in_array($class, AION_CLASSES, true)) {
json_response(false, 'Bitte eine Klasse auswählen.');
}
try {
$raid = fetch_raid_by_id($raidId);
if (!$raid || !raid_area_visible(raid_area($raid))) {
json_response(false, 'Raid wurde nicht gefunden.');
}
if (!empty($raid['archived'])) {
json_response(false, 'Dieser Raid ist archiviert. Anmeldungen sind geschlossen.');
}
$groupNames = array_values(array_filter(array_map('trim', explode(',', (string) ($raid['groups'] ?? '')))));
$wish = null;
if ($groupRaw !== null && $groupRaw !== '' && $groupRaw !== 'auto') {
$wish = (int) $groupRaw;
if ($wish < 0 || $wish > count($groupNames)) {
json_response(false, 'Ungültige Gruppe ausgewählt.');
}
}
// Derselbe Name wie bei einer Anmeldung im Discord: der Anzeigename auf dem Server (Nickname),
// nicht der Discord-Kontoname. Ob die Wunschgruppe passt, entscheidet der Bot - wie im Discord.
$signupName = trim((string) ($user['display_name'] ?? '')) !== '' ? (string) $user['display_name'] : (string) $user['discord_username'];
$assigned = raid_signup($raidId, (int) $user['discord_id'], $signupName, $class, $wish);
$assignedGroup = (int) ($assigned['group'] ?? 0);
$assignedGroupLabel = $assignedGroup === 0 ? 'Ersatzbank' : ($groupNames[$assignedGroup - 1] ?? ('Gruppe ' . $assignedGroup));
$reasons = [
'locked' => 'Deine Wunschgruppe ist gesperrt',
'full' => 'Deine Wunschgruppe ist für deine Rolle schon voll',
'cap' => 'Der Raid ist schon voll besetzt',
];
$reason = (string) ($assigned['reason'] ?? '');
if (!empty($assigned['matched_wish']) || !isset($reasons[$reason])) {
$message = 'Du bist angemeldet: ' . $class . ' in ' . $assignedGroupLabel . '.';
if ($assignedGroup === 0 && $wish !== 0) {
$message .= ' Alle passenden Plätze sind belegt – du rückst nach, wenn etwas frei wird.';
}
} else {
$message = $reasons[$reason] . ', daher wurdest du automatisch zugeteilt: ' . $assignedGroupLabel
. '. Melde dich gerne beim Raid-Lead, falls du eine Anpassung möchtest.';
}
json_response(true, $message, [
'group' => $assignedGroup,
'matched_wish' => !empty($assigned['matched_wish']),
]);
} catch (Throwable $e) {
json_response(false, 'Anmeldung fehlgeschlagen: ' . $e->getMessage());
}