AXSpammer cron
[platal.git] / modules / banana.php
index 3441fb5..ea857c5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  Copyright (C) 2003-2007 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -45,8 +45,7 @@ class BananaModule extends PLModule
                                  FROM  auth_user_md5 WHERE promo={?}", $promo);
             list($effau, $effid) = $res->fetchOneRow();
             if (5*$effau>$effid) { // + de 20% d'inscrits
-                require_once("xorg.mailer.inc.php");
-                $mymail = new XOrgMailer('mails/forums.promo.tpl');
+                $mymail = new PlMailer('mails/forums.promo.tpl');
                 $mymail->assign('promo', $promo);
                 $mymail->send();
             }
@@ -65,23 +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' && !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)) {
-                $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);
     }
 
@@ -126,7 +130,7 @@ class BananaModule extends PLModule
 
     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)
@@ -137,17 +141,19 @@ class BananaModule extends PLModule
                 . '| convert -transparent white xbm:- gif:-');
     }
 
-    function run_banana(&$page, $params = null)
+    static function run_banana(&$page, $params = null)
     {
         $page->changeTpl('banana/index.tpl');
-        $page->addCssLink('css/banana.css');
         $page->assign('xorg_title','Polytechnique.org - Forums & PA');
 
-        require_once dirname(__FILE__).'/banana/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);
+        $page->addCssInline($banana->css());
+        $page->addCssLink('banana.css');
     }
 }