xref: /webtrees/app/Http/RequestHandlers/UserListPage.php (revision 4c3563c0d95e22997e247ca4944dff997416f927)
1*4c3563c0SGreg Roach<?php
2*4c3563c0SGreg Roach
3*4c3563c0SGreg Roach/**
4*4c3563c0SGreg Roach * webtrees: online genealogy
5*4c3563c0SGreg Roach * Copyright (C) 2021 webtrees development team
6*4c3563c0SGreg Roach * This program is free software: you can redistribute it and/or modify
7*4c3563c0SGreg Roach * it under the terms of the GNU General Public License as published by
8*4c3563c0SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9*4c3563c0SGreg Roach * (at your option) any later version.
10*4c3563c0SGreg Roach * This program is distributed in the hope that it will be useful,
11*4c3563c0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*4c3563c0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*4c3563c0SGreg Roach * GNU General Public License for more details.
14*4c3563c0SGreg Roach * You should have received a copy of the GNU General Public License
15*4c3563c0SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16*4c3563c0SGreg Roach */
17*4c3563c0SGreg Roach
18*4c3563c0SGreg Roachdeclare(strict_types=1);
19*4c3563c0SGreg Roach
20*4c3563c0SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
21*4c3563c0SGreg Roach
22*4c3563c0SGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait;
23*4c3563c0SGreg Roachuse Fisharebest\Webtrees\I18N;
24*4c3563c0SGreg Roachuse Psr\Http\Message\ResponseInterface;
25*4c3563c0SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
26*4c3563c0SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
27*4c3563c0SGreg Roach
28*4c3563c0SGreg Roach/**
29*4c3563c0SGreg Roach * List of users.
30*4c3563c0SGreg Roach */
31*4c3563c0SGreg Roachclass UserListPage implements RequestHandlerInterface
32*4c3563c0SGreg Roach{
33*4c3563c0SGreg Roach    use ViewResponseTrait;
34*4c3563c0SGreg Roach
35*4c3563c0SGreg Roach    /**
36*4c3563c0SGreg Roach     * @param ServerRequestInterface $request
37*4c3563c0SGreg Roach     *
38*4c3563c0SGreg Roach     * @return ResponseInterface
39*4c3563c0SGreg Roach     */
40*4c3563c0SGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
41*4c3563c0SGreg Roach    {
42*4c3563c0SGreg Roach        $this->layout = 'layouts/administration';
43*4c3563c0SGreg Roach
44*4c3563c0SGreg Roach        $user = $request->getAttribute('user');
45*4c3563c0SGreg Roach
46*4c3563c0SGreg Roach        $params = (array) $request->getQueryParams();
47*4c3563c0SGreg Roach        $filter = $params['filter'] ?? '';
48*4c3563c0SGreg Roach
49*4c3563c0SGreg Roach        $page_size = (int) $user->getPreference(' admin_users_page_size', '10');
50*4c3563c0SGreg Roach
51*4c3563c0SGreg Roach        $title = I18N::translate('User administration');
52*4c3563c0SGreg Roach
53*4c3563c0SGreg Roach        return $this->viewResponse('admin/users', [
54*4c3563c0SGreg Roach            'filter'    => $filter,
55*4c3563c0SGreg Roach            'page_size' => $page_size,
56*4c3563c0SGreg Roach            'title'     => $title,
57*4c3563c0SGreg Roach        ]);
58*4c3563c0SGreg Roach    }
59*4c3563c0SGreg Roach}
60