From 3546b2530b91c61700e33804ca631c03d0d5f223 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Mon, 27 Jul 2009 02:10:38 +0200 Subject: [PATCH] Allows users to subscribe to our main services (ax letter, imap, ml promo, nl) directly during the registration process. Signed-off-by: Vincent Zanotti --- modules/register.php | 52 ++++++++++++++++++++++++++++++++++----- modules/register/register.inc.php | 6 ++--- templates/register/step3.tpl | 36 ++++++++++++++++++++++++++- upgrade/0.10.1/00_inscription.sql | 2 ++ 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/modules/register.php b/modules/register.php index 61a7dfa..f2cd5e6 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. // diff --git a/modules/register/register.inc.php b/modules/register/register.inc.php index 5e153d7..19cd7f2 100644 --- a/modules/register/register.inc.php +++ b/modules/register/register.inc.php @@ -237,9 +237,9 @@ function finish_ins($sub_state) SET last_known_email = {?} WHERE matricule = {?}", $email, $mat); XDB::execute( - "REPLACE INTO register_pending (uid, forlife, bestalias, mailorg2, password, email, date, relance, naissance, hash) - VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?})", - $uid, $forlife, $bestalias, $mailorg2, $password, $email, $naissance, $hash); + "REPLACE INTO register_pending (uid, forlife, bestalias, mailorg2, password, email, date, relance, naissance, hash, services) + VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?}, {?})", + $uid, $forlife, $bestalias, $mailorg2, $password, $email, $naissance, $hash, implode(',', $services)); $mymail = new PlMailer('register/inscrire.mail.tpl'); $mymail->assign('mailorg', $bestalias); diff --git a/templates/register/step3.tpl b/templates/register/step3.tpl index 4a8c003..d48eb3f 100644 --- a/templates/register/step3.tpl +++ b/templates/register/step3.tpl @@ -96,8 +96,42 @@ {checkpasswd prompt="password" text="Terminer la pré-inscription"} + + - + + + + + + + + + + + + diff --git a/upgrade/0.10.1/00_inscription.sql b/upgrade/0.10.1/00_inscription.sql index a23ef9e..199aad9 100644 --- a/upgrade/0.10.1/00_inscription.sql +++ b/upgrade/0.10.1/00_inscription.sql @@ -33,4 +33,6 @@ CREATE TABLE IF NOT EXISTS reminder ( PRIMARY KEY(uid, type_id) ) CHARSET=utf8; +ALTER TABLE register_pending ADD services SET('ax_letter', 'imap', 'ml_promo', 'nl') NOT NULL DEFAULT '' AFTER hash; + -- vim:set syntax=mysql: -- 2.1.4
+ Services supplémentaires
Pour profiter pleinement de ta nouvelle inscription, nous te proposons :
+
+
+
+ de recevoir chaque mois la lettre mensuelle de Polytechnique.org contenant les activités et nouvelles de la communauté des X. +
+
+
+ de recevoir les informations importantes de l'AX. +
+
+
+ de recevoir les informations plus spécifiques de ta promotion pour pouvoir participer plus facilement aux événements + qu'elle organise. Nous t'inscrivons donc dans le groupe de la promotion {$smarty.session.sub_state.promo}. +
+
+
+ d'avoir un accès de secours aux 30 derniers jours d'emails reçus sur ton adresse Polytechnique.org. +
+
+
Valider mon inscription :