rinkplanner/hub/views/admin_users.php

85 lines
4.7 KiB
PHP
Raw Normal View History

<?php /** @var array $users */ ?>
<?php $me = auth_user(); ?>
<div class="page-head">
<div>
<h1>Verwaltung</h1>
<p class="muted">Beta-Konten verwalten.</p>
</div>
</div>
<?php $active = 'users'; require HUB_ROOT . '/views/_admin_nav.php'; ?>
<section class="panel">
<h2>Benutzer</h2>
<div class="table-wrap">
<table class="list compact">
<thead>
<tr><th>Benutzer</th><th>Rolle</th><th>Status</th><th>Küren</th><th>Registriert</th><th>Letzte Anmeldung</th><th>Aktionen</th></tr>
</thead>
<tbody>
<?php foreach ($users as $user): ?>
<tr>
<td>
<strong><?= e($user['display_name']) ?></strong>
<span class="muted">@<?= e($user['username']) ?></span>
<?php if (!empty($user['email'])): ?>
<div class="muted small"><?= e($user['email']) ?></div>
<?php endif; ?>
</td>
<td><?= $user['role'] === 'admin' ? 'Admin' : 'Nutzer' ?></td>
<td>
<span class="status status-<?= $user['status'] === 'active' ? 'open' : 'expired' ?>">
<?= $user['status'] === 'active' ? 'aktiv' : 'gesperrt' ?>
</span>
</td>
<td><?= (int) $user['routine_count'] ?></td>
<td><?= e(fmt_dt($user['created_at'])) ?></td>
<td><?= e(fmt_dt($user['last_login_at'])) ?></td>
<td>
<?php if ((int) $user['id'] === (int) $me['id']): ?>
<span class="muted small">eigenes Konto</span>
<?php else: ?>
<div class="row-actions">
<?php if ($user['status'] === 'active'): ?>
<form class="inline" method="post" action="<?= e(url('/admin/users/action')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
<input type="hidden" name="action" value="disable">
<button class="link-button danger" type="submit">sperren</button>
</form>
<?php else: ?>
<form class="inline" method="post" action="<?= e(url('/admin/users/action')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
<input type="hidden" name="action" value="enable">
<button class="link-button" type="submit">entsperren</button>
</form>
<?php endif; ?>
<form class="inline" method="post" action="<?= e(url('/admin/users/action')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
<input type="hidden" name="action" value="reset">
<button class="link-button" type="submit">Passwort zurücksetzen</button>
</form>
<details class="danger-zone">
<summary>löschen</summary>
<form method="post" action="<?= e(url('/admin/users/action')) ?>" class="stack-tight">
<?= csrf_field() ?>
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
<input type="hidden" name="action" value="delete">
<label class="check small">
<input type="checkbox" name="confirm" value="1" required>
mit allen Küren löschen
</label>
<button class="link-button danger" type="submit">Löschen bestätigen</button>
</form>
</details>
</div>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</section>