LuminaWebsite/admin/consilium.php
Maaxxs db47b1ad2e Consilium: room under the headings, legion rows on one line
Reported: too little space between the headings and the legions (also in the member list), and editing the
legions looked shifted.

- Space between a panel heading and its content on the Consilium page (legions, raids, entries, live sessions)
  and in the member list sections (legion and Consilium tab).
- Legion rows in Verwaltung -> Consilium Elyseum on one line (forms are columns site-wide, the rename button
  wrapped under the field); the member count has a fixed width so all name fields line up. "Legion hinzufügen" and
  the legion choice in the allies' profile on one line as well.
- Empty member list of the Consilium admin page names the Consilium server instead of the old Discord role.

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

173 lines
11 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
/**
* Consilium Elyseum verwalten: die verbuendeten Legionen und welche Mitglieder zu welcher gehoeren
* (includes/consilium.php). Formulare gehen an admin/consilium_action.php.
*/
require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/../includes/consilium.php';
require_permission('consilium.manage');
$legions = consilium_legions();
$members = consilium_members(true);
$consiliumGuild = consilium_guild_id();
// Die Einrichtung (Server, Gruppen, Rechte) ist Sache unserer Admins - nicht aller mit consilium.manage
$showSetup = user_has_permission('roles.manage');
// Gruppen des Consiliums: die mit einer Rolle des Servers des Consiliums, dazu ihre Consilium-Rechte (und ob sie
// versehentlich dashboard.view haben - dann zaehlten Verbuendete als Legion)
$groups = [];
if ($showSetup) {
$stmt = db()->prepare(
"SELECT r.id, COALESCE(NULLIF(r.display_name, ''), r.name) AS label,
GROUP_CONCAT(CASE WHEN p.`key` LIKE 'consilium.%' OR p.`key` = 'dashboard.view' THEN p.`key` END
ORDER BY p.`key` SEPARATOR ' ') AS perms
FROM roles r
LEFT JOIN role_permissions rp ON rp.role_id = r.id
LEFT JOIN permissions p ON p.id = rp.permission_id
WHERE r.discord_guild_id = ?
GROUP BY r.id
ORDER BY " . ROLE_TAG_ORDER_SQL
);
$stmt->execute([$consiliumGuild]);
$groups = $stmt->fetchAll();
}
$setUp = $consiliumGuild !== '' && ($groups || !$showSetup) && $legions;
$nameOf = static fn (array $m): string => $m['display_name'] !== '' ? (string) $m['display_name'] : (string) $m['username'];
$pageTitle = CONSILIUM_NAME;
include __DIR__ . '/../includes/header.php';
?>
<div class="panel consilium-hero">
<h1><?= icon('shield-check') ?> <?= e(CONSILIUM_NAME) ?></h1>
<p class="text-muted">
Das Bündnis mit anderen Legionen, mit eigenem Discord-Server. Wer dort eine Rolle hat, sieht auf der Website das
Consilium: die Mitglieder, Consilium-Raids, Consilium-Termine und die Karten-Sitzungen, die ihr freigebt.
Verbündete sehen nichts von der Legion, und wer von uns nicht auf dem Server ist, nichts vom Consilium.
</p>
<?php if ($showSetup): ?>
<details class="consilium-setup"<?= $setUp ? '' : ' open' ?>>
<summary>So richtest du das Consilium ein</summary>
<ol>
<li>Unter <a href="/admin/bot.php">Discord-Bot</a> den Server des Consiliums eintragen
(<?= $consiliumGuild !== '' ? 'ist eingetragen: <code>' . e($consiliumGuild) . '</code>' : '<strong>fehlt noch</strong>' ?>) und
den Bot dort einladen. Dort auch den Kanal „Consilium-Raids“ wählen.</li>
<li>Unter <a href="/admin/roles.php">Berechtigungsgruppen</a> für jede Rolle des Servers eine Gruppe anlegen und
mit ihr verknüpfen (Auswahl „Discord-Server des <?= e(CONSILIUM_NAME) ?>“) – mit diesen Rechten und
<strong>ohne <code>dashboard.view</code></strong>:
<ul>
<li>Force Commander: <code>consilium.view</code>, <code>consilium.draw</code>, <code>consilium.manage</code>, <code>consilium.raids.manage</code></li>
<li>Legion Lead: <code>consilium.view</code>, <code>consilium.draw</code>, <code>consilium.raids.manage</code> (damit auch Raids anlegen)</li>
<li>Legion Officer: <code>consilium.view</code>, <code>consilium.draw</code>, <code>consilium.raids</code></li>
<li>Legionär: <code>consilium.view</code></li>
</ul>
Consilium-Termine im Kalender eintragen: <code>consilium.calendar</code> – gebt es, wem ihr es zutraut.</li>
<li>Unten die verbündeten Legionen anlegen und ihre Mitglieder zuordnen. Jedes Mitglied kann seine Legion auch
selbst unter „Mein Profil“ wählen. Wer von uns auf dem Server ist, steht automatisch unter
„<?= e(CONSILIUM_HOME_LEGION) ?>“.</li>
<li>Neue Konten schaltet ihr wie gewohnt in der <a href="/admin/users.php">Benutzerverwaltung</a> frei.</li>
</ol>
<p class="consilium-setup-status">
<strong>Gruppen mit Rolle auf dem Server des Consiliums:</strong>
<?php if (!$groups): ?>
<span class="text-muted">noch keine</span>
<?php endif; ?>
</p>
<?php if ($groups): ?>
<ul class="consilium-group-list">
<?php foreach ($groups as $group): ?>
<?php $perms = array_filter(explode(' ', (string) ($group['perms'] ?? ''))); ?>
<li>
<?= role_tag_html((string) $group['label']) ?>
<span class="text-muted"><?= $perms ? e(implode(', ', array_diff($perms, ['dashboard.view']))) : 'keine Consilium-Rechte' ?></span>
<?php if (in_array('dashboard.view', $perms, true)): ?><span class="badge badge-danger" title="Dann zählen Verbündete als Legion und sehen alles">hat dashboard.view!</span><?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</details>
<?php endif; ?>
</div>
<div class="panel">
<h2>Legionen im Consilium</h2>
<?php if (!$legions): ?>
<p class="text-muted">Noch keine verbündete Legion angelegt.</p>
<?php else: ?>
<ul class="consilium-legion-list">
<?php foreach ($legions as $i => $legion): ?>
<li>
<form method="post" action="/admin/consilium_action.php" class="consilium-legion-rename">
<?= csrf_field() ?>
<input type="hidden" name="action" value="legion_rename">
<input type="hidden" name="id" value="<?= $legion['id'] ?>">
<input type="text" name="name" value="<?= e($legion['name']) ?>" maxlength="<?= CONSILIUM_LEGION_NAME_MAX ?>" required aria-label="Name der Legion">
<button type="submit" class="button-secondary button-small">Umbenennen</button>
</form>
<span class="text-muted consilium-legion-count"><?= $legion['member_count'] ?> <?= $legion['member_count'] === 1 ? 'Mitglied' : 'Mitglieder' ?></span>
<form method="post" action="/admin/consilium_action.php" class="inline-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="legion_move">
<input type="hidden" name="id" value="<?= $legion['id'] ?>">
<button type="submit" name="direction" value="up" class="icon-button" title="Nach oben"<?= $i === 0 ? ' disabled' : '' ?>>▲</button>
<button type="submit" name="direction" value="down" class="icon-button" title="Nach unten"<?= $i === count($legions) - 1 ? ' disabled' : '' ?>>▼</button>
</form>
<form method="post" action="/admin/consilium_action.php" class="inline-form"
data-confirm="Die Legion „<?= e($legion['name']) ?>“ löschen? Ihre Mitglieder bleiben im Consilium, nur ohne Legion." data-confirm-title="Legion löschen" data-confirm-danger data-confirm-ok="Löschen">
<?= csrf_field() ?>
<input type="hidden" name="action" value="legion_delete">
<input type="hidden" name="id" value="<?= $legion['id'] ?>">
<button type="submit" class="icon-button icon-button-danger" title="Löschen" aria-label="<?= e($legion['name']) ?> löschen"><?= icon('trash') ?></button>
</form>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<form method="post" action="/admin/consilium_action.php" class="consilium-legion-add">
<?= csrf_field() ?>
<input type="hidden" name="action" value="legion_add">
<input type="text" name="name" maxlength="<?= CONSILIUM_LEGION_NAME_MAX ?>" required placeholder="Name der verbündeten Legion" aria-label="Name der verbündeten Legion">
<button type="submit">+ Legion hinzufügen</button>
</form>
</div>
<div class="panel">
<h2>Mitglieder des Consiliums <span class="chip-count"><?= count($members) ?></span></h2>
<?php if (!$members): ?>
<p class="text-muted">Noch niemand. Wer von den verbündeten Legionen eine Rolle auf dem Discord-Server des Consiliums hat und sich auf der Website anmeldet, erscheint hier.</p>
<?php else: ?>
<div class="table-scroll">
<table>
<thead>
<tr><th>Mitglied</th><th>Discord</th><th>Legion</th><th>Zuletzt aktiv</th></tr>
</thead>
<tbody>
<?php foreach ($members as $member): ?>
<tr>
<td>
<span class="consilium-member-name"><?= avatar_html($member, 28) ?> <?= e($nameOf($member)) ?></span>
<?php if ($member['status'] === 'pending'): ?><a class="badge badge-pending" href="/admin/users.php">Wartet auf Freischaltung</a><?php endif; ?>
</td>
<td class="text-muted"><?= e((string) ($member['discord_username'] ?? '')) ?></td>
<td>
<form method="post" action="/admin/consilium_action.php" class="inline-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="member_legion">
<input type="hidden" name="user_id" value="<?= (int) $member['id'] ?>">
<select name="legion_id" onchange="this.form.submit()" aria-label="Legion von <?= e($nameOf($member)) ?>">
<option value="">– keine –</option>
<?php foreach ($legions as $legion): ?>
<option value="<?= $legion['id'] ?>"<?= (int) $member['consilium_legion_id'] === $legion['id'] ? ' selected' : '' ?>><?= e($legion['name']) ?></option>
<?php endforeach; ?>
</select>
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
</form>
</td>
<td class="text-muted"><?= e(last_active_label($member['last_active'] ?? null)) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
<?php include __DIR__ . '/../includes/footer.php'; ?>