X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fregister.php;h=f1d8b58fbb4c459117d69357ba39aa4cda4ea0e7;hb=57cc5e633e763b14d3adfa4ec1b59f87613ea47a;hp=5df8c93f425a8cd7a06fd32bc1c16493cab2cb97;hpb=63331d9bdeca8d8d6b0cabd028705f69c7ba4440;p=platal.git diff --git a/modules/register.php b/modules/register.php index 5df8c93..f1d8b58 100644 --- a/modules/register.php +++ b/modules/register.php @@ -67,10 +67,11 @@ class RegisterModule extends PLModule $subState->merge($res->fetchOneRow()); $subState->set('yearpromo', substr($subState->s('promo'), 1, 4)); - XDB::execute('REPLACE INTO register_mstats (uid,sender,success) - SELECT m.uid, m.sender, 0 - FROM register_marketing AS m - WHERE m.hash', + XDB::execute('INSERT INTO register_mstats (uid, sender, success) + SELECT m.uid, m.sender, 0 + FROM register_marketing AS m + WHERE m.hash + ON DUPLICATE KEY UPDATE sender = VALUES(sender), success = VALUES(success)', $subState->s('hash')); } } @@ -276,7 +277,7 @@ class RegisterModule extends PLModule $res = XDB::query("SELECT r.uid, p.pid, r.forlife, r.bestalias, r.mailorg2, r.password, r.email, r.services, r.naissance, pnl.name AS lastname, pnf.name AS firstname, - pd.promo, p.sex, p.birthdate_ref + pd.promo, p.sex, p.birthdate_ref, a.type AS eduType FROM register_pending AS r INNER JOIN accounts AS a ON (r.uid = a.uid) INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms)) @@ -302,7 +303,8 @@ class RegisterModule extends PLModule } list($uid, $pid, $forlife, $bestalias, $emailXorg2, $password, $email, $services, - $birthdate, $lastname, $firstname, $promo, $sex, $birthdate_ref) = $res->fetchOneRow(); + $birthdate, $lastname, $firstname, $promo, $sex, $birthdate_ref, $eduType) = $res->fetchOneRow(); + $isX = ($eduType == 'x'); $yearpromo = substr($promo, 1, 4); // Prepare the template for display. @@ -327,6 +329,7 @@ class RegisterModule extends PLModule // // Create the user account. // + XDB::startTransaction(); XDB::execute("UPDATE accounts SET password = {?}, state = 'active', registration_date = NOW(), email = NULL @@ -342,10 +345,10 @@ 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'; - $user = User::getSilentWithUID($uid); $redirect = new Redirect($user); $redirect->add_email($email); @@ -368,11 +371,16 @@ class RegisterModule extends PLModule $r = XDB::query('SELECT id FROM groups WHERE diminutif = {?}', $yearpromo); if ($r->numRows()) { $asso_id = $r->fetchOneCell(); - XDB::execute('REPLACE 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')); + try { + $mmlist = new MMList($user); + $mmlist->subscribe("promo" . $yearpromo); + } catch (Exception $e) { + PlErrorReport::report($e); + $page->trigError("L'inscription à la liste promo" . $yearpromo . " a échouée."); + } } break; case 'nl': @@ -390,6 +398,12 @@ class RegisterModule extends PLModule // Congratulate our newly registered user by email. $mymail = new PlMailer('register/success.mail.tpl'); + $mymail->addTo("\"{$user->fullName()}\" <{$user->forlifeEmail()}>"); + if ($isX) { + $mymail->setSubject('Bienvenue parmi les X sur le web !'); + } else { + $mymail->setSubject('Bienvenue sur Polytechnique.org !'); + } $mymail->assign('forlife', $forlife); $mymail->assign('firstname', $firstname); $mymail->send(); @@ -398,10 +412,10 @@ class RegisterModule extends PLModule Profile::rebuildSearchTokens($pid); // Notify other users which were watching for her arrival. - XDB::execute('REPLACE INTO contacts (uid, contact) - SELECT uid, ni_id - FROM watch_nonins - WHERE ni_id = {?}', $uid); + XDB::execute('INSERT INTO contacts (uid, contact) + SELECT uid, ni_id + FROM watch_nonins + WHERE ni_id = {?}', $uid); XDB::execute('DELETE FROM watch_nonins WHERE ni_id = {?}', $uid); Platal::session()->updateNbNotifs();