Add height parameter to makeImg hook
[platal.git] / modules / banana.php
CommitLineData
f585e5a4 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2006 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
22class BananaModule extends PLModule
23{
24 function handlers()
25 {
26 return array(
3d9b1d30 27 'banana' => $this->make_hook('banana', AUTH_COOKIE),
28 'banana/profile' => $this->make_hook('profile', AUTH_MDP),
a3a1d23b 29 'banana/subscription' => $this->make_hook('subscription', AUTH_COOKIE),
30 'banana/updateall' => $this->make_hook('updateall', AUTH_COOKIE),
31 );
f585e5a4 32 }
33
3d9b1d30 34 function handler_banana(&$page, $group = null, $action = null, $artid = null)
f585e5a4 35 {
a3a1d23b 36 $get = Array();
37 if (!is_null($group)) {
38 $get['group'] = $group;
39 }
40 if (!is_null($action)) {
41 if ($action == 'new') {
42 $get['action'] = 'new';
43 } elseif (($action == 'reply' || $action == 'cancel') && !is_null($artid)) {
44 $get['action'] = $action;
45 $get['artid'] = $artid;
46 } elseif ($action == 'from' && !is_null($artid)) {
47 $get['first'] = $artid;
48 } elseif ($action == 'read' && !is_null($artid)) {
49 $get['artid'] = $artid;
50 }
51 }
52 return BananaModule::run_banana($page, $get);
f585e5a4 53 }
54
3d9b1d30 55 function handler_profile(&$page, $action = null)
f585e5a4 56 {
57 global $globals;
58
59 $page->changeTpl('banana/profile.tpl');
60
61 if (!(Post::has('action') && Post::has('banananame') && Post::has('bananasig')
62 && Post::has('bananadisplay') && Post::has('bananamail')
63 && Post::has('bananaupdate') && Post::get('action')=="OK" ))
64 {
65 $req = $globals->xdb->query("
66 SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
67 IF(FIND_IN_SET('automaj',flags),'1','0')
68 FROM forums.profils
69 WHERE uid = {?}", Session::getInt('uid'));
70 if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
71 $nom = Session::get('prenom').' '.Session::get('nom');
72 $mail = Session::get('forlife').'@'.$globals->mail->domain;
73 $sig = $nom.' ('.Session::getInt('promo').')';
74 $disp = 0;
75 $maj = 0;
76 }
77 $page->assign('nom' , $nom);
78 $page->assign('mail', $mail);
79 $page->assign('sig' , $sig);
80 $page->assign('disp', $disp);
81 $page->assign('maj' , $maj);
82 } else {
83 $globals->xdb->execute(
84 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags)
85 VALUES ({?},{?},{?},{?},{?})',
a3a1d23b 86 Session::getInt('uid'), Post::get('bananasig'),
87 Post::get('bananamail'), Post::get('banananame'),
88 (Post::getBool('bananadisplay') ? 'threads,' : '') .
89 (Post::getBool('bananaupdate') ? 'automaj' : '')
f585e5a4 90 );
91 }
92
93 return PL_OK;
94 }
3d9b1d30 95
a3a1d23b 96 function handler_updateall(&$page)
97 {
98 return BananaModule::run_banana($page, Array('banana' => 'updateall'));
99 }
3d9b1d30 100
a3a1d23b 101 function handler_subscription(&$page)
102 {
103 return $this->run_banana($page, Array('subscribe' => 1));
104 }
3d9b1d30 105
a3a1d23b 106 function run_banana(&$page, $params = null)
107 {
3d9b1d30 108 $page->changeTpl('banana/index.tpl');
109 $page->addCssLink('css/banana.css');
110 $page->assign('xorg_title','Polytechnique.org - Forums & PA');
111
112 require_once('banana.inc.php');
113
114 $res = PlatalBanana::run($params);
115 $page->assign_by_ref('banana', $banana);
116 $page->assign('banana_res', $res);
117
118 return PL_OK;
a3a1d23b 119 }
f585e5a4 120}
121
122?>