Prevents notices.
[platal.git] / modules / register.php
CommitLineData
f59bc2fb 1<?php
2/***************************************************************************
5e1513f6 3 * Copyright (C) 2003-2011 Polytechnique.org *
f59bc2fb 4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22class RegisterModule extends PLModule
23{
24 function handlers()
25 {
26 return array(
94590511
SJ
27 'register' => $this->make_hook('register', AUTH_PUBLIC),
28 'register/end' => $this->make_hook('end', AUTH_PUBLIC),
f59bc2fb 29 );
30 }
31
26ba053e 32 function handler_register($page, $hash = null)
f59bc2fb 33 {
94590511
SJ
34 $alert = null;
35 $subState = new PlDict(S::v('subState', array()));
36 if (!$subState->has('step')) {
37 $subState->set('step', 0);
f59bc2fb 38 }
94590511
SJ
39 if (!$subState->has('backs')) {
40 $subState->set('backs', new PlDict());
2efe5355 41 }
94590511
SJ
42 if (Get::has('back') && Get::i('back') < $subState->i('step')) {
43 $subState->set('step', max(0, Get::i('back')));
44 $subState->v('back')->set($subState->v('back')->count() + 1, $subState->dict());
45 $subState->v('back')->kill('back');
46 if ($subState->v('backs')->count() == 3) {
97a82cd2 47 $alert .= "Tentative d'inscription très hésitante - ";
eaf30d86 48 }
f59bc2fb 49 }
50
20d90835 51 if ($hash) {
94590511 52 $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES);
94660e07 53 $nameTypes = array_flip($nameTypes);
94590511 54 $res = XDB::query("SELECT a.uid, pd.promo, pnl.name AS lastname, pnf.name AS firstname, p.xorg_id AS xorgid,
f036c896 55 p.birthdate_ref AS birthdateRef, FIND_IN_SET('watch', a.flags) AS watch, m.hash, a.type
f59bc2fb 56 FROM register_marketing AS m
94660e07 57 INNER JOIN accounts AS a ON (m.uid = a.uid)
4b0cf4e4 58 INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))
9f1cd432 59 INNER JOIN profiles AS p ON (p.pid = ap.pid)
94660e07
SJ
60 INNER JOIN profile_display AS pd ON (p.pid = pd.pid)
61 INNER JOIN profile_name AS pnl ON (p.pid = pnl.pid AND pnl.typeid = {?})
62 INNER JOIN profile_name AS pnf ON (p.pid = pnf.pid AND pnf.typeid = {?})
4c5a5921 63 WHERE m.hash = {?} AND a.state = 'pending'",
94660e07
SJ
64 $nameTypes['name_ini'], $nameTypes['firstname_ini'], $hash);
65
94590511
SJ
66 if ($res->numRows() == 1) {
67 $subState->merge($res->fetchOneRow());
f036c896 68 $subState->set('main_mail_domain', User::$sub_mail_domains[$subState->v('type')]);
94590511 69 $subState->set('yearpromo', substr($subState->s('promo'), 1, 4));
94660e07 70
00ba8a74
SJ
71 XDB::execute('INSERT INTO register_mstats (uid, sender, success)
72 SELECT m.uid, m.sender, 0
73 FROM register_marketing AS m
74 WHERE m.hash
a245a3e1 75 ON DUPLICATE KEY UPDATE sender = VALUES(sender), success = VALUES(success)',
94590511 76 $subState->s('hash'));
f59bc2fb 77 }
78 }
79
94590511 80 switch ($subState->i('step')) {
f59bc2fb 81 case 0:
8f201b69
FB
82 $wp = new PlWikiPage('Reference.Charte');
83 $wp->buildCache();
f59bc2fb 84 if (Post::has('step1')) {
94590511
SJ
85 $subState->set('step', 1);
86 if ($subState->has('hash')) {
87 $subState->set('step', 3);
460d8f55 88 $this->load('register.inc.php');
94590511 89 createAliases($subState);
f59bc2fb 90 }
91 }
92 break;
93
94 case 1:
94590511 95 if (Post::has('yearpromo')) {
f0a52f1b 96 $edu_type = Post::t('edu_type');
94590511 97 $yearpromo = Post::i('yearpromo');
f0a52f1b 98 $promo = $edu_type . $yearpromo;
94660e07 99 $res = XDB::query("SELECT COUNT(*)
94590511
SJ
100 FROM accounts AS a
101 INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))
102 INNER JOIN profiles AS p ON (p.pid = ap.pid)
103 INNER JOIN profile_display AS pd ON (p.pid = pd.pid)
94660e07 104 WHERE a.state = 'pending' AND p.deathdate IS NULL AND pd.promo = {?}",
a41bf2f8 105 $promo);
94660e07 106
a41bf2f8 107 if (!$res->fetchOneCell()) {
94660e07 108 $error = 'La promotion saisie est incorrecte ou tous les camarades de cette promotion sont inscrits !';
f59bc2fb 109 } else {
94590511
SJ
110 $subState->set('step', 2);
111 $subState->set('promo', $promo);
112 $subState->set('yearpromo', $yearpromo);
f0a52f1b
SJ
113 $subState->set('edu_type', $edu_type);
114 if ($edu_type == 'X') {
115 if ($yearpromo >= 1996 && $yearpromo < 2000) {
116 $subState->set('schoolid', ($yearpromo % 100) * 10 . '???');
117 } elseif($yearpromo >= 2000) {
118 $subState->set('schoolid', 100 + ($yearpromo % 100) . '???');
119 }
120 } else {
121 $subState->set('schoolid', '');
f59bc2fb 122 }
123 }
124 }
125 break;
126
127 case 2:
128 if (count($_POST)) {
460d8f55 129 $this->load('register.inc.php');
94590511
SJ
130 $subState->set('firstname', Post::t('firstname'));
131 $subState->set('lastname', Post::t('lastname'));
132 $subState->set('schoolid', Post::i('schoolid'));
133 $error = checkNewUser($subState);
f59bc2fb 134
94660e07
SJ
135 if ($error !== true) {
136 break;
137 }
94590511 138 $error = createAliases($subState);
94660e07
SJ
139 if ($error === true) {
140 unset($error);
94590511 141 $subState->set('step', 3);
f59bc2fb 142 }
143 }
144 break;
145
146 case 3:
147 if (count($_POST)) {
460d8f55 148 $this->load('register.inc.php');
97a82cd2
VZ
149
150 // Validate the email address format and domain.
c6310567 151 require_once 'emails.inc.php';
94660e07 152
5e2307dc 153 if (!isvalid_email(Post::v('email'))) {
94660e07 154 $error[] = "Le champ 'Email' n'est pas valide.";
5e2307dc 155 } elseif (!isvalid_email_redirection(Post::v('email'))) {
94590511 156 $error[] = $subState->s('forlife') . ' doit renvoyer vers un email existant '
94660e07 157 . 'valide, en particulier, il ne peut pas être renvoyé vers lui-même.';
f59bc2fb 158 }
97a82cd2
VZ
159
160 // Validate the birthday format and range.
94590511 161 $birth = Post::t('birthdate');
12e5d7a6 162 if (!preg_match('@^[0-3]?\d/[01]?\d/(19|20)?\d{2}$@', $birth)) {
94660e07 163 $error[] = "La 'Date de naissance' n'est pas correcte.";
35cd1be1 164 } else {
12e5d7a6 165 $birth = explode('/', $birth, 3);
94660e07 166 for ($i = 0; $i < 3; ++$i)
7caaaf6d 167 $birth[$i] = intval($birth[$i]);
94660e07
SJ
168 if ($birth[2] < 100) {
169 $birth[2] += 1900;
170 }
7caaaf6d 171 $year = $birth[2];
94590511 172 $promo = $subState->i('yearpromo');
35cd1be1 173 if ($year > $promo - 15 || $year < $promo - 30) {
94660e07 174 $error[] = "La 'Date de naissance' n'est pas correcte.";
97a82cd2 175 $alert = "Date de naissance incorrecte à l'inscription - ";
94590511 176 $subState->set('wrong_birthdate', $birth);
35cd1be1 177 }
f59bc2fb 178 }
179
3546b253
VZ
180 // Register the optional services requested by the user.
181 $services = array();
4b1a8575 182 foreach (array('ax_letter', 'imap', 'ml_promo', 'nl') as $service) {
3546b253
VZ
183 if (Post::b($service)) {
184 $services[] = $service;
185 }
186 }
94590511 187 $subState->set('services', $services);
3546b253 188
97a82cd2 189 // Validate the password.
81b5a6c9 190 if (!Post::v('pwhash', false)) {
94660e07 191 $error[] = "Le mot de passe n'est pas valide.";
97a82cd2
VZ
192 }
193
194 // Check if the given email is known as dangerous.
94590511
SJ
195 $res = XDB::query("SELECT state, description
196 FROM email_watch
197 WHERE email = {?} AND state != 'safe'",
94660e07 198 Post::v('email'));
94590511 199 $bannedEmail = false;
15836cdd
FB
200 if ($res->numRows()) {
201 list($state, $description) = $res->fetchOneRow();
97a82cd2 202 $alert .= "Email surveillé proposé à l'inscription - ";
94590511 203 $subState->set('email_desc', $description);
706ed3ef 204 if ($state == 'dangerous') {
94590511 205 $bannedEmail = true;
706ed3ef 206 }
5480a216 207 }
4b0cf4e4 208 if ($subState->i('watch') != 0) {
4653799f 209 $alert .= "Inscription d'un utilisateur surveillé - ";
0be07aa6 210 }
5480a216 211
94590511 212 if (($bannedIp = check_ip('unsafe'))) {
94660e07 213 unset($error);
bf273d6a 214 }
215
94660e07
SJ
216 if (isset($error)) {
217 $error = join('<br />', $error);
f59bc2fb 218 } else {
94590511
SJ
219 $subState->set('birthdate', sprintf("%04d-%02d-%02d",
220 intval($birth[2]), intval($birth[1]), intval($birth[0])));
221 $subState->set('email', Post::t('email'));
81b5a6c9 222 $subState->set('password', Post::t('pwhash'));
97a82cd2
VZ
223
224 // Update the current alert if the birthdate is incorrect,
225 // or if the IP address of the user has been banned.
94590511
SJ
226 if ($subState->s('birthdateRef') != '0000-00-00'
227 && $subState->s('birthdateRef') != $subState->s('birthdate')) {
ecc734a5 228 $alert .= "Date de naissance incorrecte à l'inscription - ";
229 }
94590511 230 if ($bannedIp) {
97a82cd2 231 $alert .= "Tentative d'inscription depuis une IP surveillée";
706ed3ef 232 }
97a82cd2
VZ
233
234 // Prevent banned user from actually registering; save the current state for others.
94590511 235 if ($bannedEmail || $bannedIp) {
115c90db 236 global $globals;
94660e07 237 $error = "Une erreur s'est produite lors de l'inscription."
1d55fe45 238 . " Merci de contacter <a href='mailto:register@{$globals->mail->domain}>"
239 . " register@{$globals->mail->domain}</a>"
94660e07 240 . " pour nous faire part de cette erreur.";
5480a216 241 } else {
94590511 242 $subState->set('step', 4);
4b0cf4e4 243 if ($subState->v('backs')->count() >= 3) {
94660e07 244 $alert .= "Fin d'une inscription hésitante.";
2efe5355 245 }
94590511 246 finishRegistration($subState);
5480a216 247 }
bf273d6a 248 }
f59bc2fb 249 }
250 break;
251 }
252
94590511 253 $_SESSION['subState'] = $subState->dict();
4653799f 254 if (!empty($alert)) {
5480a216 255 send_warning_mail($alert);
256 }
97a82cd2 257
94590511 258 $page->changeTpl('register/step' . $subState->i('step') . '.tpl');
94660e07
SJ
259 if (isset($error)) {
260 $page->trigError($error);
f59bc2fb 261 }
f59bc2fb 262 }
263
26ba053e 264 function handler_end($page, $hash = null)
f59bc2fb 265 {
266 global $globals;
94590511 267 $_SESSION['subState'] = array('step' => 5);
ecc734a5 268
97a82cd2
VZ
269 // Reject registration requests from unsafe IP addresses (and remove the
270 // registration information from the database, to prevent IP changes).
ecc734a5 271 if (check_ip('unsafe')) {
94660e07 272 send_warning_mail('Une IP surveillée a tenté de finaliser son inscription.');
97a82cd2
VZ
273 XDB::execute("DELETE FROM register_pending
274 WHERE hash = {?} AND hash != 'INSCRIT'", $hash);
ecc734a5 275 return PL_FORBIDDEN;
276 }
277
94590511
SJ
278 $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES);
279 $nameTypes = array_flip($nameTypes);
280
97a82cd2
VZ
281 // Retrieve the pre-registration information using the url-provided
282 // authentication token.
94590511
SJ
283 $res = XDB::query("SELECT r.uid, p.pid, r.forlife, r.bestalias, r.mailorg2,
284 r.password, r.email, r.services, r.naissance,
285 pnl.name AS lastname, pnf.name AS firstname,
96700179 286 pd.promo, p.sex, p.birthdate_ref, a.type AS eduType
94590511
SJ
287 FROM register_pending AS r
288 INNER JOIN accounts AS a ON (r.uid = a.uid)
289 INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))
9f1cd432 290 INNER JOIN profiles AS p ON (p.pid = ap.pid)
94590511
SJ
291 INNER JOIN profile_name AS pnl ON (p.pid = pnl.pid AND pnl.typeid = {?})
292 INNER JOIN profile_name AS pnf ON (p.pid = pnf.pid AND pnf.typeid = {?})
293 INNER JOIN profile_display AS pd ON (p.pid = pd.pid)
4c5a5921 294 WHERE hash = {?} AND hash != 'INSCRIT' AND a.state = 'pending'",
94590511 295 $nameTypes['name_ini'], $nameTypes['firstname_ini'], $hash);
97a82cd2 296 if (!$hash || $res->numRows() == 0) {
f59bc2fb 297 $page->kill("<p>Cette adresse n'existe pas, ou plus, sur le serveur.</p>
97a82cd2 298 <p>Causes probables&nbsp;:</p>
f59bc2fb 299 <ol>
a7de4ef7 300 <li>Vérifie que tu visites l'adresse du dernier
97a82cd2 301 email reçu s'il y en a eu plusieurs.</li>
a7de4ef7 302 <li>Tu as peut-être mal copié l'adresse reçue par
97a82cd2 303 email, vérifie-la à la main.</li>
a7de4ef7 304 <li>Tu as peut-être attendu trop longtemps pour
94590511 305 confirmer. Les pré-inscriptions sont annulées
f59bc2fb 306 tous les 30 jours.</li>
a7de4ef7 307 <li>Tu es en fait déjà inscrit.</li>
f59bc2fb 308 </ol>");
309 }
310
94590511 311 list($uid, $pid, $forlife, $bestalias, $emailXorg2, $password, $email, $services,
96700179
SJ
312 $birthdate, $lastname, $firstname, $promo, $sex, $birthdate_ref, $eduType) = $res->fetchOneRow();
313 $isX = ($eduType == 'x');
94590511 314 $yearpromo = substr($promo, 1, 4);
f0a52f1b 315 $mail_domain = User::$sub_mail_domains[$eduType] . $globals->mail->domain;
f59bc2fb 316
97a82cd2
VZ
317 // Prepare the template for display.
318 $page->changeTpl('register/end.tpl');
97a82cd2 319 $page->assign('forlife', $forlife);
94590511 320 $page->assign('firstname', $firstname);
97a82cd2
VZ
321
322 // Check if the user did enter a valid password; if not (or if none is found),
323 // get her an information page.
94590511
SJ
324 if (Post::has('response')) {
325 $expected_response = sha1("$forlife:$password:" . S::v('challenge'));
326 if (Post::v('response') != $expected_response) {
97a82cd2
VZ
327 $page->trigError("Mot de passe invalide.");
328 S::logger($uid)->log('auth_fail', 'bad password (register/end)');
329 return;
330 }
331 } else {
332 return;
333 }
f59bc2fb 334
97a82cd2
VZ
335 //
336 // Create the user account.
337 //
dd9b3613 338 XDB::startTransaction();
94590511
SJ
339 XDB::execute("UPDATE accounts
340 SET password = {?}, state = 'active',
33a4f3f9 341 registration_date = NOW(), email = NULL
94590511
SJ
342 WHERE uid = {?}", $password, $uid);
343 XDB::execute("UPDATE profiles
344 SET birthdate = {?}, last_change = NOW()
345 WHERE pid = {?}", $birthdate, $pid);
c0436d0b
SJ
346 XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain)
347 SELECT {?}, {?}, \'forlife\', \'\', id
348 FROM email_virtual_domains
349 WHERE name = {?}',
f036c896 350 $forlife, $uid, $mail_domain);
c0436d0b
SJ
351 XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain)
352 SELECT {?}, {?}, \'alias\', \'bestalias\', id
353 FROM email_virtual_domains
354 WHERE name = {?}',
f036c896 355 $bestalias, $uid, $mail_domain);
94590511 356 if ($emailXorg2) {
c0436d0b
SJ
357 XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain)
358 SELECT {?}, {?}, \'alias\', \'\', id
359 FROM email_virtual_domains
360 WHERE name = {?}',
f036c896 361 $emailXorg2, $uid, $mail_domain);
f59bc2fb 362 }
dd9b3613 363 XDB::commit();
f59bc2fb 364
97a82cd2 365 // Add the registration email address as first and only redirection.
726eaf7a 366 require_once 'emails.inc.php';
f0a52f1b 367 $user = User::getSilentWithUID($uid);
4b1a8575
SJ
368 $redirect = new Redirect($user);
369 $redirect->add_email($email);
f59bc2fb 370
3546b253
VZ
371 // Try to start a session (so the user don't have to log in); we will use
372 // the password available in Post:: to authenticate the user.
f0a52f1b 373 Platal::session()->start(AUTH_MDP);
3546b253
VZ
374
375 // Subscribe the user to the services she did request at registration time.
376 foreach (explode(',', $services) as $service) {
6ae6840d 377 require_once 'newsletter.inc.php';
3546b253
VZ
378 switch ($service) {
379 case 'ax_letter':
6ae6840d
RB
380 NewsLetter::forGroup(NewsLetter::GROUP_AX)->subscribe($user);
381 break;
382 case 'nl':
383 NewsLetter::forGroup(NewsLetter::GROUP_XORG)->subscribe($user);
3546b253
VZ
384 break;
385 case 'imap':
b4503762 386 Email::activate_storage($user, 'imap');
3546b253
VZ
387 break;
388 case 'ml_promo':
94590511 389 $r = XDB::query('SELECT id FROM groups WHERE diminutif = {?}', $yearpromo);
3546b253
VZ
390 if ($r->numRows()) {
391 $asso_id = $r->fetchOneCell();
24a67e95
SJ
392 XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id)
393 VALUES ({?}, {?})',
94590511 394 $uid, $asso_id);
e78be37f
FB
395 try {
396 $mmlist = new MMList($user);
397 $mmlist->subscribe("promo" . $yearpromo);
398 } catch (Exception $e) {
399 PlErrorReport::report($e);
400 $page->trigError("L'inscription à la liste promo" . $yearpromo . " a échouée.");
401 }
3546b253
VZ
402 }
403 break;
3546b253
VZ
404 }
405 }
406
97a82cd2 407 // Log the registration in the user session.
03c0a3a7 408 S::logger($uid)->log('inscription', $email);
97a82cd2
VZ
409 XDB::execute("UPDATE register_pending
410 SET hash = 'INSCRIT'
411 WHERE uid = {?}", $uid);
f59bc2fb 412
97a82cd2 413 // Congratulate our newly registered user by email.
94590511 414 $mymail = new PlMailer('register/success.mail.tpl');
4b1a8575 415 $mymail->addTo("\"{$user->fullName()}\" <{$user->forlifeEmail()}>");
96700179 416 if ($isX) {
96700179
SJ
417 $mymail->setSubject('Bienvenue parmi les X sur le web !');
418 } else {
96700179
SJ
419 $mymail->setSubject('Bienvenue sur Polytechnique.org !');
420 }
f59bc2fb 421 $mymail->assign('forlife', $forlife);
94590511 422 $mymail->assign('firstname', $firstname);
f59bc2fb 423 $mymail->send();
424
97a82cd2 425 // Index the user, to allow her to appear in searches.
bbdfd693 426 Profile::rebuildSearchTokens($pid);
2a54eb4d 427
97a82cd2 428 // Notify other users which were watching for her arrival.
00ba8a74
SJ
429 XDB::execute('INSERT INTO contacts (uid, contact)
430 SELECT uid, ni_id
431 FROM watch_nonins
432 WHERE ni_id = {?}', $uid);
94590511
SJ
433 XDB::execute('DELETE FROM watch_nonins
434 WHERE ni_id = {?}', $uid);
435 Platal::session()->updateNbNotifs();
03c0a3a7 436
97a82cd2 437 // Forcibly register the new user on default forums.
94590511
SJ
438 $promoForum = 'xorg.promo.' . strtolower($promo);
439 $registeredForums = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements', $promoForum);
440 foreach ($registeredForums as $forum) {
441 XDB::execute("INSERT INTO forum_subs (fid, uid)
97a82cd2 442 SELECT fid, {?}
94590511
SJ
443 FROM forums
444 WHERE name = {?}",
445 $uid, $val);
97a82cd2
VZ
446
447 // Notify the newsgroup admin of the promotion forum needs be created.
94590511
SJ
448 if (XDB::affectedRows() == 0 && $forum == $promoForum) {
449 $promoFull = new UserFilter(new UFC_Promo('=', UserFilter::DISPLAY, $promo));
450 $promoRegistered = new UserFilter(new PFC_And(
451 new UFC_Promo('=', UserFilter::DISPLAY, $promo),
452 new UFC_Registered(true),
453 new PFC_Not(new UFC_Dead())
454 ));
455 if ($promoRegistered->getTotalCount() > 0.2 * $promoFull->getTotalCount()) {
03c0a3a7
FB
456 $mymail = new PlMailer('admin/forums-promo.mail.tpl');
457 $mymail->assign('promo', $promo);
458 $mymail->send();
459 }
460 }
461 }
462
97a82cd2 463 // Update the global registration count stats.
ebfdf077 464 $globals->updateNbIns();
b5dd6f2f 465
97a82cd2
VZ
466 //
467 // Update collateral data sources, and inform watchers by email.
468 //
f59bc2fb 469
97a82cd2 470 // Email the referrer(s) of this new user.
94590511
SJ
471 $res = XDB::iterRow("SELECT sender, GROUP_CONCAT(email SEPARATOR ', ') AS mails, MAX(last) AS lastDate
472 FROM register_marketing
473 WHERE uid = {?}
474 GROUP BY sender
475 ORDER BY lastDate DESC", $uid);
97a82cd2
VZ
476 XDB::execute("UPDATE register_mstats
477 SET success = NOW()
478 WHERE uid = {?}", $uid);
f59bc2fb 479
d3447a09 480 $market = array();
94590511
SJ
481 while (list($senderid, $maketingEmails, $lastDate) = $res->next()) {
482 $sender = User::getWithUID($senderid);
07f1f729 483 $market[] = " - par {$sender->fullName()} sur $maketingEmails (le plus récemment le $lastDate)";
94590511
SJ
484 $mymail = new PlMailer('register/marketer.mail.tpl');
485 $mymail->setSubject("$firstname $lastname s'est inscrit à Polytechnique.org !");
330888b0 486 $mymail->addTo($sender);
94590511
SJ
487 $mymail->assign('sender', $sender);
488 $mymail->assign('firstname', $firstname);
489 $mymail->assign('lastname', $lastname);
490 $mymail->assign('promo', $promo);
491 $mymail->assign('sex', $sex);
f59bc2fb 492 $mymail->setTxtBody(wordwrap($msg, 72));
493 $mymail->send();
494 }
5f5f0eb5 495
97a82cd2 496 // Email the plat/al administrators about the registration.
9812efa0 497 if ($globals->register->notif) {
94590511
SJ
498 $mymail = new PlMailer('register/registration.mail.tpl');
499 $mymail->setSubject("Inscription de $firstname $lastname ($promo)");
500 $mymail->assign('firstname', $firstname);
501 $mymail->assign('lastname', $lastname);
502 $mymail->assign('promo', $promo);
503 $mymail->assign('sex', $sex);
504 $mymail->assign('birthdate', $birthdate);
505 $mymail->assign('birthdate_ref', $birthdate_ref);
506 $mymail->assign('forlife', $forlife);
507 $mymail->assign('email', $email);
4b0cf4e4 508 $mymail->assign('logger', S::logger());
defff1aa 509 if (count($market) > 0) {
94590511 510 $mymail->assign('market', implode("\n", $market));
defff1aa 511 }
9812efa0 512 $mymail->setTxtBody($msg);
eaf30d86 513 $mymail->send();
9812efa0 514 }
f59bc2fb 515
97a82cd2 516 // Remove old pending marketing requests for the new user.
e654517d 517 Marketing::clear($uid);
f59bc2fb 518
97a0a459
FB
519 pl_redirect('profile/edit');
520 }
f59bc2fb 521}
522
a7de4ef7 523// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
f59bc2fb 524?>