<?php
/***************************************************************************
- * Copyright (C) 2003-2009 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
}
}
+ // 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(S::user()->id());
+ 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 groups WHERE diminutif = {?}', S::user()->promo());
+ if ($r->numRows()) {
+ $asso_id = $r->fetchOneCell();
+ XDB::execute('REPLACE INTO group_members (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
$promo_forum = 'xorg.promo.x' . $promo;
$registered_forums = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements', $promo_forum);
foreach ($registered_forums as $forum) {
- XDB::execute("INSERT INTO forums.abos (fid,uid)
+ XDB::execute("INSERT INTO #forums#.abos (fid,uid)
SELECT fid, {?}
- FROM forums.list
+ FROM #forums#.list
WHERE nom = {?}",
$uid, $val);
// 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.
//