X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fbanana.php;h=63ce688751d1fc9f690ef1353ed929bf52547c6b;hb=5d9d45a8e223225ea5c25b857cd5e11f1aabf6f7;hp=ad9e406146ef8e2d5ba225c685f2a4f18bbe51e8;hpb=82838f55222fbe9f1e183669d67e3ccb5c2ac34d;p=platal.git diff --git a/modules/banana.php b/modules/banana.php index ad9e406..63ce688 100644 --- a/modules/banana.php +++ b/modules/banana.php @@ -27,7 +27,7 @@ class BananaModule extends PLModule '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), + 'banana/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS), ); } @@ -59,35 +59,16 @@ class BananaModule extends PLModule function handler_banana(&$page, $group = null, $action = null, $artid = null) { + $page->changeTpl('banana/index.tpl'); + $page->assign('xorg_title','Polytechnique.org - Forums & PA'); + $get = Array(); - if (!is_null($group)) { - $get['group'] = $group; - } if (Post::has('updateall')) { $get['updateall'] = Post::v('updateall'); } - if (!is_null($action)) { - if ($action == 'new') { - $get['action'] = 'new'; - } elseif (!is_null($artid)) { - $get['artid'] = $artid; - if ($action == 'reply') { - $get['action'] = 'new'; - } elseif ($action == 'cancel') { - $get['action'] = $action; - } elseif ($action == 'from') { - $get['first'] = $artid; - unset($get['artid']); - } elseif ($action == 'read') { - $get['part'] = @$_GET['part']; - } elseif ($action == 'source') { - $get['part'] = 'source'; - } elseif ($action == 'xface') { - $get['part'] = 'xface'; - } - } - } - return BananaModule::run_banana($page, $get); + require_once 'banana/forum.inc.php'; + get_banana_params($get, $group, $action, $artid); + run_banana($page, 'ForumsBanana', $get); } function handler_profile(&$page, $action = null) @@ -98,48 +79,80 @@ class BananaModule extends PLModule if (!(Post::has('action') && Post::has('banananame') && Post::has('bananasig') && Post::has('bananadisplay') && Post::has('bananamail') - && Post::has('bananaupdate') && Post::v('action')=="OK" )) + && Post::has('bananaupdate') && Post::v('action')=="Enregistrer" )) { $req = XDB::query(" - SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'), - IF(FIND_IN_SET('automaj',flags),'1','0') + SELECT nom, mail, sig, + FIND_IN_SET('threads', flags), + FIND_IN_SET('automaj', flags), + FIND_IN_SET('xface', flags) FROM forums.profils WHERE uid = {?}", S::v('uid')); - if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) { - $nom = S::v('prenom').' '.S::v('nom'); - $mail = S::v('forlife').'@'.$globals->mail->domain; - $sig = $nom.' ('.S::v('promo').')'; - $disp = 0; - $maj = 0; + if (!(list($nom, $mail, $sig, $disp, $maj, $xface) = $req->fetchOneRow())) { + $nom = S::v('prenom').' '.S::v('nom'); + $mail = S::v('forlife').'@'.$globals->mail->domain; + $sig = $nom.' ('.S::v('promo').')'; + $disp = 0; + $maj = 0; + $xface = 0; } - $page->assign('nom' , $nom); - $page->assign('mail', $mail); - $page->assign('sig' , $sig); - $page->assign('disp', $disp); - $page->assign('maj' , $maj); + $page->assign('nom' , $nom); + $page->assign('mail', $mail); + $page->assign('sig', $sig); + $page->assign('disp', $disp); + $page->assign('maj', $maj); + $page->assign('xface', $xface); } else { - XDB::execute( - 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags) - VALUES ({?},{?},{?},{?},{?})', - S::v('uid'), Post::v('bananasig'), - Post::v('bananamail'), Post::v('banananame'), - (Post::b('bananadisplay') ? 'threads,' : '') . - (Post::b('bananaupdate') ? 'automaj' : '') - ); + $flags = array(); + if (Post::b('bananadisplay')) { + $flags[] = 'threads'; + } + if (Post::b('bananaupdate')) { + $flags[] = 'automaj'; + } + if (Post::b('bananaxface')) { + $flags[] = 'xface'; + } + XDB::execute("REPLACE INTO forums.profils (uid, sig, mail, nom, flags) + VALUES ({?}, {?}, {?}, {?}, {?})", + S::v('uid'), Post::v('bananasig'), + Post::v('bananamail'), Post::v('banananame'), + implode(',', $flags)); } } function handler_subscription(&$page) { - return $this->run_banana($page, Array('action' => 'subscribe')); + $page->changeTpl('banana/index.tpl'); + $page->assign('xorg_title','Polytechnique.org - Forums & PA'); + + require_once 'banana/forum.inc.php'; + run_banana($page, 'ForumsBanana', Array('action' => 'subscribe')); } - function handler_xface(&$page, $face = null) + function handler_rss(&$page, $group, $alias, $hash, $file = null) { - header('Content-Type: image/gif'); - passthru('echo ' . escapeshellarg(base64_decode(strtr($face, '.:', '+/'))) - . '| uncompface -X ' - . '| convert -transparent white xbm:- gif:-'); + if (is_null($file)) { + if (is_null($hash)) { + exit; + } + $this->handler_rss($page, null, $group, $alias, $hash); + } + require_once('rss.inc.php'); + $uid = init_rss(null, $alias, $hash); + if (!$uid) { + exit; + } + $res = XDB::query("SELECT id AS uid, alias AS forlife + FROM aliases + WHERE type = 'a_vie' AND id = {?}", $uid); + $row = $res->fetchOneAssoc(); + $_SESSION = array_merge($row, $_SESSION); + + require_once 'banana/forum.inc.php'; + $banana = new ForumsBanana(S::v('forlife'), array('group' => $group, 'action' => 'rss2')); + $banana->run(); + exit; } static function run_banana(&$page, $params = null) @@ -148,14 +161,9 @@ class BananaModule extends PLModule $page->assign('xorg_title','Polytechnique.org - Forums & PA'); require_once 'banana/forum.inc.php'; - - $banana = new ForumsBanana($params); - $res = $banana->run(); - $page->assign_by_ref('banana', $banana); - $page->assign('banana_res', $res); - $page->addCssInline($banana->css()); - $page->addCssLink('banana.css'); + run_banana($page, 'ForumsBanana', $params); } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>