LuminaWebsite/includes/calendar_entry.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

132 lines
8.9 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
/**
* Ein Termin eines Mitglieds in der Terminliste des Kalenders (eingebunden in calendar.php).
*
* @var array $entry mit row, people, joined, reported
* @var bool $isModerator
* @var int $myId
* @var callable $entryFields
* @var bool $canLead calendar.leadership (Termine nur fuer die Leitung)
*/
$row = $entry['row'];
$entryId = (int) $row['id'];
$isAuthor = (int) $row['user_id'] === $myId;
$ends = $row['ends_at'] ? strtotime((string) $row['ends_at']) : null;
$actionForm = static function (string $action, string $label, string $class) use ($entryId): string {
return '<form class="inline-form" method="post" action="/calendar_action.php">'
. csrf_field() . '<input type="hidden" name="action" value="' . $action . '"><input type="hidden" name="id" value="' . $entryId . '">'
. '<button type="submit" class="button-small ' . $class . '">' . $label . '</button></form>';
};
?>
<div class="calendar-member-entry calendar-member<?= $row['status'] === 'pending' ? ' is-pending' : '' ?>" id="termin-<?= $entryId ?>">
<div class="calendar-member-head">
<span class="calendar-time"><?= date('H:i', $entry['time']) ?><?= $ends ? '–' . (date('Y-m-d', $ends) === date('Y-m-d', $entry['time']) ? date('H:i', $ends) : date('d.m. H:i', $ends)) : '' ?> Uhr</span>
<strong class="calendar-member-title"><?= e((string) $row['title']) ?></strong>
<?php if ($row['status'] === 'pending'): ?>
<span class="pending-badge-inline" title="<?= e((string) $row['moderation_note']) ?>">Wartet auf Freigabe</span>
<?php endif; ?>
<?php if (($row['audience'] ?? 'all') === 'internal'): ?>
<span class="calendar-audience-badge" title="Nur die Leitung sieht diesen Termin">🔒 Intern</span>
<?php elseif (($row['audience'] ?? 'all') === 'leadership'): ?>
<span class="calendar-audience-badge" title="Für alle sichtbar, teilnehmen kann nur die Leitung">Nur Leitung</span>
<?php elseif (($row['audience'] ?? 'all') === 'consilium' && empty($consiliumOnly)): ?>
<span class="calendar-audience-badge" title="Auch die verbündeten Legionen im Consilium Elyseum sehen diesen Termin und nehmen teil">🤝 Consilium</span>
<?php endif; ?>
<?php // Profilseiten gibt es nur fuer die Legion - wer nur zum Consilium gehoert, sieht die Namen ohne Link ?>
<?php $profileTag = empty($consiliumOnly) ? 'a' : 'span'; ?>
<span class="calendar-member-author">
<?= avatar_html(['id' => $row['user_id'], 'username' => $row['username'], 'display_name' => $row['display_name'], 'avatar_filename' => $row['avatar_filename']], 22) ?>
<<?= $profileTag ?><?= $profileTag === 'a' ? ' href="/member.php?id=' . (int) $row['user_id'] . '"' : '' ?>><?= e((string) $row['author']) ?></<?= $profileTag ?>>
</span>
</div>
<?php $location = !empty($row['location_path']) ? map_link_parse((string) $row['location_path']) : null; ?>
<?php if ($location): ?>
<div class="calendar-location">Treffpunkt: <?= map_link_html($location) ?></div>
<?php endif; ?>
<?php if (!empty($row['description'])): ?>
<p class="calendar-member-description"><?= gallery_comment_html((string) $row['description']) ?></p>
<?php endif; ?>
<div class="calendar-member-foot">
<?php $peopleCount = count($entry['people']); ?>
<?php // Teilnehmer: Avatar-Reihe, ein Klick klappt die ganze Liste mit Namen auf ?>
<details class="calendar-people"<?= $peopleCount === 0 ? ' data-empty' : '' ?>>
<summary title="Wer ist dabei? Klicken zum Aufklappen">
<span class="calendar-people-stack">
<?php foreach (array_slice($entry['people'], 0, 6) as $person): ?>
<?= avatar_html($person, 26) ?>
<?php endforeach; ?>
<?php if ($peopleCount > 6): ?><span class="calendar-people-more">+<?= $peopleCount - 6 ?></span><?php endif; ?>
</span>
<span class="calendar-people-label"><?= $peopleCount ?> dabei</span>
<?php if ($peopleCount > 0): ?><span class="calendar-people-toggle" aria-hidden="true">▾</span><?php endif; ?>
</summary>
<?php if ($peopleCount > 0): ?>
<ul class="calendar-people-list">
<?php foreach ($entry['people'] as $person): ?>
<?php
$personName = $person['display_name'] !== '' ? $person['display_name'] : $person['username'];
$isHost = (int) $person['id'] === (int) $row['user_id'];
?>
<li class="<?= $isHost ? 'is-host' : '' ?><?= (int) $person['id'] === $myId ? ' is-me' : '' ?>">
<<?= $profileTag ?><?= $profileTag === 'a' ? ' href="/member.php?id=' . (int) $person['id'] . '"' : '' ?>>
<?= avatar_html($person, 30) ?>
<span class="calendar-people-name"><?= e($personName) ?></span>
<?php if ($isHost): ?><span class="calendar-people-badge">Veranstalter</span><?php elseif ((int) $person['id'] === $myId): ?><span class="calendar-people-badge is-me">Du</span><?php endif; ?>
</<?= $profileTag ?>>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</details>
<div class="calendar-member-actions">
<?php if (!$entry['past']): ?>
<?php if ($entry['joined']): ?>
<?= $actionForm('leave', 'Absagen', 'button-secondary') ?>
<?php elseif (calendar_can_join($row, $canLead)): ?>
<?= $actionForm('join', '✋ Bin dabei', 'button-success') ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($isModerator && $row['status'] === 'pending'): ?>
<form class="inline-form" method="post" action="/moderation_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="approve"><input type="hidden" name="type" value="calendar">
<input type="hidden" name="id" value="<?= $entryId ?>"><input type="hidden" name="back" value="calendar">
<button type="submit" class="button-small button-success">Freigeben</button>
</form>
<?php endif; ?>
<?php if ($isAuthor): ?>
<details class="calendar-edit">
<summary class="icon-button" title="Bearbeiten" aria-label="Bearbeiten"><?= icon('edit') ?></summary>
<form method="post" action="/calendar_action.php" class="calendar-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="<?= $entryId ?>">
<?= $entryFields($row) ?>
<div class="actions"><button type="submit">Speichern</button></div>
</form>
</details>
<?php endif; ?>
<?php if ($isAuthor || $isModerator): ?>
<form class="inline-form" method="post" action="/calendar_action.php" data-confirm="<?= e('„' . $row['title'] . '“ wirklich löschen?') ?>" data-confirm-title="Termin löschen" data-confirm-danger data-confirm-ok="Löschen">
<?= csrf_field() ?>
<input type="hidden" name="action" value="delete"><input type="hidden" name="id" value="<?= $entryId ?>">
<button type="submit" class="icon-button icon-button-danger" title="Löschen" aria-label="Löschen"><?= icon('trash') ?></button>
</form>
<?php endif; ?>
<?php if (!$isAuthor): ?>
<?php if ($entry['reported']): ?>
<span class="report-done" title="Du hast das gemeldet - danke!"><?= icon('flag') ?> Gemeldet</span>
<?php else: ?>
<form class="inline-form" method="post" action="/moderation_action.php"
data-confirm="Die Moderation schaut sich den Termin an." data-confirm-title="Termin melden" data-confirm-ok="Melden"
data-confirm-input="reason" data-confirm-placeholder="Was ist daran nicht in Ordnung? (optional)">
<?= csrf_field() ?>
<input type="hidden" name="action" value="report"><input type="hidden" name="type" value="calendar">
<input type="hidden" name="id" value="<?= $entryId ?>"><input type="hidden" name="reason" value="">
<button type="submit" class="icon-button report-button" title="Melden" aria-label="Melden"><?= icon('flag') ?></button>
</form>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>