]> git.agnieray.net Git - galette.git/blob - galette/includes/routes/public_pages.routes.php
786e1c5b8ee199d1775d56ea2d71f93475bd9cd9
[galette.git] / galette / includes / routes / public_pages.routes.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Public pages routes
7 *
8 * PHP version 5
9 *
10 * Copyright © 2014 The Galette Team
11 *
12 * This file is part of Galette (http://galette.tuxfamily.org).
13 *
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.
18 *
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.
23 *
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/>.
26 *
27 * @category Routes
28 * @package Galette
29 *
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 * @version SVN: $Id$
34 * @link http://galette.tuxfamily.org
35 * @since 0.8.2dev 2014-11-11
36 */
37
38 use Galette\Controllers\Crud;
39
40 use Galette\Repository\Members;
41 use Galette\Filters\MembersList;
42
43 $showPublicPages = function($request, $response, $next) use ($container) {
44 $login = $container->login;
45 $preferences = $container->preferences;
46
47 if (!$preferences->showPublicPages($login)) {
48 $this->flash->addMessage('error', _T("Unauthorized"));
49
50 return $response
51 ->withStatus(403)
52 ->withHeader(
53 'Location',
54 $this->router->pathFor('slash')
55 );
56 }
57
58 return $next($request, $response);
59 };
60
61 $app->group('/public', function() {
62 //public members list
63 $this->get(
64 '/{type:list|trombi}[/{option:page|order}/{value:\d+}]',
65 Crud\MembersController::class . ':publicList'
66 )->setName('publicList');
67
68 //members list filtering
69 $this->post(
70 '/{type:list|trombi}/filter[/{from}]',
71 Crud\MembersController::class . ':filterPublicList'
72 )->setName('filterPublicList');
73
74 $this->get(
75 '/members[/{option:page|order}/{value:\d+}]',
76 function($request, $response, $args = []) {
77 $args['type'] = 'list';
78 return $response
79 ->withStatus(301)
80 ->withHeader('Location', $this->router->pathFor('publicList', $args));
81 }
82 );
83
84 $this->get(
85 '/trombinoscope',
86 function($request, $response, $args = []) {
87 $args['type'] = 'trombi';
88 return $response
89 ->withStatus(301)
90 ->withHeader('Location', $this->router->pathFor('publicList', $args));
91 }
92 );
93 })->add($showPublicPages);