LuminaWebsite/admin/users.php
Maaxxs 77bb1b3ff5 Use real German umlauts instead of ASCII transliterations
Every "oe/ae/ue" spelling throughout the UI text and comments (fuer,
loeschen, koennen, ...) was my own typo, not an encoding bug - the
charset fix in the last commit was unrelated. Replaced all of them
with proper ö/ä/ü across every PHP file and the README.

Also fix table rows rendering inconsistently: `.actions` and the
status badges were applying `display:flex` directly to a <td>, which
fights the table layout model and renders unreliably across browsers.
Moved the flex layout into a wrapper <div> inside each cell instead,
and restyled row-level delete buttons as plain text links so they
match the height of the "Bearbeiten" link exactly. Tables also get a
horizontal-scroll wrapper so narrow viewports scroll instead of
squeezing cell content.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-18 07:16:15 +02:00

82 lines
3.2 KiB
PHP

<?php
require_once __DIR__ . '/../includes/bootstrap.php';
require_permission('users.view');
$canCreate = user_has_permission('users.create');
$canEdit = user_has_permission('users.edit');
$canDelete = user_has_permission('users.delete');
$currentUser = current_user();
$users = db()->query(
'SELECT u.id, u.username, u.display_name, u.status, u.last_login, u.must_change_password,
GROUP_CONCAT(r.name ORDER BY r.name SEPARATOR ", ") AS role_names
FROM users u
LEFT JOIN user_roles ur ON ur.user_id = u.id
LEFT JOIN roles r ON r.id = ur.role_id
GROUP BY u.id
ORDER BY u.username'
)->fetchAll();
$pageTitle = 'Benutzerverwaltung';
include __DIR__ . '/../includes/header.php';
?>
<div class="panel">
<h1>Benutzerverwaltung</h1>
<p class="text-muted">Nur für Administratoren sichtbar.</p>
<?php if ($canCreate): ?>
<p><a class="button" href="/admin/user_form.php">Neuen Benutzer anlegen</a></p>
<?php endif; ?>
<div class="table-scroll">
<table>
<thead>
<tr>
<th>Benutzername</th>
<th>Anzeigename</th>
<th>Berechtigungsgruppen</th>
<th>Status</th>
<th>Letzter Login</th>
<?php if ($canEdit || $canDelete): ?><th>Aktionen</th><?php endif; ?>
</tr>
</thead>
<tbody>
<?php foreach ($users as $u): ?>
<tr>
<td><?= e($u['username']) ?></td>
<td><?= e($u['display_name']) ?></td>
<td><?= e($u['role_names'] ?: '-') ?></td>
<td>
<div class="badge-group">
<span class="badge <?= $u['status'] === 'active' ? 'badge-active' : 'badge-disabled' ?>">
<?= $u['status'] === 'active' ? 'Aktiv' : 'Deaktiviert' ?>
</span>
<?php if ($u['must_change_password']): ?>
<span class="badge" title="Benutzer muss beim nächsten Login das Passwort ändern">Passwortänderung ausstehend</span>
<?php endif; ?>
</div>
</td>
<td><?= e($u['last_login'] ?? 'nie') ?></td>
<?php if ($canEdit || $canDelete): ?>
<td>
<div class="actions">
<?php if ($canEdit): ?>
<a href="/admin/user_form.php?id=<?= (int) $u['id'] ?>">Bearbeiten</a>
<?php endif; ?>
<?php if ($canDelete && (int) $u['id'] !== (int) $currentUser['id']): ?>
<form class="inline-form" method="post" action="/admin/user_delete.php" onsubmit="return confirm('Diesen Benutzer wirklich löschen?');">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int) $u['id'] ?>">
<button type="submit" class="text-button">Löschen</button>
</form>
<?php endif; ?>
</div>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php include __DIR__ . '/../includes/footer.php'; ?>