xref: /webtrees/app/Http/RequestHandlers/UserListPage.php (revision 89f7189b61a494347591c99bdb92afb7d8b66e1b)
14c3563c0SGreg Roach<?php
24c3563c0SGreg Roach
34c3563c0SGreg Roach/**
44c3563c0SGreg Roach * webtrees: online genealogy
54c3563c0SGreg Roach * Copyright (C) 2021 webtrees development team
64c3563c0SGreg Roach * This program is free software: you can redistribute it and/or modify
74c3563c0SGreg Roach * it under the terms of the GNU General Public License as published by
84c3563c0SGreg Roach * the Free Software Foundation, either version 3 of the License, or
94c3563c0SGreg Roach * (at your option) any later version.
104c3563c0SGreg Roach * This program is distributed in the hope that it will be useful,
114c3563c0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
124c3563c0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134c3563c0SGreg Roach * GNU General Public License for more details.
144c3563c0SGreg Roach * You should have received a copy of the GNU General Public License
15*89f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
164c3563c0SGreg Roach */
174c3563c0SGreg Roach
184c3563c0SGreg Roachdeclare(strict_types=1);
194c3563c0SGreg Roach
204c3563c0SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
214c3563c0SGreg Roach
224c3563c0SGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait;
234c3563c0SGreg Roachuse Fisharebest\Webtrees\I18N;
244c3563c0SGreg Roachuse Psr\Http\Message\ResponseInterface;
254c3563c0SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
264c3563c0SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
274c3563c0SGreg Roach
284c3563c0SGreg Roach/**
294c3563c0SGreg Roach * List of users.
304c3563c0SGreg Roach */
314c3563c0SGreg Roachclass UserListPage implements RequestHandlerInterface
324c3563c0SGreg Roach{
334c3563c0SGreg Roach    use ViewResponseTrait;
344c3563c0SGreg Roach
354c3563c0SGreg Roach    /**
364c3563c0SGreg Roach     * @param ServerRequestInterface $request
374c3563c0SGreg Roach     *
384c3563c0SGreg Roach     * @return ResponseInterface
394c3563c0SGreg Roach     */
404c3563c0SGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
414c3563c0SGreg Roach    {
424c3563c0SGreg Roach        $this->layout = 'layouts/administration';
434c3563c0SGreg Roach
444c3563c0SGreg Roach        $user = $request->getAttribute('user');
454c3563c0SGreg Roach
464c3563c0SGreg Roach        $params = (array) $request->getQueryParams();
474c3563c0SGreg Roach        $filter = $params['filter'] ?? '';
484c3563c0SGreg Roach
494c3563c0SGreg Roach        $page_size = (int) $user->getPreference(' admin_users_page_size', '10');
504c3563c0SGreg Roach
514c3563c0SGreg Roach        $title = I18N::translate('User administration');
524c3563c0SGreg Roach
534c3563c0SGreg Roach        return $this->viewResponse('admin/users', [
544c3563c0SGreg Roach            'filter'    => $filter,
554c3563c0SGreg Roach            'page_size' => $page_size,
564c3563c0SGreg Roach            'title'     => $title,
574c3563c0SGreg Roach        ]);
584c3563c0SGreg Roach    }
594c3563c0SGreg Roach}
60