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
::v('action')=="OK" ))
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 = {?}", S
::v('uid'));
76 if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
77 $nom = S
::v('prenom').' '.S
::v('nom');
78 $mail = S
::v('forlife').'@'.$globals->mail
->domain
;
79 $sig = $nom.' ('.S
::v('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);
90 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags)
91 VALUES ({?},{?},{?},{?},{?})',
92 S
::v('uid'), Post
::v('bananasig'),
93 Post
::v('bananamail'), Post
::v('banananame'),
94 (Post
::b('bananadisplay') ?
'threads,' : '') .
95 (Post
::b('bananaupdate') ?
'automaj' : '')
100 function handler_subscription(&$page)
102 return $this->run_banana($page, Array('subscribe' => 1));
105 function handler_xface(&$page, $face = null
)
107 header('Content-Type: image/gif');
108 passthru('echo ' . escapeshellarg(base64_decode(strtr($face, '.:', '+/')))
110 . '| convert -transparent white xbm:- gif:-');
113 function run_banana(&$page, $params = null
)
115 $page->changeTpl('banana/index.tpl');
116 $page->addCssLink('css/banana.css');
117 $page->assign('xorg_title','Polytechnique.org - Forums & PA');
119 require_once dirname(__FILE__
).'/banana/banana.inc.php';
121 $res = PlatalBanana
::run($params);
122 $page->assign_by_ref('banana', $banana);
123 $page->assign('banana_res', $res);