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>
62 lines
3.1 KiB
PHP
62 lines
3.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Mitglied auswaehlen: Suchfeld mit aufklappender Liste (runder Avatar, Name, Gruppe, Klasse)
|
|
* statt eines einfachen Dropdowns. Baut auf assets/js/item-picker.js auf - die Seite muss das
|
|
* Skript einbinden.
|
|
*/
|
|
|
|
/**
|
|
* Alle aktiven Konten der Legion (ohne Verbuendete aus dem Consilium) mit allem, was die Liste anzeigt.
|
|
*
|
|
* @return array<int, array<string, mixed>>
|
|
*/
|
|
function member_picker_rows(): array
|
|
{
|
|
return db()->query(
|
|
"SELECT u.id, u.discord_id, COALESCE(NULLIF(u.display_name, ''), u.username) AS name, u.avatar_filename, u.class_name,
|
|
(SELECT COALESCE(NULLIF(r.display_name, ''), r.name) FROM user_roles ur JOIN roles r ON r.id = ur.role_id
|
|
WHERE ur.user_id = u.id ORDER BY COALESCE(r.roster_order, 999), r.name LIMIT 1) AS top_role
|
|
FROM users u WHERE u.status = 'active' AND " . sql_is_legion_member('u') . ' ORDER BY name'
|
|
)->fetchAll();
|
|
}
|
|
|
|
/**
|
|
* Ein Eintrag fuer die Liste. $idField: welche Spalte als Wert gesendet wird (id oder discord_id).
|
|
*
|
|
* @return array{id: string, name: string, category: string, icon: ?string, qty: null}
|
|
*/
|
|
function member_picker_item(array $row, string $idField = 'id'): array
|
|
{
|
|
return [
|
|
'id' => (string) ($row[$idField] ?? ''),
|
|
'name' => (string) ($row['name'] ?? ''),
|
|
'category' => trim((($row['top_role'] ?? '') ?: 'Mitglied') . (!empty($row['class_name']) ? ' · ' . $row['class_name'] : '')),
|
|
'icon' => !empty($row['avatar_filename']) ? '/assets/uploads/avatars/' . rawurlencode((string) $row['avatar_filename']) : null,
|
|
'qty' => null,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* HTML fuer das Auswahlfeld.
|
|
*
|
|
* @param array<int, array<string, mixed>>|null $items aus member_picker_item(); null = Liste mit dieser ID
|
|
* steht schon auf der Seite (mehrere Felder teilen sich eine Liste)
|
|
* @param array{selected?: string, placeholder?: string, required?: bool, input_id?: string, empty?: string} $options
|
|
*/
|
|
function member_picker(string $name, string $listId, ?array $items, array $options = []): string
|
|
{
|
|
$required = !empty($options['required']);
|
|
$inputId = $options['input_id'] ?? $listId . '-search';
|
|
return '<div class="item-picker member-picker" data-picker-items="' . e($listId) . '" data-picker-mode="id" data-picker-round'
|
|
. ' data-picker-empty="' . e($options['empty'] ?? 'Kein Mitglied gefunden.') . '"'
|
|
. ' data-picker-invalid="Bitte ein Mitglied aus der Liste wählen.">'
|
|
. '<input type="hidden" name="' . e($name) . '" value="' . e((string) ($options['selected'] ?? '')) . '">'
|
|
. '<label class="search-field"><span class="item-picker-icon">' . icon('search') . '</span>'
|
|
. '<input type="text" class="item-picker-input" id="' . e($inputId) . '"' . ($required ? ' required' : '')
|
|
. ' placeholder="' . e($options['placeholder'] ?? 'Mitglied suchen …') . '" aria-label="Mitglied auswählen"></label>'
|
|
. '</div>'
|
|
. ($items === null ? '' : '<script type="application/json" id="' . e($listId) . '">'
|
|
. json_encode(array_values($items), JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP) . '</script>');
|
|
}
|