No more on_subscribe. It fortunately didn't work.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 23 Aug 2008 15:44:52 +0000 (17:44 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 23 Aug 2008 15:44:52 +0000 (17:44 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/carnet.php
modules/forums.php
modules/lists.php
modules/register.php
modules/search.php

index 3a64bb8..32a71b9 100644 (file)
@@ -37,13 +37,6 @@ class CarnetModule extends PLModule
         );
     }
 
-    function on_subscribe($forlife, $uid, $promo, $password)
-    {
-        require_once 'notifs.inc.php';
-        register_watch_op($uid, WATCH_INSCR);
-        inscription_notifs_base($uid);
-    }
-
     function _add_rss_link(&$page)
     {
         if (!S::has('core_rss_hash')) {
index 80ea2fd..e67966d 100644 (file)
@@ -24,38 +24,12 @@ class ForumsModule extends PLModule
     function handlers()
     {
         return array(
-            'banana'              => $this->make_hook('banana', AUTH_COOKIE),
-            'banana/rss'          => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
+            'banana'         => $this->make_hook('banana', AUTH_COOKIE),
+            'banana/rss'     => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
             'admin/forums'   => $this->make_hook('forums_bans', AUTH_MDP, 'admin'),
         );
     }
 
-    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('admin/forums-promo.mail.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)
     {
         $page->changeTpl('banana/index.tpl');
index a4ea356..36b247b 100644 (file)
@@ -46,12 +46,6 @@ class ListsModule extends PLModule
         );
     }
 
-    function on_subscribe($forlife, $uid, $promo, $password)
-    {
-        $this->prepare_client(null);
-        $this->client->subscribe("promo$promo");
-    }
-
     function prepare_client(&$page)
     {
         global $globals;
index 6d1273b..8d30088 100644 (file)
@@ -301,22 +301,43 @@ class RegisterModule extends PLModule
         $redirect->add_email($email);
 
         // on cree un objet logger et on log l'inscription
-        $logger = new PlLogger($uid);
-        S::logger()->log('inscription', $email);
-
+        S::logger($uid)->log('inscription', $email);
         XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid);
 
-        global $platal;
-        $platal->on_subscribe($forlife, $uid, $promo, $password);
 
         $mymail = new PlMailer('register/inscription.reussie.tpl');
         $mymail->assign('forlife', $forlife);
         $mymail->assign('prenom', $prenom);
         $mymail->send();
 
+        // Enable search on the user
         require_once('user.func.inc.php');
         user_reindex($uid);
 
+        // Add notification for people looking for this registration
+        require_once 'notifs.inc.php';
+        register_watch_op($uid, WATCH_INSCR);
+        inscription_notifs_base($uid);
+
+        // Default registration on forums
+        $p_for = 'xorg.promo.x' . $promo;
+        $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements', $p_for);
+        foreach ($cible as $val) {
+            XDB::execute("INSERT INTO  forums.abos (fid,uid)
+                               SELECT  fid, {?} FROM forums.list WHERE nom={?}", $uid, $val);
+            if (XDB::affectedRows() == 0 && $val == $p_for) {
+                $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) { // + 
+                    $mymail = new PlMailer('admin/forums-promo.mail.tpl');
+                    $mymail->assign('promo', $promo);
+                    $mymail->send();
+                }
+            }
+        }
+
         // update number of subscribers (perms has changed)
         $globals->updateNbIns();
 
index a89d3f6..c9ca317 100644 (file)
@@ -38,13 +38,6 @@ class SearchModule extends PLModule
         exit;
     }
 
-    function on_subscribe($forlife, $uid, $promo, $pass)
-    {
-        require_once 'user.func.inc.php';
-        user_reindex($uid);
-    }
-
-
     function form_prepare()
     {
         Platal::page()->assign('formulaire',1);