migrate banana as well
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 4 Jul 2006 20:15:22 +0000 (20:15 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 4 Jul 2006 20:15:22 +0000 (20:15 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@367 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
htdocs/banana/index.php [deleted file]
htdocs/banana/profile.php [deleted file]
htdocs/banana/xface.php [deleted file]
include/banana.inc.php
install.d/banana.files
modules/banana.php [new file with mode: 0644]
templates/banana/index.tpl
templates/banana/profile.tpl
templates/docs/plan.tpl

index 90e7d3c..934038d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@ New:
     * Core:
         - Work hard to add nice URI's into Platal.                          -MC
 
+    * Banana:
+        - Switch to the new URI scheme.                                     -MC
+
     * Emails:
         - Switch to the new URI scheme.                                     -MC
 
diff --git a/htdocs/banana/index.php b/htdocs/banana/index.php
deleted file mode 100644 (file)
index 3eea328..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-/********************************************************************************
-* index.php : main page (newsgroups list)
-* -----------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('banana/index.tpl', AUTH_COOKIE);
-$page->addCssLink('css/banana/style.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);
-$page->run();
-?>
diff --git a/htdocs/banana/profile.php b/htdocs/banana/profile.php
deleted file mode 100644 (file)
index ed3790d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 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                *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page('banana/profile.tpl', AUTH_MDP);
-
-if (!(Post::has('action') && Post::has('banananame') && Post::has('bananasig') && Post::has('bananadisplay')
-            && Post::has('bananamail') && Post::has('bananaupdate') && Post::get('action')=="OK" ))
-{
-    $req = $globals->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'));
-    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').')';
-        $disp = 0;
-        $maj  = 0;
-    }
-    $page->assign('nom' , $nom);
-    $page->assign('mail', $mail);
-    $page->assign('sig' , $sig);
-    $page->assign('disp', $disp);
-    $page->assign('maj' , $maj);
-} else {
-    $globals->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' : '')
-    );
-}
-
-$page->run();
-?>
diff --git a/htdocs/banana/xface.php b/htdocs/banana/xface.php
deleted file mode 100644 (file)
index 16d0332..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-header('Content-Type: image/jpeg');
-passthru('echo '.escapeshellarg(base64_decode($_REQUEST['face'])).'|uncompface -X |convert xbm:- jpg:-');
-
-?>
index b1e0371..8bcc704 100644 (file)
@@ -71,8 +71,8 @@ class PlatalBanana extends Banana
             $globals->xdb->execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid);
         }
 
-        $req = $globals->xdb->query(
-                "SELECT  nom
+        $req = $globals->xdb->query("
+                 SELECT  nom
                    FROM  {$globals->banana->table_prefix}abos
               LEFT JOIN  {$globals->banana->table_prefix}list ON list.fid=abos.fid
                   WHERE  uid={?}", $uid);
index ab5ff53..4e01d7f 100644 (file)
@@ -1,8 +1,3 @@
 bin/banana.spoolgen.php
 hooks/banana.inc.php
-htdocs/banana/index.php
-htdocs/banana/profile.php
-htdocs/banana/xface.php
 include/banana.inc.php
-templates/banana/index.tpl
-templates/banana/profile.tpl
diff --git a/modules/banana.php b/modules/banana.php
new file mode 100644 (file)
index 0000000..2a32c71
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 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                *
+ ***************************************************************************/
+
+class BananaModule extends PLModule
+{
+    function handlers()
+    {
+        return array(
+            'banana' => $this->make_hook('banana', AUTH_COOKIE),
+            'banana/profile' => $this->make_hook('profile', AUTH_MDP),
+            'banana/xface'   => $this->make_hook('xface', AUTH_PUBLIC),
+        );
+    }
+
+    function handler_banana(&$page)
+    {
+        $page->changeTpl('banana/index.tpl');
+        $page->addCssLink('css/banana/style.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;
+    }
+
+    function handler_profile(&$page)
+    {
+        global $globals;
+
+        $page->changeTpl('banana/profile.tpl');
+
+        if (!(Post::has('action') && Post::has('banananame') && Post::has('bananasig')
+        && Post::has('bananadisplay') && Post::has('bananamail')
+        && Post::has('bananaupdate') && Post::get('action')=="OK" ))
+        {
+            $req = $globals->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'));
+            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').')';
+                $disp = 0;
+                $maj  = 0;
+            }
+            $page->assign('nom' , $nom);
+            $page->assign('mail', $mail);
+            $page->assign('sig' , $sig);
+            $page->assign('disp', $disp);
+            $page->assign('maj' , $maj);
+        } else {
+            $globals->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' : '')
+            );
+        }
+
+        return PL_OK;
+    }
+
+    function handler_xface(&$page)
+    {
+        header('Content-Type: image/jpeg');
+        passthru('echo '.escapeshellarg(base64_decode($_REQUEST['face'])).
+                 '|uncompface -X |convert xbm:- jpg:-');
+        exit;
+    }
+}
+
+?>
index 81832dd..33ed913 100644 (file)
@@ -25,7 +25,7 @@
 {if !$banana->profile.autoup}
 [<a href="?banana=updateall">Mettre à jour</a>]
 {/if}
-[<a href="profile.php">Profil</a>]
+[<a href="{rel}/banana/profile">Profil</a>]
 
 <br />
 
index 782fa73..e88c3d8 100644 (file)
   n'afficher que les fils de discussion contenant des messages lus.
 </p>
 <p class="normal">
-Retour aux <a href="{rel}/banana/">forums</a>
+Retour aux <a href="{rel}/banana">forums</a>
 </p>
 
-<form action="{$smarty.server.PHP_SELF}" method="post">
+<form action="{rel}/banana/profile" method="post">
   <table class="bicol" cellpadding="3" cellspacing="0" summary="Configuration de Banana">
     <tr>
       <th colspan="2">
@@ -112,7 +112,7 @@ Retour aux <a href="{rel}/banana/">forums</a>
   Ton profil est enregistré !!!
 </p>
 <p class="normal">
-Retour aux <a href="{rel}/banana/">forums</a>
+Retour aux <a href="{rel}/banana">forums</a>
 </p>
 {/if}
 
index 121b164..146df88 100644 (file)
 
   <li>
   <ul>
-    {page title="Configuration de Banana" url="confbanana.php"|url}
+    {page title="Configuration de Banana" url="banana/profile"|url}
     Pour configurer les paramètres de l'interface web Banana de lecture de forums.
     {/page}