Commit | Line | Data |
---|---|---|
f59bc2fb | 1 | <?php |
2 | /*************************************************************************** | |
179afa7f | 3 | * Copyright (C) 2003-2008 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 | ||
22 | class RegisterModule extends PLModule | |
23 | { | |
24 | function handlers() | |
25 | { | |
26 | return array( | |
20d90835 | 27 | 'register' => $this->make_hook('register', AUTH_PUBLIC), |
28 | 'register/end' => $this->make_hook('end', AUTH_PUBLIC), | |
2b6d403c | 29 | 'register/end.php' => $this->make_hook('end_old', AUTH_PUBLIC), |
f59bc2fb | 30 | 'register/success' => $this->make_hook('success', AUTH_MDP), |
97a0a459 | 31 | 'register/save' => $this->make_hook('save', AUTH_MDP), |
f59bc2fb | 32 | ); |
33 | } | |
34 | ||
20d90835 | 35 | function handler_register(&$page, $hash = null) |
f59bc2fb | 36 | { |
5480a216 | 37 | $alert = null; |
cab08090 | 38 | $sub_state = S::v('sub_state', Array()); |
f59bc2fb | 39 | if (!isset($sub_state['step'])) { |
40 | $sub_state['step'] = 0; | |
41 | } | |
2efe5355 | 42 | if (!isset($sub_state['backs'])) { |
43 | $sub_state['backs'] = array(); | |
44 | } | |
5e2307dc | 45 | if (Get::has('back') && Get::i('back') < $sub_state['step']) { |
46 | $sub_state['step'] = max(0,Get::i('back')); | |
2efe5355 | 47 | $state = $sub_state; |
48 | unset($state['backs']); | |
49 | $sub_state['backs'][] = $state; | |
50 | if (count($sub_state['backs']) == 3) { | |
51 | $alert .= "Tentative d'inscription tres hesitante - "; | |
eaf30d86 | 52 | } |
f59bc2fb | 53 | } |
54 | ||
2b6d403c | 55 | // Compatibility with old sources, keep it atm |
56 | if (!$hash && Env::has('hash')) { | |
5e2307dc | 57 | $hash = Env::v('hash'); |
2b6d403c | 58 | } |
59 | ||
20d90835 | 60 | if ($hash) { |
08cce2ff | 61 | $res = XDB::query( |
ecc734a5 | 62 | "SELECT m.uid, u.promo, u.nom, u.prenom, u.matricule, u.naissance_ini, FIND_IN_SET('watch', u.flags) |
f59bc2fb | 63 | FROM register_marketing AS m |
64 | INNER JOIN auth_user_md5 AS u ON u.user_id = m.uid | |
20d90835 | 65 | WHERE m.hash={?}", $hash); |
ecc734a5 | 66 | if (list($uid, $promo, $nom, $prenom, $ourmat, $naiss, $watch) = $res->fetchOneRow()) { |
f59bc2fb | 67 | $sub_state['uid'] = $uid; |
20d90835 | 68 | $sub_state['hash'] = $hash; |
f59bc2fb | 69 | $sub_state['promo'] = $promo; |
70 | $sub_state['nom'] = $nom; | |
71 | $sub_state['prenom'] = $prenom; | |
72 | $sub_state['ourmat'] = $ourmat; | |
eaf30d86 | 73 | $sub_state['watch'] = $watch; |
ecc734a5 | 74 | $sub_state['naissance_ini'] = $naiss; |
f59bc2fb | 75 | |
08cce2ff | 76 | XDB::execute( |
f59bc2fb | 77 | "REPLACE INTO register_mstats (uid,sender,success) |
78 | SELECT m.uid, m.sender, 0 | |
79 | FROM register_marketing AS m | |
80 | WHERE m.hash", $sub_state['hash']); | |
81 | } | |
82 | } | |
83 | ||
84 | switch ($sub_state['step']) { | |
85 | case 0: | |
8f201b69 FB |
86 | $wp = new PlWikiPage('Reference.Charte'); |
87 | $wp->buildCache(); | |
f59bc2fb | 88 | if (Post::has('step1')) { |
89 | $sub_state['step'] = 1; | |
90 | if (isset($sub_state['hash'])) { | |
91 | $sub_state['step'] = 3; | |
433336f3 | 92 | require_once(dirname(__FILE__) . '/register/register.inc.php'); |
f59bc2fb | 93 | create_aliases($sub_state); |
94 | } | |
95 | } | |
96 | break; | |
97 | ||
98 | case 1: | |
99 | if (Post::has('promo')) { | |
5e2307dc | 100 | $promo = Post::i('promo'); |
a41bf2f8 | 101 | $res = XDB::query("SELECT COUNT(*) |
102 | FROM auth_user_md5 | |
103 | WHERE perms='pending' AND deces = '0000-00-00' | |
104 | AND promo = {?}", | |
105 | $promo); | |
106 | if (!$res->fetchOneCell()) { | |
107 | $err = "La promotion saisie est incorrecte ou tous les camardes de cette promo sont inscrits !"; | |
f59bc2fb | 108 | } else { |
109 | $sub_state['step'] = 2; | |
110 | $sub_state['promo'] = $promo; | |
111 | if ($promo >= 1996 && $promo<2000) { | |
112 | $sub_state['mat'] = ($promo % 100)*10 . '???'; | |
113 | } elseif($promo >= 2000) { | |
114 | $sub_state['mat'] = 100 + ($promo % 100) . '???'; | |
115 | } | |
116 | } | |
117 | } | |
118 | break; | |
119 | ||
120 | case 2: | |
121 | if (count($_POST)) { | |
433336f3 | 122 | require_once(dirname(__FILE__) . '/register/register.inc.php'); |
5e2307dc | 123 | $sub_state['prenom'] = Post::v('prenom'); |
124 | $sub_state['nom'] = Post::v('nom'); | |
125 | $sub_state['mat'] = Post::v('mat'); | |
f59bc2fb | 126 | $err = check_new_user($sub_state); |
127 | ||
128 | if ($err !== true) { break; } | |
129 | $err = create_aliases($sub_state); | |
130 | if ($err === true) { | |
131 | unset($err); | |
132 | $sub_state['step'] = 3; | |
133 | } | |
134 | } | |
135 | break; | |
136 | ||
137 | case 3: | |
138 | if (count($_POST)) { | |
433336f3 | 139 | require_once(dirname(__FILE__) . '/register/register.inc.php'); |
5e2307dc | 140 | if (!isvalid_email(Post::v('email'))) { |
f59bc2fb | 141 | $err[] = "Le champ 'E-mail' n'est pas valide."; |
5e2307dc | 142 | } elseif (!isvalid_email_redirection(Post::v('email'))) { |
f59bc2fb | 143 | $err[] = $sub_state['forlife']." doit renvoyer vers un email existant ". |
a7de4ef7 | 144 | "valide, en particulier, il ne peut pas être renvoyé vers lui-même."; |
f59bc2fb | 145 | } |
1970c12b | 146 | $birth = trim(Env::v('naissance')); |
12e5d7a6 | 147 | if (!preg_match('@^[0-3]?\d/[01]?\d/(19|20)?\d{2}$@', $birth)) { |
f59bc2fb | 148 | $err[] = "La 'Date de naissance' n'est pas correcte."; |
35cd1be1 | 149 | } else { |
12e5d7a6 | 150 | $birth = explode('/', $birth, 3); |
7caaaf6d AA |
151 | for ($i = 0; $i < 3; $i++) |
152 | $birth[$i] = intval($birth[$i]); | |
153 | if ($birth[2] < 100) $birth[2] += 1900; | |
154 | $year = $birth[2]; | |
35cd1be1 | 155 | $promo = (int)$sub_state['promo']; |
156 | if ($year > $promo - 15 || $year < $promo - 30) { | |
157 | $err[] = "La 'Date de naissance' n'est pas correcte."; | |
5480a216 | 158 | $alert = "Date de naissance incorrecte a l'inscription - "; |
fb5d164e | 159 | $sub_state['wrong_naissance'] = $birth; |
35cd1be1 | 160 | } |
f59bc2fb | 161 | } |
162 | ||
bf273d6a | 163 | // Check if the given email is known as dangerous |
15836cdd FB |
164 | $res = XDB::query("SELECT w.state, w.description |
165 | FROM emails_watch AS w | |
166 | WHERE w.email = {?} AND w.state != 'safe'", | |
167 | Post::v('email')); | |
706ed3ef | 168 | $email_banned = false; |
15836cdd FB |
169 | if ($res->numRows()) { |
170 | list($state, $description) = $res->fetchOneRow(); | |
171 | $alert .= "Email surveille propose a l'inscription - "; | |
172 | $sub_state['email_desc'] = $description; | |
706ed3ef FB |
173 | if ($state == 'dangerous') { |
174 | $email_banned = true; | |
175 | } | |
5480a216 | 176 | } |
0be07aa6 | 177 | if ($sub_state['watch']) { |
4653799f | 178 | $alert .= "Inscription d'un utilisateur surveillé - "; |
0be07aa6 | 179 | } |
5480a216 | 180 | |
181 | if (check_ip('unsafe')) { | |
182 | unset($err); | |
bf273d6a | 183 | } |
184 | ||
f59bc2fb | 185 | if (isset($err)) { |
186 | $err = join('<br />', $err); | |
187 | } else { | |
12e5d7a6 FB |
188 | $sub_state['naissance'] = sprintf("%04d-%02d-%02d", |
189 | intval($birth[2]), intval($birth[1]), intval($birth[0])); | |
ecc734a5 | 190 | if ($sub_state['naissance_ini'] != '0000-00-00' && $sub_state['naissance'] != $sub_state['naissance_ini']) { |
191 | $alert .= "Date de naissance incorrecte à l'inscription - "; | |
192 | } | |
5e2307dc | 193 | $sub_state['email'] = Post::v('email'); |
706ed3ef FB |
194 | $ip_banned = check_ip('unsafe'); |
195 | if ($ip_banned) { | |
196 | $alert .= "Tentative d'inscription depuis une IP surveillee"; | |
197 | } | |
198 | if ($email_banned || $ip_banned) { | |
115c90db | 199 | global $globals; |
5480a216 | 200 | $err = "Une erreur s'est produite lors de l'inscription." |
1d55fe45 | 201 | . " Merci de contacter <a href='mailto:register@{$globals->mail->domain}>" |
202 | . " register@{$globals->mail->domain}</a>" | |
5480a216 | 203 | . " pour nous faire part de cette erreur"; |
5480a216 | 204 | } else { |
205 | $sub_state['step'] = 4; | |
9fc2d0d2 | 206 | if (count($sub_state['backs']) >= 3) { |
a7de4ef7 | 207 | $alert .= "Fin d'une inscription hésitante"; |
2efe5355 | 208 | } |
5480a216 | 209 | finish_ins($sub_state); |
210 | } | |
bf273d6a | 211 | } |
f59bc2fb | 212 | } |
213 | break; | |
214 | } | |
215 | ||
216 | $_SESSION['sub_state'] = $sub_state; | |
4653799f | 217 | if (!empty($alert)) { |
5480a216 | 218 | send_warning_mail($alert); |
219 | } | |
a41bf2f8 | 220 | $page->changeTpl('register/step'.intval($sub_state['step']).'.tpl'); |
f59bc2fb | 221 | if (isset($err)) { |
a7d35093 | 222 | $page->trigError($err); |
f59bc2fb | 223 | } |
f59bc2fb | 224 | } |
225 | ||
2b6d403c | 226 | function handler_end_old(&$page) |
227 | { | |
5e2307dc | 228 | return $this->handler_end($page, Env::v('hash')); |
2b6d403c | 229 | } |
230 | ||
f59bc2fb | 231 | function handler_end(&$page, $hash = null) |
232 | { | |
233 | global $globals; | |
234 | ||
ecc734a5 | 235 | |
f59bc2fb | 236 | $page->changeTpl('register/end.tpl'); |
a41bf2f8 | 237 | $_SESSION['sub_state'] = array('step' => 5); |
ecc734a5 | 238 | |
239 | if (check_ip('unsafe')) { | |
240 | send_warning_mail('Une IP surveillée a tenté de finaliser son inscription'); | |
241 | XDB::execute('DELETE FROM register_pending | |
242 | WHERE hash = {?} AND hash != \'INSCRIT\'', $hash); | |
243 | return PL_FORBIDDEN; | |
244 | } | |
245 | ||
f59bc2fb | 246 | require_once('user.func.inc.php'); |
247 | ||
248 | if ($hash) { | |
08cce2ff | 249 | $res = XDB::query( |
f59bc2fb | 250 | "SELECT r.uid, r.forlife, r.bestalias, r.mailorg2, |
251 | r.password, r.email, r.naissance, u.nom, u.prenom, | |
ecc734a5 | 252 | u.promo, FIND_IN_SET('femme', u.flags), u.naissance_ini |
f59bc2fb | 253 | FROM register_pending AS r |
254 | INNER JOIN auth_user_md5 AS u ON r.uid = u.user_id | |
20d90835 | 255 | WHERE hash={?} AND hash!='INSCRIT'", $hash); |
f59bc2fb | 256 | } |
257 | ||
258 | if (!$hash || !list($uid, $forlife, $bestalias, $mailorg2, $password, $email, | |
ecc734a5 | 259 | $naissance, $nom, $prenom, $promo, $femme, $naiss_ini) = $res->fetchOneRow()) |
f59bc2fb | 260 | { |
261 | $page->kill("<p>Cette adresse n'existe pas, ou plus, sur le serveur.</p> | |
262 | <p>Causes probables :</p> | |
263 | <ol> | |
a7de4ef7 | 264 | <li>Vérifie que tu visites l'adresse du dernier |
265 | e-mail reçu s'il y en a eu plusieurs.</li> | |
266 | <li>Tu as peut-être mal copié l'adresse reçue par | |
267 | mail, vérifie-la à la main.</li> | |
268 | <li>Tu as peut-être attendu trop longtemps pour | |
269 | confirmer. Les pré-inscriptions sont annulées | |
f59bc2fb | 270 | tous les 30 jours.</li> |
a7de4ef7 | 271 | <li>Tu es en fait déjà inscrit.</li> |
f59bc2fb | 272 | </ol>"); |
273 | } | |
274 | ||
275 | ||
276 | ||
277 | /***********************************************************/ | |
278 | /****************** REALLY CREATE ACCOUNT ******************/ | |
279 | /***********************************************************/ | |
280 | ||
08cce2ff | 281 | XDB::execute('UPDATE auth_user_md5 |
f59bc2fb | 282 | SET password={?}, perms="user", |
283 | date=NOW(), naissance={?}, date_ins = NOW() | |
284 | WHERE user_id={?}', $password, $naissance, $uid); | |
08cce2ff | 285 | XDB::execute('REPLACE INTO auth_user_quick (user_id) VALUES ({?})', $uid); |
286 | XDB::execute('INSERT INTO aliases (id,alias,type) | |
f59bc2fb | 287 | VALUES ({?}, {?}, "a_vie")', $uid, |
288 | $forlife); | |
08cce2ff | 289 | XDB::execute('INSERT INTO aliases (id,alias,type,flags) |
f59bc2fb | 290 | VALUES ({?}, {?}, "alias", "bestalias")', |
291 | $uid, $bestalias); | |
292 | if ($mailorg2) { | |
08cce2ff | 293 | XDB::execute('INSERT INTO aliases (id,alias,type) |
f59bc2fb | 294 | VALUES ({?}, {?}, "alias")', $uid, |
295 | $mailorg2); | |
296 | } | |
297 | ||
298 | require_once('emails.inc.php'); | |
299 | $redirect = new Redirect($uid); | |
300 | $redirect->add_email($email); | |
301 | ||
302 | // on cree un objet logger et on log l'inscription | |
68ef4e7d | 303 | $logger = new PlLogger($uid); |
732e5855 | 304 | S::logger()->log('inscription', $email); |
f59bc2fb | 305 | |
08cce2ff | 306 | XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid); |
f59bc2fb | 307 | |
8d8f7607 | 308 | global $platal; |
309 | $platal->on_subscribe($forlife, $uid, $promo, $password); | |
f59bc2fb | 310 | |
1e33266a | 311 | $mymail = new PlMailer('register/inscription.reussie.tpl'); |
f59bc2fb | 312 | $mymail->assign('forlife', $forlife); |
313 | $mymail->assign('prenom', $prenom); | |
314 | $mymail->send(); | |
315 | ||
2a54eb4d | 316 | require_once('user.func.inc.php'); |
317 | user_reindex($uid); | |
318 | ||
b5dd6f2f | 319 | // update number of subscribers (perms has changed) |
ebfdf077 | 320 | $globals->updateNbIns(); |
b5dd6f2f | 321 | |
ecc734a5 | 322 | if (!start_connexion($uid, false)) { |
5480a216 | 323 | return PL_FORBIDDEN; |
324 | } | |
f59bc2fb | 325 | $_SESSION['auth'] = AUTH_MDP; |
326 | ||
327 | /***********************************************************/ | |
a7de4ef7 | 328 | /************* envoi d'un mail au démarcheur ***************/ |
f59bc2fb | 329 | /***********************************************************/ |
08cce2ff | 330 | $res = XDB::iterRow( |
ebb129a4 FB |
331 | "SELECT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom, |
332 | s.prenom, FIND_IN_SET('femme', s.flags) AS femme, | |
381a3df0 | 333 | GROUP_CONCAT(m.email) AS mails, MAX(m.last) AS dateDernier |
f59bc2fb | 334 | FROM register_marketing AS m |
335 | INNER JOIN auth_user_md5 AS s ON ( m.sender = s.user_id ) | |
336 | INNER JOIN aliases AS sa ON ( sa.id = m.sender | |
337 | AND FIND_IN_SET('bestalias', sa.flags) ) | |
ebb129a4 | 338 | WHERE m.uid = {?} |
38acbdf3 BFPC |
339 | GROUP BY m.sender |
340 | ORDER BY dateDernier DESC", $uid); | |
08cce2ff | 341 | XDB::execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid); |
f59bc2fb | 342 | |
ebb129a4 | 343 | $market = array(); |
381a3df0 OLF |
344 | while (list($salias, $snom, $sprenom, $sfemme, $mails, $dateDernier) = $res->next()) { |
345 | $market[] = " - par $snom $sprenom sur $mails (le plus récemment le $dateDernier)"; | |
1e33266a | 346 | $mymail = new PlMailer(); |
a7de4ef7 | 347 | $mymail->setSubject("$prenom $nom s'est inscrit à Polytechnique.org !"); |
1d55fe45 | 348 | $mymail->setFrom('"Marketing Polytechnique.org" <register@' . $globals->mail->domain . '>'); |
f59bc2fb | 349 | $mymail->addTo("\"$sprenom $snom\" <$salias@{$globals->mail->domain}>"); |
a7de4ef7 | 350 | $msg = ($sfemme?'Chère':'Cher')." $sprenom,\n\n" |
ecc734a5 | 351 | . "Nous t'écrivons pour t'informer que $prenom $nom (X$promo), " |
a7de4ef7 | 352 | . "que tu avais incité".($femme?'e':'')." à s'inscrire à Polytechnique.org, " |
353 | . "vient à l'instant de terminer son inscription.\n\n" | |
354 | . "Merci de ta participation active à la reconnaissance de ce site !!!\n\n" | |
f59bc2fb | 355 | . "Bien cordialement,\n" |
a7de4ef7 | 356 | . "L'équipe Polytechnique.org"; |
f59bc2fb | 357 | $mymail->setTxtBody(wordwrap($msg, 72)); |
358 | $mymail->send(); | |
359 | } | |
5f5f0eb5 | 360 | |
361 | /**** send a mail to X.org administrators ****/ | |
9812efa0 | 362 | if ($globals->register->notif) { |
363 | $mymail = new PlMailer(); | |
364 | $mymail->setSubject("Inscription de $prenom $nom (X$promo)"); | |
1d55fe45 | 365 | $mymail->setFrom('"Webmaster Polytechnique.org" <web@' . $globals->mail->domain . '>'); |
9812efa0 | 366 | $mymail->addTo($globals->register->notif); |
280c6e4d | 367 | $mymail->addHeader('Reply-To', $globals->register->notif); |
a7de4ef7 | 368 | $msg = "$prenom $nom (X$promo) a terminé son inscription avec les données suivantes :\n" |
9812efa0 | 369 | . " - nom : $nom\n" |
370 | . " - prenom : $prenom\n" | |
371 | . " - promo : $promo\n" | |
ecc734a5 | 372 | . " - naissance : $naissance (date connue : $naiss_ini)\n" |
9812efa0 | 373 | . " - forlife : $forlife\n" |
374 | . " - email : $email\n" | |
5f5f0eb5 | 375 | . " - sexe : $femme\n" |
20b71450 | 376 | . " - ip : {$logger->ip} ({$logger->host})\n" |
ebb129a4 | 377 | . ($logger->proxy_ip ? " - proxy : {$logger->proxy_ip} ({$logger->proxy_host})\n" : "") |
defff1aa SJ |
378 | . "\n\n"; |
379 | if (count($market) > 0) { | |
380 | $msg .= "Les marketings suivants avaient été effectués :\n" | |
381 | . implode("\n", $market); | |
382 | } else { | |
841ff7e7 | 383 | $msg .= "$prenom $nom n'a jamais reçu d\'email de marketing."; |
defff1aa | 384 | } |
9812efa0 | 385 | $mymail->setTxtBody($msg); |
eaf30d86 | 386 | $mymail->send(); |
9812efa0 | 387 | } |
f59bc2fb | 388 | |
e654517d | 389 | Marketing::clear($uid); |
f59bc2fb | 390 | |
8b00e0e0 | 391 | pl_redirect('register/success'); |
f59bc2fb | 392 | $page->assign('uid', $uid); |
f59bc2fb | 393 | } |
394 | ||
395 | function handler_success(&$page) | |
396 | { | |
84270653 | 397 | global $globals; |
f59bc2fb | 398 | $page->changeTpl('register/success.tpl'); |
399 | ||
a41bf2f8 | 400 | $_SESSION['sub_state'] = array('step' => 5); |
f59bc2fb | 401 | if (Env::has('response2')) { |
5e2307dc | 402 | $_SESSION['password'] = $password = Post::v('response2'); |
f59bc2fb | 403 | |
08cce2ff | 404 | XDB::execute('UPDATE auth_user_md5 SET password={?} |
f59bc2fb | 405 | WHERE user_id={?}', $password, |
cab08090 | 406 | S::v('uid')); |
f59bc2fb | 407 | |
84270653 VZ |
408 | // If GoogleApps is enabled, and the user did choose to use synchronized passwords, |
409 | // and if the (stupid) user has decided to user /register/success another time, | |
410 | // updates the Google Apps password as well. | |
411 | if ($globals->mailstorage->googleapps_domain) { | |
412 | require_once 'googleapps.inc.php'; | |
413 | $account = new GoogleAppsAccount(S::v('uid'), S::v('forlife')); | |
f5c4bf30 | 414 | if ($account->active() && $account->sync_password) { |
84270653 VZ |
415 | $account->set_password($password); |
416 | } | |
417 | } | |
418 | ||
714bc242 | 419 | $log = S::v('log'); |
732e5855 | 420 | S::logger()->log('passwd', ''); |
f59bc2fb | 421 | |
5e2307dc | 422 | if (Cookie::v('ORGaccess')) { |
f59bc2fb | 423 | require_once('secure_hash.inc.php'); |
424 | setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0); | |
425 | } | |
426 | ||
427 | $page->assign('mdpok', true); | |
428 | } | |
429 | ||
0baf0741 | 430 | $res = XDB::iterRow("SELECT sub, domain |
431 | FROM register_subs | |
432 | WHERE uid = {?} AND type = 'list' | |
433 | ORDER BY domain", | |
434 | S::i('uid')); | |
435 | $current_domain = null; | |
436 | $lists = array(); | |
437 | while (list($sub, $domain) = $res->next()) { | |
438 | if ($current_domain != $domain) { | |
439 | $current_domain = $domain; | |
440 | $client = new MMList(S::v('uid'), S::v('password'), $domain); | |
441 | } | |
442 | list($details, ) = $client->get_members($sub); | |
443 | $lists["$sub@$domain"] = $details; | |
444 | } | |
445 | $page->assign_by_ref('lists', $lists); | |
446 | ||
c99ef281 | 447 | $page->addJsLink('motdepasse.js'); |
f59bc2fb | 448 | } |
97a0a459 FB |
449 | |
450 | function handler_save(&$page) | |
451 | { | |
452 | global $globals; | |
453 | ||
454 | // Finish registration procedure | |
455 | if (Post::v('register_from_ax_question')) { | |
456 | XDB::execute('UPDATE auth_user_quick | |
457 | SET profile_from_ax = 1 | |
458 | WHERE user_id = {?}', | |
459 | S::v('uid')); | |
460 | } | |
461 | if (Post::v('add_to_nl')) { | |
462 | require_once 'newsletter.inc.php'; | |
463 | NewsLetter::subscribe(); | |
464 | } | |
465 | if (Post::v('add_to_ax')) { | |
466 | require_once dirname(__FILE__) . '/axletter/axletter.inc.php'; | |
467 | AXLetter::subscribe(); | |
468 | } | |
469 | if (Post::v('add_to_promo')) { | |
470 | $r = XDB::query('SELECT id FROM groupex.asso WHERE diminutif = {?}', | |
471 | S::v('promo')); | |
472 | $asso_id = $r->fetchOneCell(); | |
473 | XDB::execute('REPLACE INTO groupex.membres (uid,asso_id) | |
474 | VALUES ({?}, {?})', | |
475 | S::v('uid'), $asso_id); | |
476 | $mmlist = new MMList(S::v('uid'), S::v('password')); | |
477 | $mmlist->subscribe("promo".S::v('promo')); | |
478 | } | |
479 | if (Post::v('sub_ml')) { | |
480 | $subs = array_keys(Post::v('sub_ml')); | |
481 | $current_domain = null; | |
482 | foreach ($subs as $list) { | |
483 | list($sub, $domain) = explode('@', $list); | |
484 | if ($domain != $current_domain) { | |
485 | $current_domain = $domain; | |
486 | $client = new MMList(S::v('uid'), S::v('password'), $domain); | |
487 | } | |
488 | $client->subscribe($sub); | |
489 | } | |
490 | } | |
b9fe731c VZ |
491 | if (Post::v('imap')) { |
492 | require_once 'emails.inc.php'; | |
afde0a3a | 493 | $storage = new EmailStorage(S::v('uid'), 'imap'); |
94c6c788 | 494 | $storage->activate(); |
b9fe731c | 495 | } |
97a0a459 FB |
496 | |
497 | pl_redirect('profile/edit'); | |
498 | } | |
f59bc2fb | 499 | } |
500 | ||
a7de4ef7 | 501 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
f59bc2fb | 502 | ?> |