LuminaWebsite/consilium.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

158 lines
7.3 KiB
PHP

<?php
/**
* Consilium Elyseum - Startseite des Buendnisses. Fuer Mitglieder verbuendeter Legionen ist sie die Startseite
* statt des Dashboards (dashboard.php leitet sie hierher), die Legion erreicht sie ueber das Menue.
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/consilium.php';
require_login();
if (!consilium_can_view()) {
show_not_found();
}
$user = current_user();
$isOnly = consilium_only();
$legions = consilium_legions();
$members = consilium_members();
$unassigned = count(array_filter($members, static fn (array $m): bool => $m['consilium_legion_id'] === null));
$myLegion = $isOnly ? consilium_legion_name(consilium_member_legion_id((int) $user['id'])) : null;
$upcoming = consilium_upcoming_entries();
$weekdayNames = ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'];
// Die naechsten Consilium-Raids (eigener Discord-Kanal, includes/raids_api.php) - faellt der Bot aus, bleibt der Hinweis
require_once __DIR__ . '/includes/raids_api.php';
$consiliumRaids = null;
if (raid_area_visible('consilium')) {
try {
$consiliumRaids = raids_in_area(fetch_raids('active'), 'consilium');
usort($consiliumRaids, static fn (array $a, array $b): int => (int) ($a['timestamp'] ?? 0) <=> (int) ($b['timestamp'] ?? 0));
$consiliumRaids = array_slice($consiliumRaids, 0, 5);
} catch (Throwable $e) {
$consiliumRaids = [];
}
}
// Live-Sitzungen der Karte, die gerade fuer das Consilium freigegeben sind (includes/tactics.php) - nur wenn welche laufen
require_once __DIR__ . '/includes/tactics.php';
try {
$liveSessions = tactics_missing_tables() ? [] : tactics_consilium_sessions();
} catch (Throwable $e) {
$liveSessions = [];
}
$pageTitle = CONSILIUM_NAME;
include __DIR__ . '/includes/header.php';
?>
<div class="panel consilium-hero">
<h1><?= icon('shield-check') ?> <?= e(CONSILIUM_NAME) ?></h1>
<p>Das Bündnis der Legionen: gemeinsame Raids, gemeinsame Termine und Taktiken, die wir live miteinander besprechen.</p>
<?php if ($isOnly): ?>
<p class="text-muted">
Willkommen, <?= e($user['display_name'] !== '' ? $user['display_name'] : $user['username']) ?>!
<?php if ($myLegion !== null): ?>
Du gehörst zur Legion <strong><?= e($myLegion) ?></strong>.
<?php elseif ($legions): ?>
Wähle unter <a href="/profile.php#consilium">Mein Profil</a>, zu welcher Legion du gehörst.
<?php endif; ?>
</p>
<?php endif; ?>
</div>
<?php if ($liveSessions): ?>
<div class="panel">
<div class="raid-header">
<h2>Gerade live auf der Karte</h2>
<a class="button button-secondary button-small" href="/map.php"><?= icon('map') ?> Karte</a>
</div>
<ul class="consilium-upcoming">
<?php foreach ($liveSessions as $session): ?>
<li>
<a href="<?= e($session['url']) ?>">
<span class="consilium-upcoming-date">seit <?= e(date('H:i', $session['since'])) ?> Uhr</span>
<strong><?= e($session['name']) ?></strong>
<span class="text-muted"><?= e($session['map_name']) ?> · <?= $session['members'] + $session['guests'] ?> dabei</span>
<span class="consilium-session-join"><?= $isOnly ? 'Beitreten →' : 'Öffnen →' ?></span>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php if ($consiliumRaids !== null): ?>
<div class="panel">
<div class="raid-header">
<h2>Nächste Raids</h2>
<a class="button button-secondary button-small" href="/raids.php<?= raid_area_visible('legion') ? '?bereich=consilium' : '' ?>"><?= icon('calendar') ?> Alle Raids</a>
</div>
<?php if (!$consiliumRaids): ?>
<p class="text-muted">Gerade ist kein Raid des Consiliums geplant.</p>
<?php else: ?>
<ul class="consilium-upcoming">
<?php foreach ($consiliumRaids as $raid): ?>
<?php
$start = (int) ($raid['timestamp'] ?? 0);
$inGroups = count(array_filter((array) ($raid['signups'] ?? []), static fn ($s): bool
=> (int) ($s['group'] ?? 0) >= 1 && ($s['class'] ?? '') !== 'Ausstehend'));
?>
<li>
<a href="/raids.php<?= raid_area_visible('legion') ? '?bereich=consilium' : '' ?>#raid-<?= (int) ($raid['raid_id'] ?? 0) ?>">
<span class="consilium-upcoming-date"><?= $start > 0 ? e($weekdayNames[(int) date('w', $start)] . ' ' . date('d.m. H:i', $start)) . ' Uhr' : '' ?></span>
<strong><?= e((string) ($raid['title'] ?? 'Raid')) ?></strong>
<span class="text-muted"><?= $inGroups ?><?= (int) ($raid['max_slots'] ?? 0) > 0 ? ' / ' . (int) $raid['max_slots'] : '' ?> angemeldet</span>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="panel">
<div class="raid-header">
<h2>Nächste Termine</h2>
<a class="button button-secondary button-small" href="/calendar.php"><?= icon('calendar') ?> Kalender</a>
</div>
<?php if (!$upcoming): ?>
<p class="text-muted">Gerade steht kein Termin des Consiliums an. Du planst etwas? Trag es im Kalender ein.</p>
<?php else: ?>
<ul class="consilium-upcoming">
<?php foreach ($upcoming as $entry): ?>
<?php $start = strtotime((string) $entry['starts_at']); ?>
<li>
<a href="/calendar.php?month=<?= e(date('Y-m', $start)) ?>#termin-<?= (int) $entry['id'] ?>">
<span class="consilium-upcoming-date"><?= e($weekdayNames[(int) date('w', $start)] . ' ' . date('d.m. H:i', $start)) ?> Uhr</span>
<strong><?= e((string) $entry['title']) ?></strong>
<span class="text-muted"><?= (int) $entry['people'] ?> dabei</span>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<div class="panel">
<div class="raid-header">
<h2>Legionen im Consilium</h2>
<a class="button button-secondary button-small" href="/members.php?tab=consilium"><?= icon('users') ?> Alle Mitglieder</a>
</div>
<?php if (!$legions): ?>
<p class="text-muted">Noch keine verbündete Legion eingetragen.</p>
<?php else: ?>
<div class="consilium-legion-grid">
<?php foreach ($legions as $legion): ?>
<a class="consilium-legion-card" href="/members.php?tab=consilium#legion-<?= $legion['id'] ?>">
<strong><?= e($legion['name']) ?></strong>
<span class="text-muted"><?= $legion['member_count'] ?> <?= $legion['member_count'] === 1 ? 'Mitglied' : 'Mitglieder' ?></span>
</a>
<?php endforeach; ?>
<?php if ($unassigned > 0): ?>
<a class="consilium-legion-card is-muted" href="/members.php?tab=consilium#legion-0">
<strong>Ohne Legion</strong>
<span class="text-muted"><?= $unassigned ?> <?= $unassigned === 1 ? 'Mitglied' : 'Mitglieder' ?></span>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php include __DIR__ . '/includes/footer.php'; ?>