3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link http://galette.tuxfamily.org
34 * @since 0.8.2dev 2014-11-11
37 use Galette\Controllers\Crud
;
39 use Galette\Repository\Members
;
40 use Galette\Filters\MembersList
;
42 $showPublicPages = function ($request, $response, $next) use ($container) {
43 $login = $container->login
;
44 $preferences = $container->preferences
;
46 if (!$preferences->showPublicPages($login)) {
47 $this->flash
->addMessage('error', _T("Unauthorized"));
53 $this->router
->pathFor('slash')
57 return $next($request, $response);
60 $app->group('/public', function () {
63 '/{type:list|trombi}[/{option:page|order}/{value:\d+}]',
64 Crud\MembersController
::class . ':publicList'
65 )->setName('publicList');
67 //members list filtering
69 '/{type:list|trombi}/filter[/{from}]',
70 Crud\MembersController
::class . ':filterPublicList'
71 )->setName('filterPublicList');
74 '/members[/{option:page|order}/{value:\d+}]',
75 function ($request, $response, $args = []) {
76 $args['type'] = 'list';
79 ->withHeader('Location', $this->router
->pathFor('publicList', $args));
85 function ($request, $response, $args = []) {
86 $args['type'] = 'trombi';
89 ->withHeader('Location', $this->router
->pathFor('publicList', $args));
92 })->add($showPublicPages);