xref: /webtrees/resources/views/admin/users-cleanup.phtml (revision 3f0247b283a74c64ac885446380ea81de9cf779e)
1<?php
2
3use Fisharebest\Webtrees\Contracts\UserInterface;
4use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
5use Fisharebest\Webtrees\Http\RequestHandlers\UserEditPage;
6use Fisharebest\Webtrees\Http\RequestHandlers\UserListPage;
7use Fisharebest\Webtrees\Http\RequestHandlers\UsersCleanupAction;
8use Fisharebest\Webtrees\I18N;
9use Fisharebest\Webtrees\Registry;
10use Illuminate\Support\Collection;
11
12/**
13 * @var Collection<int,UserInterface> $inactive_users
14 * @var string                        $title
15 * @var Collection<int,UserInterface> $unverified_users
16 */
17
18?>
19
20<?= view('components/breadcrumbs', ['links' => [
21    route(ControlPanel::class) => I18N::translate('Control panel'),
22    route(UserListPage::class) => I18N::translate('User administration'),
23    $title,
24]]) ?>
25
26<h1><?= $title ?></h1>
27
28<form method="post" action="<?= e(route(UsersCleanupAction::class)) ?>">
29    <table class="table table-bordered">
30        <?php foreach ($inactive_users as $user) : ?>
31            <tr>
32                <td>
33                    <input type="checkbox" name="delete[]" value="<?= $user->id() ?>" aria-label="<?= e($user->userName()) ?>">
34                </td>
35                <td>
36                    <a href="<?= e(route(UserEditPage::class, ['user_id' => $user->id()])) ?>">
37                        <?= e($user->userName()) ?>
3839                        <bdi><?= e($user->realName()) ?></bdi>
40                    </a>
41                </td>
42                <td>
43                    <?= I18N::translate('User’s account has been inactive too long: ') ?>
44                    <?= view('components/datetime', ['timestamp' => Registry::timestampFactory()->make(max((int) $user->getPreference(UserInterface::PREF_TIMESTAMP_REGISTERED), (int) $user->getPreference(UserInterface::PREF_TIMESTAMP_ACTIVE)))]) ?>
45                </td>
46            </tr>
47        <?php endforeach ?>
48
49        <?php foreach ($unverified_users as $user) : ?>
50            <tr>
51                <td>
52                    <input type="checkbox" name="delete[]" value="<?= $user->id() ?>" aria-label="<?= e($user->userName()) ?>">
53                </td>
54                <td>
55                    <a href="<?= e(route(UserEditPage::class, ['user_id' => $user->id()])) ?>">
56                        <?= e($user->userName()) ?>
5758                        <bdi><?= e($user->realName()) ?></bdi>
59                    </a>
60                </td>
61                <td>
62                    <?= I18N::translate('User didn’t verify within 7 days.') ?>
63                    <?php if ($user->getPreference(UserInterface::PREF_IS_ACCOUNT_APPROVED) !== '1') : ?>
64                        <?= I18N::translate('User not verified by administrator.') ?>
65                    <?php endif ?>
66                </td>
67            </tr>
68        <?php endforeach ?>
69    </table>
70
71    <p>
72        <?php if ($inactive_users->isEmpty() && $unverified_users->isEmpty()) : ?>
73            <?= I18N::translate('Nothing found to cleanup') ?>
74        <?php else : ?>
75            <button type="submit" class="btn btn-primary">
76                <?= I18N::translate('delete') ?>
77            </button>
78        <?php endif ?>
79    </p>
80
81    <?= csrf_field() ?>
82</form>
83