rinkplanner/hub/views/admin_users.php

93 lines
5.2 KiB
PHP
Raw Normal View History

<?php /** @var array $users */ ?>
<?php $me = auth_user(); ?>
<div class="page-head">
<div>
<h1><?= e(t('admin.title')) ?></h1>
<p class="muted"><?= e(t('admin_users.lede')) ?></p>
</div>
</div>
<?php $active = 'users'; require HUB_ROOT . '/views/_admin_nav.php'; ?>
<section class="panel">
<h2><?= e(t('admin.tab_users')) ?></h2>
<div class="table-wrap">
<table class="list compact">
<thead>
<tr>
<th><?= e(t('admin.tab_users')) ?></th>
<th><?= e(t('table.role')) ?></th>
<th><?= e(t('table.status')) ?></th>
<th><?= e(t('table.routines')) ?></th>
<th><?= e(t('table.registered')) ?></th>
<th><?= e(t('table.last_login')) ?></th>
<th><?= e(t('table.actions')) ?></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><?= e($user['role'] === 'admin' ? t('admin_users.role_admin') : t('admin_users.role_user')) ?></td>
<td>
<span class="status status-<?= $user['status'] === 'active' ? 'open' : 'expired' ?>">
<?= e($user['status'] === 'active' ? t('status.active') : t('status.blocked')) ?>
</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"><?= e(t('admin_users.self')) ?></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"><?= e(t('admin_users.block')) ?></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"><?= e(t('admin_users.unblock')) ?></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"><?= e(t('admin_users.reset')) ?></button>
</form>
<details class="danger-zone">
<summary><?= e(t('admin_users.delete')) ?></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>
<?= e(t('admin_users.delete_confirm')) ?>
</label>
<button class="link-button danger" type="submit"><?= e(t('admin_users.delete_submit')) ?></button>
</form>
</details>
</div>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</section>