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/updateall' => $this->make_hook('updateall', AUTH_COOKIE
),
31 'banana/xface' => $this->make_hook('xface', AUTH_COOKIE
),
35 function handler_banana(&$page, $group = null
, $action = null
, $artid = null
)
38 if (!is_null($group)) {
39 $get['group'] = $group;
41 if (!is_null($action)) {
42 if ($action == 'new') {
43 $get['action'] = 'new';
44 } elseif (($action == 'reply' ||
$action == 'cancel') && !is_null($artid)) {
45 $get['action'] = $action;
46 $get['artid'] = $artid;
47 } elseif ($action == 'from' && !is_null($artid)) {
48 $get['first'] = $artid;
49 } elseif ($action == 'read' && !is_null($artid)) {
50 $get['artid'] = $artid;
53 return BananaModule
::run_banana($page, $get);
56 function handler_profile(&$page, $action = null
)
60 $page->changeTpl('banana/profile.tpl');
62 if (!(Post
::has('action') && Post
::has('banananame') && Post
::has('bananasig')
63 && Post
::has('bananadisplay') && Post
::has('bananamail')
64 && Post
::has('bananaupdate') && Post
::get('action')=="OK" ))
66 $req = $globals->xdb
->query("
67 SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
68 IF(FIND_IN_SET('automaj',flags),'1','0')
70 WHERE uid = {?}", Session
::getInt('uid'));
71 if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
72 $nom = Session
::get('prenom').' '.Session
::get('nom');
73 $mail = Session
::get('forlife').'@'.$globals->mail
->domain
;
74 $sig = $nom.' ('.Session
::getInt('promo').')';
78 $page->assign('nom' , $nom);
79 $page->assign('mail', $mail);
80 $page->assign('sig' , $sig);
81 $page->assign('disp', $disp);
82 $page->assign('maj' , $maj);
84 $globals->xdb
->execute(
85 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags)
86 VALUES ({?},{?},{?},{?},{?})',
87 Session
::getInt('uid'), Post
::get('bananasig'),
88 Post
::get('bananamail'), Post
::get('banananame'),
89 (Post
::getBool('bananadisplay') ?
'threads,' : '') .
90 (Post
::getBool('bananaupdate') ?
'automaj' : '')
97 function handler_updateall(&$page)
99 return BananaModule
::run_banana($page, Array('banana' => 'updateall'));
102 function handler_subscription(&$page)
104 return $this->run_banana($page, Array('subscribe' => 1));
107 function handler_xface()
109 $args = func_get_args();
111 $face = join('/', $args);
112 header('Content-Type: image/jpeg');
113 passthru('echo ' . escapeshellarg(base64_decode($face))
115 . '| convert xbm:- jpg:-');
119 function run_banana(&$page, $params = null
)
121 $page->changeTpl('banana/index.tpl');
122 $page->addCssLink('css/banana.css');
123 $page->assign('xorg_title','Polytechnique.org - Forums & PA');
125 require_once('banana.inc.php');
127 $res = PlatalBanana
::run($params);
128 $page->assign_by_ref('banana', $banana);
129 $page->assign('banana_res', $res);