pending commit, finished during MQ/S download ...
[platal.git] / modules / banana.php
index fa6576b..3dab3d1 100644 (file)
@@ -27,7 +27,6 @@ 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/updateall'    => $this->make_hook('updateall', AUTH_COOKIE),
             'banana/xface'        => $this->make_hook('xface', AUTH_COOKIE),
         );
     }
@@ -38,10 +37,16 @@ class BananaModule extends PLModule
         if (!is_null($group)) {
             $get['group'] = $group;
         }
+        if (Post::has('updateall')) {
+            $get['banana'] = 'updateall';
+        }
         if (!is_null($action)) {
             if ($action == 'new') {
                 $get['action'] = 'new';
-            } elseif (($action == 'reply' || $action == 'cancel') && !is_null($artid)) {
+            } elseif ($action == 'reply' && !is_null($artid)) {
+                $get['action'] = 'new';
+                $get['artid']  = $artid;
+            } elseif ($action == 'cancel' && !is_null($artid)) {
                 $get['action'] = $action;
                 $get['artid']  = $artid;
             } elseif ($action == 'from' && !is_null($artid)) {
@@ -63,15 +68,15 @@ class BananaModule extends PLModule
         && Post::has('bananadisplay') && Post::has('bananamail')
         && Post::has('bananaupdate') && Post::get('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;
             }
@@ -81,22 +86,15 @@ 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'),
+                S::v('uid'), Post::get('bananasig'),
                 Post::get('bananamail'), Post::get('banananame'),
                 (Post::getBool('bananadisplay') ? 'threads,' : '') .
                 (Post::getBool('bananaupdate') ? 'automaj' : '')
             );
         }
-
-        return PL_OK;
-    }
-
-    function handler_updateall(&$page)
-    {
-        return BananaModule::run_banana($page, Array('banana' => 'updateall'));
     }
 
     function handler_subscription(&$page)
@@ -104,16 +102,12 @@ class BananaModule extends PLModule
         return $this->run_banana($page, Array('subscribe' => 1));
     }
 
-    function handler_xface()
+    function handler_xface(&$page, $face = null)
     {
-        $args = func_get_args();
-        array_shift($args);
-        $face = join('/', $args);
-        header('Content-Type: image/jpeg');
-        passthru('echo ' . escapeshellarg(base64_decode($face))
+        header('Content-Type: image/gif');
+        passthru('echo ' . escapeshellarg(base64_decode(strtr($face, '.:', '+/')))
                 . '| uncompface -X '
-                . '| convert xbm:- jpg:-');
-        return PL_OK;
+                . '| convert -transparent white xbm:- gif:-');
     }
 
     function run_banana(&$page, $params = null)
@@ -127,8 +121,6 @@ class BananaModule extends PLModule
         $res = PlatalBanana::run($params);
         $page->assign_by_ref('banana', $banana);
         $page->assign('banana_res', $res);
-
-        return PL_OK;
     }
 }