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

139 lines
7.6 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/tactics.php';
require_once __DIR__ . '/includes/consilium.php';
require_login();
// Mitglieder verbuendeter Legionen (Consilium Elyseum) sehen keine Taktiken der Legion - nur die Live-Sitzungen,
// die gerade fuer das Consilium freigegeben sind (includes/tactics.php). Beitreten oeffnet die Karte mit der Taktik.
if (consilium_only()) {
$sessionsError = false;
try {
$sessions = tactics_missing_tables() ? [] : tactics_consilium_sessions();
} catch (Throwable $e) {
$sessions = [];
$sessionsError = true;
}
$joinId = (int) ($_GET['taktik'] ?? 0);
$joined = null;
foreach ($sessions as $session) {
if ($session['tactic_id'] === $joinId) {
$joined = $session;
}
}
$canDraw = user_has_permission('consilium.draw');
$pageTitle = $joined !== null ? $joined['name'] . ' – Live' : 'Karte';
$containerWide = $joined !== null;
include __DIR__ . '/includes/header.php';
if ($joined !== null) {
// Der Viewer laedt als Gast nur freigegebene Sitzungen (tactics_api.php) und oeffnet diese Taktik
$frameSrc = '/map_frame.php?' . http_build_query(array_filter([
'bereich' => str_starts_with($joined['url'], '/raidplan.php') ? 'dungeons' : '',
'karte' => $joined['map_slug'],
'taktik' => (string) $joined['tactic_id'],
]));
?>
<div class="panel consilium-live-bar">
<a class="button button-secondary button-small" href="/map.php">← Alle Live-Sitzungen</a>
<strong><?= e($joined['name']) ?></strong>
<span class="text-muted"><?= e($joined['map_name']) ?><?= $joined['author'] !== '' ? ' · von ' . e($joined['author']) : '' ?></span>
<span class="consilium-live-mode"><?= $canDraw
? '✏️ <span class="consilium-live-long">Du darfst mitzeichnen</span><span class="consilium-live-short">Mitzeichnen</span>'
: '👁 <span class="consilium-live-long">Du schaust zu</span><span class="consilium-live-short">Zuschauen</span>' ?></span>
</div>
<iframe class="map-frame consilium-map-frame" src="<?= e($frameSrc) ?>" title="Live-Sitzung: <?= e($joined['name']) ?>"></iframe>
<?php
} else {
?>
<div class="panel">
<h1>Karte – Live-Sitzungen</h1>
<p class="text-muted">
Hier erscheinen die Taktiken, die gerade live besprochen und für das <?= e(CONSILIUM_NAME) ?> freigegeben werden.
Du schaust zu<?= $canDraw ? ' und darfst mitzeichnen – nur zeichnen, nichts löschen oder verschieben' : '' ?>.
Die Freigabe gilt nur für die laufende Sitzung.
</p>
<?php if ($joinId > 0): ?>
<div class="flash flash-info">Diese Live-Sitzung ist beendet oder nicht mehr für das Consilium freigegeben.</div>
<?php endif; ?>
<div class="flash flash-error" id="consilium-sessions-error"<?= $sessionsError ? '' : ' hidden' ?>>Die Live-Sitzungen sind gerade nicht erreichbar – die Liste versucht es gleich noch einmal.</div>
<?php // Dieselbe Darstellung baut assets/js/consilium-map.js beim Aktualisieren ?>
<ul class="consilium-upcoming consilium-sessions" id="consilium-sessions" data-source="/tactics_api.php?sitzungen=1">
<?php foreach ($sessions 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'] > 0 ? $session['members'] . ' aus der Legion' : 'Legion gerade nicht verbunden' ?><?= $session['guests'] > 0 ? ' · ' . $session['guests'] . ($session['guests'] === 1 ? ' Gast' : ' Gäste') : '' ?></span>
<span class="consilium-session-join">Beitreten →</span>
</a>
</li>
<?php endforeach; ?>
</ul>
<p class="text-muted" id="consilium-sessions-empty"<?= $sessions ? ' hidden' : '' ?>>
Gerade läuft keine freigegebene Live-Sitzung. Sobald die Legion eine Taktik für das Consilium freigibt, erscheint sie hier von selbst.
</p>
</div>
<script src="<?= e(asset_url('/assets/js/consilium-map.js')) ?>"></script>
<?php
}
include __DIR__ . '/includes/footer.php';
exit;
}
require_permission('map.view');
// Bestehende Installationen kennen die Taktik-Tabellen noch nicht. Die Karte selbst
// funktioniert trotzdem, nur die Taktiken brauchen die Datenbank.
try {
$missingTables = tactics_missing_tables();
} catch (Throwable $e) {
$missingTables = TACTIC_TABLES;
}
// Dieselbe Seite ist auch der Raidplaner (raidplan.php setzt $mapArea): der Viewer startet dann bei
// den Dungeon- und Raid-Karten statt bei den Weltkarten.
$mapArea = ($mapArea ?? 'welt') === 'dungeons' ? 'dungeons' : 'welt';
// Die Karte ist ein eigenstaendiger Viewer (assets/map/) mit eigenem Stylesheet, das
// global auf body/button/* greift. Im iframe bleibt er vom Seitenlayout getrennt.
// Die Taktiken laedt und speichert er selbst ueber tactics_api.php.
// Geteilter Ort (/map.php?karte=verteron&x=1234&y=2345&zoom=5&ort=Treffpunkt) bzw. geteilte Taktik
// (/raidplan.php?karte=reforged-abyss&taktik=12&schritt=3): an den Viewer weiterreichen.
$linkParams = array_filter([
'bereich' => $mapArea === 'dungeons' ? 'dungeons' : '',
'karte' => preg_match('/^[a-z0-9-]{1,40}$/', (string) ($_GET['karte'] ?? '')) ? (string) $_GET['karte'] : '',
'x' => is_numeric($_GET['x'] ?? null) ? (string) (int) $_GET['x'] : '',
'y' => is_numeric($_GET['y'] ?? null) ? (string) (int) $_GET['y'] : '',
'zoom' => is_numeric($_GET['zoom'] ?? null) ? (string) (int) $_GET['zoom'] : '',
'ort' => mb_substr(trim((string) ($_GET['ort'] ?? '')), 0, 60),
'taktik' => (int) ($_GET['taktik'] ?? 0) > 0 ? (string) (int) $_GET['taktik'] : '',
'schritt' => (int) ($_GET['schritt'] ?? 0) > 0 ? (string) (int) $_GET['schritt'] : '',
], static fn (string $v): bool => $v !== '');
// map_frame.php haengt Versionskennungen an die Skripte (sonst alte Dateien aus dem Browser-Cache)
$frameSrc = '/map_frame.php' . ($linkParams ? '?' . http_build_query($linkParams) : '');
$pageTitle = $mapArea === 'dungeons' ? 'Raidplaner' : 'Karte';
$containerWide = true;
include __DIR__ . '/includes/header.php';
?>
<?php if (!empty($missingTables)): ?>
<div class="panel map-setup">
<p>
<strong>Taktiken einrichten:</strong>
<span class="text-muted">Der Datenbank fehlen noch die Tabellen für Taktiken
(<?= e(implode(', ', $missingTables)) ?>). Die Karte funktioniert auch ohne sie.</span>
</p>
<?php if (user_has_permission('roles.manage')): ?>
<form method="post" action="/tactics_install_action.php">
<?= csrf_field() ?>
<button type="submit">Tabellen jetzt anlegen</button>
</form>
<?php else: ?>
<p class="text-muted">Dafür fehlt dir die Berechtigung <code>roles.manage</code> - bitte einen Administrator.</p>
<?php endif; ?>
</div>
<?php endif; ?>
<iframe class="map-frame" src="<?= e($frameSrc) ?>" title="<?= $mapArea === 'dungeons' ? 'Raidplaner: Taktiken für Dungeons und Raids' : 'Interaktive Karte' ?>"></iframe>
<?php include __DIR__ . '/includes/footer.php'; ?>