X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fbanana.php;h=63234c29e94c82af3b60907d78b2d9d069d04690;hb=57e834acf593ac435793ce7e50b472535e724148;hp=b853065cf2f9b724a123728a9d0d810085c4f78a;hpb=86136c76d3aa444fad543bc0e3b12704984d6579;p=platal.git diff --git a/modules/banana.php b/modules/banana.php index b853065..63234c2 100644 --- a/modules/banana.php +++ b/modules/banana.php @@ -24,27 +24,41 @@ class BananaModule extends PLModule function handlers() { return array( - 'banana' => $this->make_hook('banana', AUTH_COOKIE), - 'banana/profile' => $this->make_hook('profile', AUTH_MDP), + 'banana' => $this->make_hook('banana', AUTH_COOKIE), + 'banana/profile' => $this->make_hook('profile', AUTH_MDP), + 'banana/subscription' => $this->make_hook('subscription', AUTH_COOKIE), + 'banana/xface' => $this->make_hook('xface', AUTH_COOKIE), ); } - function handler_banana(&$page) + function handler_banana(&$page, $group = null, $action = null, $artid = null) { - $page->changeTpl('banana/index.tpl'); - $page->addCssLink('css/banana.css'); - $page->assign('xorg_title','Polytechnique.org - Forums & PA'); - - require_once 'banana.inc.php'; - - $res = PlatalBanana::run(); - $page->assign_by_ref('banana', $banana); - $page->assign('banana_res', $res); - - return PL_OK; + $get = Array(); + if (!is_null($group)) { + $get['group'] = $group; + } + if (Post::has('updateall')) { + $get['banana'] = 'updateall'; + } + if (!is_null($action)) { + if ($action == 'new') { + $get['action'] = 'new'; + } elseif ($action == 'reply' && !is_null($artid)) { + $get['action'] = 'new'; + $get['artid'] = $artid; + } elseif ($action == 'cancel' && !is_null($artid)) { + $get['action'] = $action; + $get['artid'] = $artid; + } elseif ($action == 'from' && !is_null($artid)) { + $get['first'] = $artid; + } elseif ($action == 'read' && !is_null($artid)) { + $get['artid'] = $artid; + } + } + return BananaModule::run_banana($page, $get); } - function handler_profile(&$page) + function handler_profile(&$page, $action = null) { global $globals; @@ -52,17 +66,17 @@ class BananaModule extends PLModule if (!(Post::has('action') && Post::has('banananame') && Post::has('bananasig') && Post::has('bananadisplay') && Post::has('bananamail') - && Post::has('bananaupdate') && Post::get('action')=="OK" )) + && Post::has('bananaupdate') && Post::v('action')=="OK" )) { - $req = $globals->xdb->query(" + $req = XDB::query(" SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'), IF(FIND_IN_SET('automaj',flags),'1','0') FROM forums.profils - WHERE uid = {?}", Session::getInt('uid')); + WHERE uid = {?}", S::v('uid')); if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) { - $nom = Session::get('prenom').' '.Session::get('nom'); - $mail = Session::get('forlife').'@'.$globals->mail->domain; - $sig = $nom.' ('.Session::getInt('promo').')'; + $nom = S::v('prenom').' '.S::v('nom'); + $mail = S::v('forlife').'@'.$globals->mail->domain; + $sig = $nom.' ('.S::v('promo').')'; $disp = 0; $maj = 0; } @@ -72,15 +86,41 @@ class BananaModule extends PLModule $page->assign('disp', $disp); $page->assign('maj' , $maj); } else { - $globals->xdb->execute( + XDB::execute( 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags) VALUES ({?},{?},{?},{?},{?})', - Session::getInt('uid'), Post::get('bananasig'), Post::get('bananamail'), Post::get('banananame'), - (Post::getBool('bananadisplay') ? 'threads,' : '') . (Post::getBool('bananaupdate') ? 'automaj' : '') + S::v('uid'), Post::v('bananasig'), + Post::v('bananamail'), Post::v('banananame'), + (Post::b('bananadisplay') ? 'threads,' : '') . + (Post::b('bananaupdate') ? 'automaj' : '') ); } + } - return PL_OK; + function handler_subscription(&$page) + { + return $this->run_banana($page, Array('subscribe' => 1)); + } + + function handler_xface(&$page, $face = null) + { + header('Content-Type: image/gif'); + passthru('echo ' . escapeshellarg(base64_decode(strtr($face, '.:', '+/'))) + . '| uncompface -X ' + . '| convert -transparent white xbm:- gif:-'); + } + + function run_banana(&$page, $params = null) + { + $page->changeTpl('banana/index.tpl'); + $page->addCssLink('css/banana.css'); + $page->assign('xorg_title','Polytechnique.org - Forums & PA'); + + require_once dirname(__FILE__).'/banana/banana.inc.php'; + + $res = PlatalBanana::run($params); + $page->assign_by_ref('banana', $banana); + $page->assign('banana_res', $res); } }