2 /***************************************************************************
3 * Copyright (C) 2003-2006 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 BananaModule
extends PLModule
27 'banana' => $this->make_hook('banana', AUTH_COOKIE
),
28 'banana/profile' => $this->make_hook('profile', AUTH_MDP
),
29 'banana/subscription' => $this->make_hook('subscription', AUTH_COOKIE
),
30 'banana/xface' => $this->make_hook('xface', AUTH_COOKIE
),
34 function handler_banana(&$page, $group = null
, $action = null
, $artid = null
)
37 if (!is_null($group)) {
38 $get['group'] = $group;
40 if (Post
::has('updateall')) {
41 $get['banana'] = 'updateall';
43 if (!is_null($action)) {
44 if ($action == 'new') {
45 $get['action'] = 'new';
46 } elseif ($action == 'reply' && !is_null($artid)) {
47 $get['action'] = 'new';
48 $get['artid'] = $artid;
49 } elseif ($action == 'cancel' && !is_null($artid)) {
50 $get['action'] = $action;
51 $get['artid'] = $artid;
52 } elseif ($action == 'from' && !is_null($artid)) {
53 $get['first'] = $artid;
54 } elseif ($action == 'read' && !is_null($artid)) {
55 $get['artid'] = $artid;
58 return BananaModule
::run_banana($page, $get);
61 function handler_profile(&$page, $action = null
)
65 $page->changeTpl('banana/profile.tpl');
67 if (!(Post
::has('action') && Post
::has('banananame') && Post
::has('bananasig')
68 && Post
::has('bananadisplay') && Post
::has('bananamail')
69 && Post
::has('bananaupdate') && Post
::get('action')=="OK" ))
71 $req = $globals->xdb
->query("
72 SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
73 IF(FIND_IN_SET('automaj',flags),'1','0')
75 WHERE uid = {?}", Session
::getInt('uid'));
76 if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
77 $nom = Session
::get('prenom').' '.Session
::get('nom');
78 $mail = Session
::get('forlife').'@'.$globals->mail
->domain
;
79 $sig = $nom.' ('.Session
::getInt('promo').')';
83 $page->assign('nom' , $nom);
84 $page->assign('mail', $mail);
85 $page->assign('sig' , $sig);
86 $page->assign('disp', $disp);
87 $page->assign('maj' , $maj);
89 $globals->xdb
->execute(
90 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags)
91 VALUES ({?},{?},{?},{?},{?})',
92 Session
::getInt('uid'), Post
::get('bananasig'),
93 Post
::get('bananamail'), Post
::get('banananame'),
94 (Post
::getBool('bananadisplay') ?
'threads,' : '') .
95 (Post
::getBool('bananaupdate') ?
'automaj' : '')
102 function handler_subscription(&$page)
104 return $this->run_banana($page, Array('subscribe' => 1));
107 function handler_xface(&$page, $face = null
)
109 header('Content-Type: image/gif');
110 passthru('echo ' . escapeshellarg(base64_decode(strtr($face, '.:', '+/')))
112 . '| convert -transparent white xbm:- gif:-');
116 function run_banana(&$page, $params = null
)
118 $page->changeTpl('banana/index.tpl');
119 $page->addCssLink('css/banana.css');
120 $page->assign('xorg_title','Polytechnique.org - Forums & PA');
122 require_once('banana.inc.php');
124 $res = PlatalBanana
::run($params);
125 $page->assign_by_ref('banana', $banana);
126 $page->assign('banana_res', $res);