2020-10-23 07:13:39 +09:00
|
|
|
<?php
|
|
|
|
// {{{ License
|
|
|
|
|
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
2020-11-10 06:25:57 +09:00
|
|
|
namespace Plugin\Poll;
|
2020-10-23 07:13:39 +09:00
|
|
|
|
|
|
|
use App\Core\Event;
|
|
|
|
use App\Core\Module;
|
2020-11-10 02:43:10 +09:00
|
|
|
use App\Core\Router\RouteLoader;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
|
2020-10-30 03:32:35 +09:00
|
|
|
|
|
|
|
const ID_FMT = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
|
2020-10-23 07:13:39 +09:00
|
|
|
|
2020-11-10 06:25:57 +09:00
|
|
|
/**
|
|
|
|
* Poll plugin main class
|
|
|
|
*
|
|
|
|
* @package GNUsocial
|
|
|
|
* @category PollPlugin
|
|
|
|
*
|
|
|
|
* @author Daniel Brandao <up201705812@fe.up.pt>
|
|
|
|
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
|
|
|
*/
|
|
|
|
class Poll extends Module
|
2020-10-23 07:13:39 +09:00
|
|
|
{
|
2020-11-10 02:43:10 +09:00
|
|
|
/**
|
|
|
|
* Map URLs to actions
|
|
|
|
*
|
|
|
|
* @param RouteLoader $r
|
|
|
|
*
|
|
|
|
* @return bool hook value; true means continue processing, false means stop.
|
|
|
|
*/
|
|
|
|
public function onAddRoute(RouteLoader $r): bool
|
2020-10-23 07:13:39 +09:00
|
|
|
{
|
2020-11-10 02:43:10 +09:00
|
|
|
$r->connect('newpollnum', 'main/poll/new/{num<\\d*>}', [Controller\NewPoll::class, 'newpoll']);
|
2020-11-04 00:53:46 +09:00
|
|
|
$r->connect('showpoll', 'main/poll/{id<\\d*>}',[Controller\ShowPoll::class, 'showpoll']);
|
2020-11-10 06:25:57 +09:00
|
|
|
$r->connect('answerpoll', 'main/poll/{id<\\d*>}/respond',[Controller\AnswerPoll::class, 'answerpoll']);
|
2020-11-10 02:43:10 +09:00
|
|
|
$r->connect('newpoll', 'main/poll/new', RedirectController::class, ['defaults' => ['route' => 'newpollnum', 'num' => 3]]);
|
2020-10-23 07:13:39 +09:00
|
|
|
|
|
|
|
return Event::next;
|
|
|
|
}
|
|
|
|
}
|