}
}
+ // 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.";
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
</ol>");
}
- 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.
$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
// 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.
//
$res = XDB::iterRow(
"SELECT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom,
s.prenom, FIND_IN_SET('femme', s.flags) AS femme,
- GROUP_CONCAT(m.email) AS mails, MAX(m.last) AS dateDernier
+ GROUP_CONCAT(m.email SEPARATOR ', ') AS mails, MAX(m.last) AS dateDernier
FROM register_marketing AS m
INNER JOIN auth_user_md5 AS s ON (m.sender = s.user_id)
INNER JOIN aliases AS sa ON (sa.id = m.sender