LuminaWebsite/includes/calendar_audience.php
Maaxxs 9eb340684e Consilium: only accounts with consilium.view see it - normal legion members see nothing of it
Asked for: normal members must not see anything of the alliances - not the alliance member list, not their
calendar entries - and the alliance things out of the patch notes.

- consilium_can_view() is now consilium.view only (before: every legion member). Normal members get no menu entry,
  no Consilium page, no member-list tab, no Consilium raids (raids page, dashboard, calendar) and no share button
  or Consilium hints on the map (tactics_api.php: consilium flag and consilium_share need consilium.view).
- Calendar: Consilium entries only with consilium.view - calendar_can_view(), the iCal subscription, the "Für wen?"
  option and the moderation queue and its counter.
- member.php: profiles of allied members only for those who see the Consilium.
- Allies no longer counted in legion lists: Lumipunkte rank on the dashboard, premade invite candidates, class
  counts on the professions page.
- Map: normal members in a shared session see guests like other participants, without 🤝 and legion.
- Patch note about the Consilium removed; permission description updated (schema 70); admin setup hint and README.

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

67 lines
2.8 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
declare(strict_types=1);
/**
* Fuer wen ein Kalender-Termin der Mitglieder gedacht ist (calendar_entries.audience). Termine nur
* fuer die Leitung tragen Konten mit calendar.leadership ein (die Sedes Luminis):
* all - wie bisher: alle sehen ihn und koennen "Bin dabei" klicken
* consilium - fuer das Consilium Elyseum: sehen und teilnehmen nur mit consilium.view - die verbuendeten Legionen
* und aus der Legion z.B. die Leitung, normale Mitglieder nicht
* leadership - alle sehen ihn, teilnehmen kann nur die Leitung (z.B. eine Besprechung)
* internal - nur die Leitung sieht ihn ueberhaupt
* Mitglieder verbuendeter Legionen (consilium_only()) sehen nur Consilium-Termine und tragen nur solche ein; der
* oeffentliche Kalender zeigt sie nicht.
*/
const CALENDAR_AUDIENCES = [
'all' => 'Alle Mitglieder',
'consilium' => 'Consilium Elyseum – auch die verbündeten Legionen sehen ihn und nehmen teil',
'leadership' => 'Nur Leitung nimmt teil (für alle sichtbar)',
'internal' => 'Intern – nur für die Leitung sichtbar',
];
function calendar_can_lead(): bool
{
return user_has_permission('calendar.leadership');
}
/**
* Darf der Betrachter den Termin sehen? (Freigabe/Moderation prueft der Aufrufer wie bisher.) $consiliumOnly: ob er nur
* zum Consilium gehoert, $seeConsilium: ob er das Consilium sieht (consilium.view) - null = das angemeldete Konto.
*/
function calendar_can_view(array $row, bool $canLead, int $myId, ?bool $consiliumOnly = null, ?bool $seeConsilium = null): bool
{
$audience = $row['audience'] ?? 'all';
if ((int) $row['user_id'] === $myId) {
return true;
}
if ($consiliumOnly ?? consilium_only()) {
return $audience === 'consilium';
}
if ($audience === 'consilium') {
return $seeConsilium ?? consilium_can_view();
}
return $audience !== 'internal' || $canLead;
}
/** Darf der Betrachter sich mit "Bin dabei" eintragen? (Sehen darf er ihn, siehe calendar_can_view().) */
function calendar_can_join(array $row, bool $canLead): bool
{
return in_array($row['audience'] ?? 'all', ['all', 'consilium'], true) || $canLead;
}
/**
* Zielgruppe aus dem Formular - ohne calendar.leadership bleibt es beim bisherigen Wert. Verbuendete aus dem Consilium
* tragen immer Consilium-Termine ein.
*/
function calendar_audience_input(?string $current, bool $canLead): string
{
if (consilium_only()) {
return 'consilium';
}
$value = (string) ($_POST['audience'] ?? '');
// Consilium-Termine nur, wer das Consilium auch sieht
if ($canLead && isset(CALENDAR_AUDIENCES[$value]) && ($value !== 'consilium' || consilium_can_view())) {
return $value;
}
return $current !== null && isset(CALENDAR_AUDIENCES[$current]) ? $current : 'all';
}