67a454e898d81bd743ac873ffddce002dc2edc2f
2 /***************************************************************************
3 * Copyright (C) 2003-2008 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class ForumsModule
extends PLModule
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'),
33 function on_subscribe($forlife, $uid, $promo, $password)
35 $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements');
36 $p_for = "xorg.promo.x$promo";
38 // récupération de l'id du forum promo
39 $res = XDB
::query("SELECT fid FROM forums.list WHERE nom={?}", $p_for);
40 if ($res->numRows()) {
42 } else { // pas de forum promo, il faut le créer
43 $res = XDB
::query("SELECT SUM(perms IN ('admin','user') AND deces=0),COUNT(*)
44 FROM auth_user_md5 WHERE promo={?}", $promo);
45 list($effau, $effid) = $res->fetchOneRow();
46 if (5*$effau>$effid) { // + de 20% d'inscrits
47 $mymail = new PlMailer('admin/forums-promo.mail.tpl');
48 $mymail->assign('promo', $promo);
53 while (list ($key, $val) = each ($cible)) {
54 XDB
::execute("INSERT INTO forums.abos (fid,uid)
55 SELECT fid,{?} FROM forums.list WHERE nom={?}", $uid, $val);
59 function handler_banana(&$page, $group = null
, $action = null
, $artid = null
)
61 $page->changeTpl('banana/index.tpl');
62 $page->setTitle('Forums & PA');
65 if (Post
::has('updateall')) {
66 $get['updateall'] = Post
::v('updateall');
68 require_once 'banana/forum.inc.php';
69 get_banana_params($get, $group, $action, $artid);
70 run_banana($page, 'ForumsBanana', $get);
73 function handler_rss(&$page, $group, $alias, $hash, $file = null
)
79 $this->handler_rss($page, null
, $group, $alias, $hash);
81 require_once('rss.inc.php');
82 $uid = init_rss(null
, $alias, $hash);
86 $res = XDB
::query("SELECT id AS uid, alias AS forlife
88 WHERE type = 'a_vie' AND id = {?}", $uid);
89 $row = $res->fetchOneAssoc();
90 $_SESSION = array_merge($row, $_SESSION);
92 require_once 'banana/forum.inc.php';
93 $banana = new ForumsBanana(S
::user(), array('group' => $group, 'action' => 'rss2'));
98 function handler_forums_bans(&$page, $action = 'list', $id = null
)
100 $page->setTitle('Administration - Bannissements des forums');
101 $page->assign('title', 'Gestion des mises au ban');
102 $table_editor = new PLTableEditor('admin/forums','forums.innd','id_innd');
103 $table_editor->add_sort_field('priority', true
, true
);
104 $table_editor->describe('read_perm','lecture',true
);
105 $table_editor->describe('write_perm','écriture',true
);
106 $table_editor->describe('priority','priorité',true
);
107 $table_editor->describe('comment','commentaire',true
);
108 $table_editor->apply($page, $action, $id);
109 $page->changeTpl('forums/admin.tpl');
110 $page->addJsLink('jquery.js');
113 static function run_banana(&$page, $params = null
)
115 $page->changeTpl('banana/index.tpl');
116 $page->setTitle('Forums & PA');
118 require_once 'banana/forum.inc.php';
119 run_banana($page, 'ForumsBanana', $params);
123 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: