X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fbanana.php;h=efa90c05691f009ee6ffab6270fb2706b40f3464;hb=323e53dc4e0b4d0a65182b179fd27880de0c3ff7;hp=f45d8b2dcd56f947173b8a1e75a33b1109c95dbb;hpb=a011eab2b168c190d9812c8c796ed44fd69dadc7;p=platal.git diff --git a/modules/banana.php b/modules/banana.php index f45d8b2..efa90c0 100644 --- a/modules/banana.php +++ b/modules/banana.php @@ -1,6 +1,6 @@ numRows()) { + $cible[] = $p_for; + } else { // pas de forum promo, il faut le créer + $res = XDB::query("SELECT SUM(perms IN ('admin','user') AND deces=0),COUNT(*) + FROM auth_user_md5 WHERE promo={?}", $promo); + list($effau, $effid) = $res->fetchOneRow(); + if (5*$effau>$effid) { // + de 20% d'inscrits + $mymail = new PlMailer('mails/forums.promo.tpl'); + $mymail->assign('promo', $promo); + $mymail->send(); + } + } + + while (list ($key, $val) = each ($cible)) { + XDB::execute("INSERT INTO forums.abos (fid,uid) + SELECT fid,{?} FROM forums.list WHERE nom={?}", $uid, $val); + } + } + function handler_banana(&$page, $group = null, $action = null, $artid = null) { $get = Array(); @@ -38,20 +64,28 @@ class BananaModule extends PLModule $get['group'] = $group; } if (Post::has('updateall')) { - $get['banana'] = 'updateall'; + $get['updateall'] = Post::v('updateall'); } if (!is_null($action)) { if ($action == 'new') { $get['action'] = 'new'; - } elseif (($action == 'reply' || $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; + } 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; + } 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); } @@ -63,17 +97,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; } @@ -83,22 +117,20 @@ 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)); + return $this->run_banana($page, Array('action' => 'subscribe')); } function handler_xface(&$page, $face = null) @@ -107,22 +139,20 @@ class BananaModule extends PLModule passthru('echo ' . escapeshellarg(base64_decode(strtr($face, '.:', '+/'))) . '| uncompface -X ' . '| convert -transparent white xbm:- gif:-'); - return PL_OK; } - function run_banana(&$page, $params = null) + static function run_banana(&$page, $params = null) { $page->changeTpl('banana/index.tpl'); - $page->addCssLink('css/banana.css'); + $page->addCssLink('banana.css'); $page->assign('xorg_title','Polytechnique.org - Forums & PA'); - require_once('banana.inc.php'); + require_once 'banana/forum.inc.php'; - $res = PlatalBanana::run($params); + $banana = new ForumsBanana($params); + $res = $banana->run(); $page->assign_by_ref('banana', $banana); $page->assign('banana_res', $res); - - return PL_OK; } }