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