X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fregister.php;h=b515348975bd3df5b6129e9e74f25844ae5c1e69;hb=f28684feb06bef0d1d00f52db84d160ec557c458;hp=b2c4a3d967747aeda596cacb71a784e553a67368;hpb=905cda00459649fa751c2ea292e079f5f05cae81;p=platal.git diff --git a/modules/register.php b/modules/register.php index b2c4a3d..b515348 100644 --- a/modules/register.php +++ b/modules/register.php @@ -1,6 +1,6 @@ changeTpl('register/step' . $subState->i('step') . '.tpl'); - $page->addJsLink('password.js'); if (isset($error)) { $page->trigError($error); } @@ -277,7 +276,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)) @@ -303,12 +302,12 @@ 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. $page->changeTpl('register/end.tpl'); - $page->addJsLink('do_challenge_response_logged.js'); $page->assign('forlife', $forlife); $page->assign('firstname', $firstname); @@ -328,6 +327,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,10 +343,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); @@ -372,8 +372,13 @@ class RegisterModule extends PLModule 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': @@ -391,6 +396,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();