From: Florent Bruneau Date: Sat, 5 Jul 2008 11:13:03 +0000 (+0200) Subject: Can choose the color of banana tree branches. X-Git-Tag: xorg/0.9.17~57 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=43cddb05b858dfc532ae3c1a3621a0acce616f00;p=platal.git Can choose the color of banana tree branches. Signed-off-by: Florent Bruneau --- diff --git a/include/banana/forum.inc.php b/include/banana/forum.inc.php index 89fa0c9..99f002f 100644 --- a/include/banana/forum.inc.php +++ b/include/banana/forum.inc.php @@ -68,15 +68,18 @@ class ForumsBanana extends Banana // Get user profile from SQL $req = XDB::query("SELECT nom, mail, sig, - FIND_IN_SET('threads',flags), FIND_IN_SET('automaj',flags) + FIND_IN_SET('threads',flags), FIND_IN_SET('automaj',flags), + tree_unread, tree_read FROM {$globals->banana->table_prefix}profils WHERE uid={?}", S::i('uid')); - if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) { + if (!(list($nom, $mail, $sig, $disp, $maj, $unread, $read) = $req->fetchOneRow())) { $nom = S::v('prenom')." ".S::v('nom'); $mail = S::v('forlife')."@" . $globals->mail->domain; $sig = $nom." (".S::v('promo').")"; $disp = 0; $maj = 1; + $unread = 'b'; + $read = 'dg'; } if ($maj) { $time = time(); @@ -95,6 +98,8 @@ class ForumsBanana extends Banana Banana::$profile['autoup'] = $maj; Banana::$profile['lastnews'] = S::v('banana_last'); Banana::$profile['subscribe'] = $req->fetchColumn(); + Banana::$tree_unread = $unread; + Banana::$tree_read = $read; // Update the "unread limit" if (!is_null($time)) { @@ -176,9 +181,15 @@ class ForumsBanana extends Banana { global $page, $globals; - if (Post::has('action') && Post::has('banananame') && Post::has('bananasig') - && Post::has('bananadisplay') && Post::has('bananamail') - && Post::has('bananaupdate') && Post::v('action')=="Enregistrer" ) { + $colors = glob(dirname(__FILE__) . '/../../htdocs/images/banana/m2*.gif'); + foreach ($colors as $key=>$path) { + $path = basename($path, '.gif'); + $colors[$key] = substr($path, 2); + } + $page->assign('colors', $colors); + + if (Post::has('action') && Post::v('action') == 'Enregistrer') { + S::assert_xsrf_token(); $flags = new FlagSet(); if (Post::b('bananadisplay')) { $flags->addFlag('threads'); @@ -189,11 +200,15 @@ class ForumsBanana extends Banana if (Post::b('bananaxface')) { $flags->addFlag('xface'); } - if (XDB::execute("REPLACE INTO forums.profils (uid, sig, mail, nom, flags) - VALUES ({?}, {?}, {?}, {?}, {?})", - S::v('uid'), Post::v('bananasig'), - Post::v('bananamail'), Post::v('banananame'), - $flags)) { + $unread = Post::s('unread'); + $read = Post::s('read'); + if (!in_array($unread, $colors) || !in_array($read, $colors)) { + $page->trigError('Le choix de type pour l\'arborescence est invalide'); + } elseif (XDB::execute("REPLACE INTO forums.profils (uid, sig, mail, nom, flags, tree_unread, tree_read) + VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})", + S::v('uid'), Post::v('bananasig'), + Post::v('bananamail'), Post::v('banananame'), + $flags, $unread, $read)) { $page->trigSuccess("Ton profil a été enregistré avec succès."); } else { $page->trigError("Une erreur s'est produite lors de l'enregistrement de ton profil"); @@ -204,16 +219,20 @@ class ForumsBanana extends Banana SELECT nom, mail, sig, FIND_IN_SET('threads', flags), FIND_IN_SET('automaj', flags), - FIND_IN_SET('xface', flags) + FIND_IN_SET('xface', flags), + tree_unread, + tree_read FROM forums.profils WHERE uid = {?}", S::v('uid')); - if (!(list($nom, $mail, $sig, $disp, $maj, $xface) = $req->fetchOneRow())) { + if (!(list($nom, $mail, $sig, $disp, $maj, $xface, $unread, $read) = $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; + $unread = 'b'; + $read = 'dg'; } $page->assign('nom' , $nom); $page->assign('mail', $mail); @@ -221,6 +240,8 @@ class ForumsBanana extends Banana $page->assign('disp', $disp); $page->assign('maj', $maj); $page->assign('xface', $xface); + $page->assign('unread', $unread); + $page->assign('read', $read); return null; } } diff --git a/include/banana/ml.inc.php b/include/banana/ml.inc.php index 1a5413f..39dacf6 100644 --- a/include/banana/ml.inc.php +++ b/include/banana/ml.inc.php @@ -79,6 +79,17 @@ class MLBanana extends Banana $sig = $nom . ' (' . S::v('promo') . ')'; Banana::$msgedit_headers['X-Org-Mail'] = S::v('forlife') . '@' . $globals->mail->domain; + // Tree color + $req = XDB::query("SELECT tree_unread, tree_read + FROM {$globals->banana->table_prefix}profils + WHERE uid={?}", S::i('uid')); + if (!(list($unread, $read) = $req->fetchOneRow())) { + $unread = 'b'; + $read = 'dg'; + } + Banana::$tree_unread = $unread; + Banana::$tree_read = $read; + // Build user profile Banana::$profile['headers']['From'] = "$nom <$mail>"; Banana::$profile['headers']['Organization'] = make_Organization(); diff --git a/templates/banana/index.tpl b/templates/banana/index.tpl index 0e811d5..e865ee2 100644 --- a/templates/banana/index.tpl +++ b/templates/banana/index.tpl @@ -38,6 +38,7 @@

+ {xsrf_token_field} @@ -64,6 +65,17 @@ + + + +
Profil Banana
Aspect de l'arborescence + {foreach from=$colors item=color} + + {$color} + +
+ {/foreach} +
Mise à jour des messages non lus