| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
| 4 | * http://opensource.polytechnique.org/ * |
| 5 | * * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, write to the Free Software * |
| 18 | * Foundation, Inc., * |
| 19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | class ForumsModule extends PLModule |
| 23 | { |
| 24 | function handlers() |
| 25 | { |
| 26 | return array( |
| 27 | 'banana' => $this->make_hook('banana', AUTH_COOKIE, 'forums'), |
| 28 | 'banana/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'forums', NO_HTTPS), |
| 29 | 'admin/forums' => $this->make_hook('forums_bans', AUTH_MDP, 'admin'), |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | function handler_banana($page, $group = null, $action = null, $artid = null) |
| 34 | { |
| 35 | $page->changeTpl('banana/index.tpl'); |
| 36 | $page->setTitle('Forums & PA'); |
| 37 | |
| 38 | $get = Array(); |
| 39 | if (Post::has('updateall')) { |
| 40 | $get['updateall'] = Post::v('updateall'); |
| 41 | } |
| 42 | require_once 'banana/forum.inc.php'; |
| 43 | get_banana_params($get, $group, $action, $artid); |
| 44 | run_banana($page, 'ForumsBanana', $get); |
| 45 | } |
| 46 | |
| 47 | function handler_rss($page, $group, $alias, $hash, $file = null) |
| 48 | { |
| 49 | if (is_null($file)) { |
| 50 | if (is_null($hash)) { |
| 51 | return PL_FORBIDDEN; |
| 52 | } |
| 53 | $this->handler_rss($page, null, $group, $alias, $hash); |
| 54 | } |
| 55 | $user = Platal::session()->tokenAuth($alias, $hash); |
| 56 | if (is_null($user)) { |
| 57 | return PL_FORBIDDEN; |
| 58 | } |
| 59 | |
| 60 | require_once 'banana/forum.inc.php'; |
| 61 | $banana = new ForumsBanana($user, array('group' => $group, 'action' => 'rss2')); |
| 62 | $banana->run(); |
| 63 | exit; |
| 64 | } |
| 65 | |
| 66 | function handler_forums_bans($page, $action = 'list', $id = null) |
| 67 | { |
| 68 | $page->setTitle('Administration - Bannissements des forums'); |
| 69 | $page->assign('title', 'Gestion des mises au ban'); |
| 70 | $table_editor = new PLTableEditor('admin/forums','forum_innd','id_innd'); |
| 71 | $table_editor->add_sort_field('priority', true, true); |
| 72 | $table_editor->describe('read_perm','lecture',true); |
| 73 | $table_editor->describe('write_perm','écriture',true); |
| 74 | $table_editor->describe('priority','priorité',true); |
| 75 | $table_editor->describe('comment','commentaire',true); |
| 76 | $table_editor->apply($page, $action, $id); |
| 77 | $page->changeTpl('forums/admin.tpl'); |
| 78 | } |
| 79 | |
| 80 | static function run_banana($page, $params = null) |
| 81 | { |
| 82 | $page->changeTpl('banana/index.tpl'); |
| 83 | $page->setTitle('Forums & PA'); |
| 84 | |
| 85 | require_once 'banana/forum.inc.php'; |
| 86 | run_banana($page, 'ForumsBanana', $params); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
| 91 | ?> |