Moving to GitHub.
[platal.git] / modules / register.php
index fd9bdd3..82ada2c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -193,7 +193,7 @@ class RegisterModule extends PLModule
 
                     // Register the optional services requested by the user.
                     $services = array();
-                    foreach (array('ax_letter', 'imap', 'ml_promo', 'nl') as $service) {
+                    foreach (array('com_letters', 'imap', 'ml_promo', 'nl') as $service) {
                         if (Post::b($service)) {
                             $services[] = $service;
                         }
@@ -385,6 +385,10 @@ class RegisterModule extends PLModule
         }
         XDB::commit();
 
+        // Try to start a session (so the user don't have to log in); we will use
+        // the password available in Post:: to authenticate the user.
+        Platal::session()->start(AUTH_PASSWD);
+
         // Add the registration email address as first and only redirection.
         require_once 'emails.inc.php';
         $user = User::getSilentWithUID($uid);
@@ -400,17 +404,18 @@ class RegisterModule extends PLModule
             update_alias_user($old_account_email, $user->forlifeEmail());
         }
 
-        // Try to start a session (so the user don't have to log in); we will use
-        // the password available in Post:: to authenticate the user.
-        Platal::session()->start(AUTH_PASSWD);
-
         // Subscribe the user to the services she did request at registration time.
         require_once 'newsletter.inc.php';
         foreach (explode(',', $services) as $service) {
             switch ($service) {
-                case 'ax_letter':
+                case 'ax_letter': /* This option is deprecated by 'com_letters' */
                     NewsLetter::forGroup(NewsLetter::GROUP_AX)->subscribe($user);
                     break;
+                case 'com_letters':
+                    NewsLetter::forGroup(NewsLetter::GROUP_AX)->subscribe($user);
+                    NewsLetter::forGroup(NewsLetter::GROUP_EP)->subscribe($user);
+                    NewsLetter::forGroup(NewsLetter::GROUP_FX)->subscribe($user);
+                    break;
                 case 'nl':
                     NewsLetter::forGroup(NewsLetter::GROUP_XORG)->subscribe($user);
                     break;
@@ -426,8 +431,7 @@ class RegisterModule extends PLModule
                                                       VALUES  ({?}, {?})',
                                          $uid, $asso_id);
                             try {
-                                $mmlist = new MMList($user);
-                                $mmlist->subscribe("promo" . $yearpromo);
+                                MailingList::subscribePromo($yearpromo, $user);
                             } catch (Exception $e) {
                                 PlErrorReport::report($e);
                                 $page->trigError("L'inscription à la liste promo" . $yearpromo . " a échouée.");
@@ -461,9 +465,9 @@ class RegisterModule extends PLModule
 
         // Notify other users which were watching for her arrival.
         XDB::execute('INSERT INTO  contacts (uid, contact)
-                           SELECT  uid, ni_id
+                           SELECT  uid, {?}
                              FROM  watch_nonins
-                            WHERE  ni_id = {?}', $uid);
+                            WHERE  ni_id = {?}', $pid, $uid);
         XDB::execute('DELETE FROM  watch_nonins
                             WHERE  ni_id = {?}', $uid);
         Platal::session()->updateNbNotifs();
@@ -564,5 +568,5 @@ class RegisterModule extends PLModule
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>