Merge branch 'platal-0.10.0'
[platal.git] / modules / forums.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2009 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),
28 'banana/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', 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 exit;
52 }
53 $this->handler_rss($page, null, $group, $alias, $hash);
54 }
55 require_once('rss.inc.php');
56 $uid = init_rss(null, $alias, $hash);
57 if (!$uid) {
58 exit;
59 }
60 $res = XDB::query("SELECT id AS uid, alias AS forlife
61 FROM aliases
62 WHERE type = 'a_vie' AND id = {?}", $uid);
63 $row = $res->fetchOneAssoc();
64 $_SESSION = array_merge($row, $_SESSION);
65
66 require_once 'banana/forum.inc.php';
67 $banana = new ForumsBanana(S::user(), array('group' => $group, 'action' => 'rss2'));
68 $banana->run();
69 exit;
70 }
71
72 function handler_forums_bans(&$page, $action = 'list', $id = null)
73 {
74 $page->setTitle('Administration - Bannissements des forums');
75 $page->assign('title', 'Gestion des mises au ban');
76 $table_editor = new PLTableEditor('admin/forums','forums.innd','id_innd');
77 $table_editor->add_sort_field('priority', true, true);
78 $table_editor->describe('read_perm','lecture',true);
79 $table_editor->describe('write_perm','écriture',true);
80 $table_editor->describe('priority','priorité',true);
81 $table_editor->describe('comment','commentaire',true);
82 $table_editor->apply($page, $action, $id);
83 $page->changeTpl('forums/admin.tpl');
84 $page->addJsLink('jquery.js');
85 }
86
87 static function run_banana(&$page, $params = null)
88 {
89 $page->changeTpl('banana/index.tpl');
90 $page->setTitle('Forums & PA');
91
92 require_once 'banana/forum.inc.php';
93 run_banana($page, 'ForumsBanana', $params);
94 }
95 }
96
97 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
98 ?>