From b5163f5283aabcf6a68cb12c6ad81334e4a52b59 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Fri, 2 Nov 2007 17:04:57 +0100 Subject: [PATCH] Port profile page and have lighter code to handle the wall thing Signed-off-by: Florent Bruneau --- include/banana/forum.inc.php | 61 +++++++++++++++++++++- include/banana/hooks.inc.php | 23 ++++++++- modules/banana.php | 26 +--------- templates/banana/index.tpl | 68 +++++++++++++++++++++++- templates/banana/profile.tpl | 120 ------------------------------------------- 5 files changed, 150 insertions(+), 148 deletions(-) delete mode 100644 templates/banana/profile.tpl diff --git a/include/banana/forum.inc.php b/include/banana/forum.inc.php index 961c6ab..9d9d17a 100644 --- a/include/banana/forum.inc.php +++ b/include/banana/forum.inc.php @@ -50,6 +50,9 @@ class ForumsBanana extends Banana Banana::$feed_active = false; } parent::__construct($params, 'NNTP', 'PlatalBananaPage'); + if ($params['action'] == 'profile') { + Banana::$action = 'profile'; + } } public function run() @@ -116,8 +119,13 @@ class ForumsBanana extends Banana Banana::$page->registerPage('profile', 'Préférences', null); } - // Run Banana - return parent::run(); + // Run Bananai + if (Banana::$action == 'profile') { + Banana::$page->run(); + return $this->action_updateProfile(); + } else { + return parent::run(); + } } public function post($dest, $reply, $subject, $body) @@ -163,6 +171,55 @@ class ForumsBanana extends Banana Banana::$profile['subscribe'][] = $g; } } + + protected function action_updateProfile() + { + 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" )) + { + $req = XDB::query(" + 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, $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('xface', $xface); + } else { + $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)); + } + return null; + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/include/banana/hooks.inc.php b/include/banana/hooks.inc.php index 05d43cc..ef22186 100644 --- a/include/banana/hooks.inc.php +++ b/include/banana/hooks.inc.php @@ -222,6 +222,23 @@ function make_Organization() function get_banana_params(array &$get, $group = null, $action = null, $artid = null) { + if ($group == 'forums') { + $group = null; + } else if ($group == 'thread') { + $group = S::v('banana_group'); + } else if ($group == 'message') { + $action = 'read'; + $group = S::v('banana_group'); + $artid = S::i('banana_artid'); + } else if ($group == 'subscribe' || $group == 'subscription') { + $group = null; + $action = null; + $get['action'] = 'subscribe'; + } else if ($group == 'profile') { + $group = null; + $action = null; + $get['action'] = 'profile'; + } if (!is_null($group)) { $get['group'] = $group; } @@ -267,7 +284,11 @@ class PlatalBananaPage extends BananaPage global $wiz, $page; $wiz = new PlWizard('Banana', 'core/plwizard.tpl', true, false); foreach ($this->pages as $name=>&$mpage) { - $wiz->addPage('BananaHandler', $mpage['text'], $name); + if ($text == 'profile') { + $wiz->addPage('BananaProfile', $mpage['text'], $name); + } else { + $wiz->addPage('BananaHandler', $mpage['text'], $name); + } } $wiz->apply($page, 'banana', $this->page); return $tpl; diff --git a/modules/banana.php b/modules/banana.php index 7a7548f..3ad4cbc 100644 --- a/modules/banana.php +++ b/modules/banana.php @@ -25,11 +25,8 @@ class BananaModule extends PLModule { return array( 'banana' => $this->make_hook('banana', AUTH_COOKIE), - 'banana/forums' => $this->make_hook('banana', AUTH_COOKIE), - 'banana/message' => $this->make_hook('message', AUTH_COOKIE), - 'banana/thread' => $this->make_hook('thread', AUTH_COOKIE), - 'banana/profile' => $this->make_hook('profile', AUTH_MDP), - 'banana/subscribe' => $this->make_hook('subscription', AUTH_COOKIE), +// 'banana/profile' => $this->make_hook('profile', AUTH_MDP), +// 'banana/subscribe' => $this->make_hook('subscription', AUTH_COOKIE), 'banana/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS), ); } @@ -74,16 +71,6 @@ class BananaModule extends PLModule run_banana($page, 'ForumsBanana', $get); } - function handler_message(&$page) - { - pl_redirect('banana/' . S::v('banana_group') . '/read/' . S::i('banana_artid')); - } - - function handler_thread(&$page) - { - pl_redirect('banana/' . S::v('banana_group')); - } - function handler_profile(&$page, $action = null) { global $globals; @@ -134,15 +121,6 @@ class BananaModule extends PLModule } } - function handler_subscription(&$page) - { - $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_rss(&$page, $group, $alias, $hash, $file = null) { if (is_null($file)) { diff --git a/templates/banana/index.tpl b/templates/banana/index.tpl index fd6691b..5401fad 100644 --- a/templates/banana/index.tpl +++ b/templates/banana/index.tpl @@ -20,8 +20,74 @@ {* *} {**************************************************************************} -
+{if isset($banana|smarty:nodefaults)} {$banana|smarty:nodefaults} +{else} + +{if !$smarty.post.action} +

+ Tu peux régler quelques paramètres qui apparaîtront sur les messages lorsque + tu posteras sur les forums. Cela ne te permettra pas d'être anonyme, puisque + tout le monde pourra remonter à ton identité en regardant ta fiche. L'objectif + est simplement de permettre plus de convivialité. +

+

+ Tu pourras voir dans les forums les nouveaux messages mis en valeur (en + général en gras). Si tu consultes les forums régulièrement, tu peux en avoir + assez de voir tout le contenu du forum : la dernière option te permet de + n'afficher que les fils de discussion contenant des messages lus. +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Profil Banana
Nom
Adresse électronique
Signature
Affichage des fils de discussion + Afficher tous les messages
+ Afficher seulement les fils de discussion contenant des messages non lus +
Mise à jour des messages non lus + Automatique
+ Manuelle +
+ + +
+
+
+{else} +

+ Ton profil est enregistré !!! +

+{/if} +{/if}

{icon name="lightbulb" title="Astuce"}Astuce : diff --git a/templates/banana/profile.tpl b/templates/banana/profile.tpl deleted file mode 100644 index bb97abd..0000000 --- a/templates/banana/profile.tpl +++ /dev/null @@ -1,120 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2007 Polytechnique.org *} -{* http://opensource.polytechnique.org/ *} -{* *} -{* This program is free software; you can redistribute it and/or modify *} -{* it under the terms of the GNU General Public License as published by *} -{* the Free Software Foundation; either version 2 of the License, or *} -{* (at your option) any later version. *} -{* *} -{* This program is distributed in the hope that it will be useful, *} -{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} -{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} -{* GNU General Public License for more details. *} -{* *} -{* You should have received a copy of the GNU General Public License *} -{* along with this program; if not, write to the Free Software *} -{* Foundation, Inc., *} -{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} -{* *} -{**************************************************************************} - -
- - - - - - - - -
- -
- -{if !$smarty.post.action} - -

- Tu peux régler quelques paramètres qui apparaîtront sur les messages lorsque - tu posteras sur les forums. Cela ne te permettra pas d'être anonyme, puisque - tout le monde pourra remonter à ton identité en regardant ta fiche. L'objectif - est simplement de permettre plus de convivialité. -

-

- Tu pourras voir dans les forums les nouveaux messages mis en valeur (en - général en gras). Si tu consultes les forums régulièrement, tu peux en avoir - assez de voir tout le contenu du forum : la dernière option te permet de - n'afficher que les fils de discussion contenant des messages lus. -

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Profil Banana
Nom
Adresse électronique
Signature
Affichage des fils de discussion - Afficher tous - les messages -
- Afficher - seulement les fils de discussion contenant des messages non lus -
Mise à jour des messages non lus - Automatique -
- Manuelle -
- - -
-
-
- -{else} -

- Ton profil est enregistré !!! -

-{/if} - -
- -

- {icon name="lightbulb" title="Astuce"}Astuce : - Tu peux également consulter les fora en utilisant un client NNTP tel que - Outlook Express ou Thunderbird.
N'hésite pas à - consulter la documentation et à activer ton accès pour utiliser ce service. -

- - -{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4