Merge remote branch 'origin/xorg/maint' into xorg/1.0.2/master
[platal.git] / modules / register.php
index c53a456..331f618 100644 (file)
@@ -71,7 +71,7 @@ class RegisterModule extends PLModule
                                    SELECT  m.uid, m.sender, 0
                                      FROM  register_marketing AS m
                                     WHERE  m.hash
-                         ON DUPLICATE KEY  sender = VALUES(sender), success = VALUES(success)',
+                  ON DUPLICATE KEY UPDATE  sender = VALUES(sender), success = VALUES(success)',
                              $subState->s('hash'));
             }
         }
@@ -328,6 +328,7 @@ class RegisterModule extends PLModule
         //
         // Create the user account.
         //
+        XDB::startTransaction();
         XDB::execute("UPDATE  accounts
                          SET  password = {?}, state = 'active',
                               registration_date = NOW(), email = NULL
@@ -343,6 +344,7 @@ class RegisterModule extends PLModule
             XDB::execute("INSERT INTO  aliases (uid, alias, type)
                                VALUES  ({?}, {?}, 'alias')", $uid, $emailXorg2);
         }
+        XDB::commit();
 
         // Add the registration email address as first and only redirection.
         require_once 'emails.inc.php';
@@ -369,11 +371,11 @@ class RegisterModule extends PLModule
                     $r = XDB::query('SELECT id FROM groups WHERE diminutif = {?}', $yearpromo);
                     if ($r->numRows()) {
                         $asso_id = $r->fetchOneCell();
-                        XDB::execute('INSERT INTO  group_members (uid, asso_id)
-                                           VALUES  ({?}, {?})',
+                        XDB::execute('INSERT IGNORE INTO  group_members (uid, asso_id)
+                                                  VALUES  ({?}, {?})',
                                      $uid, $asso_id);
-                        $mmlist = new MMList($uid, S::v('password'));
-                        $mmlist->subscribe("promo" . S::v('promo'));
+                        $mmlist = new MMList($user);
+                        $mmlist->subscribe("promo" . $yearpromo);
                     }
                     break;
                 case 'nl':