remove acces_smtp.php => password/smtp
[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),
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 {
3d9b1d30 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 ({?},{?},{?},{?},{?})',
86 Session::getInt('uid'), Post::get('bananasig'), Post::get('bananamail'), Post::get('banananame'),
87 (Post::getBool('bananadisplay') ? 'threads,' : '') . (Post::getBool('bananaupdate') ? 'automaj' : '')
88 );
89 }
90
91 return PL_OK;
92 }
3d9b1d30 93
94 function handler_updateall(&$page)
95 {
96 return BananaModule::run_banana($page, Array('banana' => 'updateall'));
97 }
98
99 function handler_subscription(&$page)
100 {
101 return $this->run_banana($page, Array('subscribe' => 1));
102 }
103
104 function run_banana(&$page, $params = null)
105 {
106 $page->changeTpl('banana/index.tpl');
107 $page->addCssLink('css/banana.css');
108 $page->assign('xorg_title','Polytechnique.org - Forums & PA');
109
110 require_once('banana.inc.php');
111
112 $res = PlatalBanana::run($params);
113 $page->assign_by_ref('banana', $banana);
114 $page->assign('banana_res', $res);
115
116 return PL_OK;
117 }
f585e5a4 118}
119
120?>