fix URL accordingly to new documentation architecture
[platal.git] / modules / banana.php
index 63234c2..7a88b9c 100644 (file)
@@ -31,6 +31,32 @@ class BananaModule extends PLModule
         );
     }
 
+    function on_subscribe($forlife, $uid, $promo, $password)
+    {
+        $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements');
+        $p_for = "xorg.promo.x$promo";
+
+        // récupération de l'id du forum promo
+        $res = XDB::query("SELECT fid FROM forums.list WHERE nom={?}", $p_for);
+        if ($res->numRows()) {
+            $cible[] = $p_for;
+        } else { // pas de forum promo, il faut le créer
+            $res = XDB::query("SELECT  SUM(perms IN ('admin','user') AND deces=0),COUNT(*)
+                                 FROM  auth_user_md5 WHERE promo={?}", $promo);
+            list($effau, $effid) = $res->fetchOneRow();
+            if (5*$effau>$effid) { // + de 20% d'inscrits
+                $mymail = new PlMailer('mails/forums.promo.tpl');
+                $mymail->assign('promo', $promo);
+                $mymail->send();
+            }
+        }
+
+        while (list ($key, $val) = each ($cible)) {
+            XDB::execute("INSERT INTO  forums.abos (fid,uid)
+                               SELECT  fid,{?} FROM forums.list WHERE nom={?}", $uid, $val);
+        }
+    }
+
     function handler_banana(&$page, $group = null, $action = null, $artid = null)
     {
         $get = Array();
@@ -38,7 +64,7 @@ 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') {
@@ -113,7 +139,7 @@ class BananaModule extends PLModule
     function run_banana(&$page, $params = null)
     {
         $page->changeTpl('banana/index.tpl');
-        $page->addCssLink('css/banana.css');
+        $page->addCssLink('banana.css');
         $page->assign('xorg_title','Polytechnique.org - Forums & PA');
 
         require_once dirname(__FILE__).'/banana/banana.inc.php';