xref: /webtrees/resources/views/admin/users-cleanup.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
10c0910bfSGreg Roach<?php
2dd6b2bfcSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
51fe542e9SGreg Roachuse Fisharebest\Webtrees\Contracts\UserInterface;
60c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
74c3563c0SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\UserEditPage;
84c3563c0SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\UserListPage;
92474349cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\UsersCleanupAction;
100c0910bfSGreg Roachuse Fisharebest\Webtrees\I18N;
11d97083feSGreg Roachuse Fisharebest\Webtrees\Registry;
127c2c99faSGreg Roachuse Illuminate\Support\Collection;
137c2c99faSGreg Roach
147c2c99faSGreg Roach/**
1536779af1SGreg Roach * @var Collection<int,UserInterface> $inactive_users
167c2c99faSGreg Roach * @var string                        $title
1736779af1SGreg Roach * @var Collection<int,UserInterface> $unverified_users
187c2c99faSGreg Roach */
190c0910bfSGreg Roach
200c0910bfSGreg Roach?>
210c0910bfSGreg Roach
224c3563c0SGreg Roach<?= view('components/breadcrumbs', ['links' => [
234c3563c0SGreg Roach    route(ControlPanel::class) => I18N::translate('Control panel'),
244c3563c0SGreg Roach    route(UserListPage::class) => I18N::translate('User administration'),
254c3563c0SGreg Roach    $title,
264c3563c0SGreg Roach]]) ?>
27dd6b2bfcSGreg Roach
28dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
29dd6b2bfcSGreg Roach
302474349cSGreg Roach<form method="post" action="<?= e(route(UsersCleanupAction::class)) ?>">
31dd6b2bfcSGreg Roach    <table class="table table-bordered">
32dd6b2bfcSGreg Roach        <?php foreach ($inactive_users as $user) : ?>
33dd6b2bfcSGreg Roach            <tr>
34dd6b2bfcSGreg Roach                <td>
355e62dd03SGreg Roach                    <input type="checkbox" name="delete[]" value="<?= $user->id() ?>" aria-label="<?= e($user->userName()) ?>">
365e62dd03SGreg Roach                </td>
375e62dd03SGreg Roach                <td>
384c3563c0SGreg Roach                    <a href="<?= e(route(UserEditPage::class, ['user_id' => $user->id()])) ?>">
39c65e00b4SGreg Roach                        <?= e($user->userName()) ?>
40dd6b2bfcSGreg Roach41315eb316SGreg Roach                        <bdi><?= e($user->realName()) ?></bdi>
42dd6b2bfcSGreg Roach                    </a>
43dd6b2bfcSGreg Roach                </td>
44dd6b2bfcSGreg Roach                <td>
454459dc9aSGreg Roach                    <?= I18N::translate('User’s account has been inactive too long: ') ?>
46d97083feSGreg Roach                    <?= view('components/datetime', ['timestamp' => Registry::timestampFactory()->make(max((int) $user->getPreference(UserInterface::PREF_TIMESTAMP_REGISTERED), (int) $user->getPreference(UserInterface::PREF_TIMESTAMP_ACTIVE)))]) ?>
47dd6b2bfcSGreg Roach                </td>
48dd6b2bfcSGreg Roach            </tr>
49dd6b2bfcSGreg Roach        <?php endforeach ?>
50dd6b2bfcSGreg Roach
51dd6b2bfcSGreg Roach        <?php foreach ($unverified_users as $user) : ?>
52dd6b2bfcSGreg Roach            <tr>
53dd6b2bfcSGreg Roach                <td>
545e62dd03SGreg Roach                    <input type="checkbox" name="delete[]" value="<?= $user->id() ?>" aria-label="<?= e($user->userName()) ?>">
555e62dd03SGreg Roach                </td>
565e62dd03SGreg Roach                <td>
574c3563c0SGreg Roach                    <a href="<?= e(route(UserEditPage::class, ['user_id' => $user->id()])) ?>">
58c65e00b4SGreg Roach                        <?= e($user->userName()) ?>
59dd6b2bfcSGreg Roach60315eb316SGreg Roach                        <bdi><?= e($user->realName()) ?></bdi>
61dd6b2bfcSGreg Roach                    </a>
62dd6b2bfcSGreg Roach                </td>
63dd6b2bfcSGreg Roach                <td>
64dd6b2bfcSGreg Roach                    <?= I18N::translate('User didn’t verify within 7 days.') ?>
651fe542e9SGreg Roach                    <?php if ($user->getPreference(UserInterface::PREF_IS_ACCOUNT_APPROVED) !== '1') : ?>
66dd6b2bfcSGreg Roach                        <?= I18N::translate('User not verified by administrator.') ?>
67dd6b2bfcSGreg Roach                    <?php endif ?>
68dd6b2bfcSGreg Roach                </td>
69dd6b2bfcSGreg Roach            </tr>
70dd6b2bfcSGreg Roach        <?php endforeach ?>
71dd6b2bfcSGreg Roach    </table>
72dd6b2bfcSGreg Roach
73dd6b2bfcSGreg Roach    <p>
742474349cSGreg Roach        <?php if ($inactive_users->isEmpty() && $unverified_users->isEmpty()) : ?>
75dd6b2bfcSGreg Roach            <?= I18N::translate('Nothing found to cleanup') ?>
76dd6b2bfcSGreg Roach        <?php else : ?>
77dd6b2bfcSGreg Roach            <button type="submit" class="btn btn-primary">
78dd6b2bfcSGreg Roach                <?= I18N::translate('delete') ?>
79dd6b2bfcSGreg Roach            </button>
80dd6b2bfcSGreg Roach        <?php endif ?>
81dd6b2bfcSGreg Roach    </p>
8281443e3cSGreg Roach
8381443e3cSGreg Roach    <?= csrf_field() ?>
84dd6b2bfcSGreg Roach</form>
85