X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fregister.php;h=3ddd658dee468cf81997da60f5f3e7a62ad6ff5f;hb=8a43972f58f0a77015ae9e509f1c073d188874d2;hp=3668521f39be0f4d5ebb1443ce4c7425bc3842f8;hpb=20f354f5992637e664fa71f98200289ed913d6c0;p=platal.git diff --git a/modules/register.php b/modules/register.php index 3668521..3ddd658 100644 --- a/modules/register.php +++ b/modules/register.php @@ -157,6 +157,15 @@ class RegisterModule extends PLModule } } + // Register the optional services requested by the user. + $services = array(); + foreach (array('ax_letter', 'imap', 'ml_promo', 'nl') as $service) { + if (Post::b($service)) { + $services[] = $service; + } + } + $sub_state['services'] = $services; + // Validate the password. if (!Post::v('response2', false)) { $err[] = "Le mot de passe n'est pas valide."; @@ -253,7 +262,7 @@ class RegisterModule extends PLModule if ($hash) { $res = XDB::query( "SELECT r.uid, r.forlife, r.bestalias, r.mailorg2, - r.password, r.email, r.naissance, u.nom, u.prenom, + r.password, r.email, r.services, r.naissance, u.nom, u.prenom, u.promo, FIND_IN_SET('femme', u.flags), u.naissance_ini FROM register_pending AS r INNER JOIN auth_user_md5 AS u ON r.uid = u.user_id @@ -274,7 +283,7 @@ class RegisterModule extends PLModule "); } - list($uid, $forlife, $bestalias, $mailorg2, $password, $email, + list($uid, $forlife, $bestalias, $mailorg2, $password, $email, $services, $naissance, $nom, $prenom, $promo, $femme, $naiss_ini) = $res->fetchOneRow(); // Prepare the template for display. @@ -321,6 +330,41 @@ class RegisterModule extends PLModule $redirect = new Redirect($user); $redirect->add_email($email); + // 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_MDP); + + // Subscribe the user to the services she did request at registration time. + foreach (explode(',', $services) as $service) { + switch ($service) { + case 'ax_letter': + Platal::load('axletter', 'axletter.inc.php'); + AXLetter::subscribe(); + break; + case 'imap': + require_once 'emails.inc.php'; + $user = S::user(); + $storage = new EmailStorage($user, 'imap'); + $storage->activate(); + break; + case 'ml_promo': + $r = XDB::query('SELECT id FROM groupex.asso WHERE diminutif = {?}', S::user()->promo()); + if ($r->numRows()) { + $asso_id = $r->fetchOneCell(); + XDB::execute('REPLACE INTO groupex.membres (uid, asso_id) + VALUES ({?}, {?})', + S::user()->id(), $asso_id); + $mmlist = new MMList(S::user()->id(), S::v('password')); + $mmlist->subscribe("promo" . S::v('promo')); + } + break; + case 'nl': + require_once 'newsletter.inc.php'; + NewsLetter::subscribe(); + break; + } + } + // Log the registration in the user session. S::logger($uid)->log('inscription', $email); XDB::execute("UPDATE register_pending @@ -369,10 +413,6 @@ class RegisterModule extends PLModule // Update the global registration count stats. $globals->updateNbIns(); - // 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_MDP); - // // Update collateral data sources, and inform watchers by email. //