169 lines
8.3 KiB
PHP
169 lines
8.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();
|
|
// Unsere eigenen Leute im Consilium (mit Rolle auf dessen Server) stehen unter CONSILIUM_HOME_LEGION
|
|
$homeCount = count(array_filter($members, static fn (array $m): bool => !empty($m['is_legion'])));
|
|
$unassigned = count(array_filter($members, static fn (array $m): bool => empty($m['is_legion']) && $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<?= $isOnly ? '' : ' consilium-hero-logo' ?>">
|
|
<?php if (!$isOnly): // Nur-Allianz-Mitglieder sehen das Logo schon in der Seitenleiste ?>
|
|
<img src="<?= e(asset_url('/assets/images/elyos-allianz-logo.webp')) ?>" alt="<?= e(CONSILIUM_NAME) ?>" width="417" height="230" class="consilium-logo">
|
|
<?php endif; ?>
|
|
<h1><?= $isOnly ? 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 von <?= e(CONSILIUM_NAME) ?> 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 von <?= e(CONSILIUM_NAME) ?> an.<?= user_has_permission('consilium.calendar') ? ' 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 in <?= e(CONSILIUM_NAME) ?></h2>
|
|
<a class="button button-secondary button-small" href="/members.php?tab=consilium"><?= icon('users') ?> Alle Mitglieder</a>
|
|
</div>
|
|
<?php if (!$legions && $homeCount === 0): ?>
|
|
<p class="text-muted">Noch keine verbündete Legion eingetragen.</p>
|
|
<?php else: ?>
|
|
<div class="consilium-legion-grid">
|
|
<?php if ($homeCount > 0): ?>
|
|
<a class="consilium-legion-card" href="/members.php?tab=consilium#legion-home">
|
|
<strong><?= e(CONSILIUM_HOME_LEGION) ?></strong>
|
|
<span class="text-muted"><?= $homeCount ?> <?= $homeCount === 1 ? 'Mitglied' : 'Mitglieder' ?></span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?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'; ?>
|