X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fregister.php;h=002b7ef394d8387cfe48bfb04585152504582669;hb=1d10d3fd659fa8eb7c663d6bb599bc8bbc0feeb3;hp=b67c5bc9d47189fa05bb5c66e58346f54dd7021b;hpb=5e2307dcebc38ebb0ffe469967a377eb3baed571;p=platal.git diff --git a/modules/register.php b/modules/register.php index b67c5bc..002b7ef 100644 --- a/modules/register.php +++ b/modules/register.php @@ -70,6 +70,8 @@ class RegisterModule extends PLModule switch ($sub_state['step']) { case 0: + require_once('wiki.inc.php'); + wiki_require_page('Reference.Charte'); if (Post::has('step1')) { $sub_state['step'] = 1; if (isset($sub_state['hash'])) { @@ -83,8 +85,13 @@ class RegisterModule extends PLModule case 1: if (Post::has('promo')) { $promo = Post::i('promo'); - if ($promo < 1900 || $promo > date('Y')) { - $err = "La promotion saisie est incorrecte !"; + $res = XDB::query("SELECT COUNT(*) + FROM auth_user_md5 + WHERE perms='pending' AND deces = '0000-00-00' + AND promo = {?}", + $promo); + if (!$res->fetchOneCell()) { + $err = "La promotion saisie est incorrecte ou tous les camardes de cette promo sont inscrits !"; } else { $sub_state['step'] = 2; $sub_state['promo'] = $promo; @@ -115,6 +122,7 @@ class RegisterModule extends PLModule break; case 3: + $alert = null; if (count($_POST)) { require_once('register.inc.php'); if (!isvalid_email(Post::v('email'))) { @@ -123,16 +131,41 @@ class RegisterModule extends PLModule $err[] = $sub_state['forlife']." doit renvoyer vers un email existant ". "valide, en particulier, il ne peut pas être renvoyé vers lui-même."; } - if (!preg_match('/^[0-3][0-9][01][0-9][12][90][0-9][0-9]$/', - Post::v('naissance'))) - { + $birth = Env::v('naissance'); + if (!preg_match('/^[0-3][0-9][01][0-9][12][90][0-9][0-9]$/', $birth)) { $err[] = "La 'Date de naissance' n'est pas correcte."; + } else { + $year = (int)substr($birth, 4, 4); + $promo = (int)$sub_state['promo']; + if ($year > $promo - 15 || $year < $promo - 30) { + $err[] = "La 'Date de naissance' n'est pas correcte."; + $alert = "Date de naissance proposée $birth\n\n"; + } + } + + // Check if the given email is known as dangerous + $res = Xdb::iterRow("SELECT w.state, w.description, a.alias + FROM emails AS e + INNER JOIN emails_watch AS w ON (e.email = w.email AND w.state != 'safe') + INNER JOIN aliases AS a ON (e.uid = a.id AND a.type = 'a_vie') + WHERE e.email = {?} + ORDER BY a.alias", Post::v('email')); + $aliases = array(); + while(list($gstate, $gdescription, $alias) = $res->next()) { + $state = $gstate; + $description = $gdescription; + $aliases[] = $alias; + } + if (count($aliases) != 0) { + $alert .= "Email proposé : " . Post::v('email') . "\n" + . "Ce mails est connu avec l'état $state :\n" + . $description . "\n" + . "Pour les alias :\n* " . join("\n* ", $aliases) . "\n\n"; } if (isset($err)) { $err = join('
', $err); } else { - $birth = Env::v('naissance'); $sub_state['naissance'] = sprintf("%s-%s-%s", substr($birth,4,4), substr($birth,2,2), @@ -141,12 +174,15 @@ class RegisterModule extends PLModule $sub_state['step'] = 4; finish_ins($sub_state); } + if (!is_null($alert)) { + send_alert_mail($sub_state, $alert); + } } break; } $_SESSION['sub_state'] = $sub_state; - $page->changeTpl('register/step'.intval($sub_state['step']).'.tpl', SIMPLE); + $page->changeTpl('register/step'.intval($sub_state['step']).'.tpl'); if (isset($err)) { $page->trig($err); } @@ -162,7 +198,7 @@ class RegisterModule extends PLModule global $globals; $page->changeTpl('register/end.tpl'); - + $_SESSION['sub_state'] = array('step' => 5); require_once('user.func.inc.php'); if ($hash) { @@ -220,12 +256,13 @@ class RegisterModule extends PLModule $redirect->add_email($email); // on cree un objet logger et on log l'inscription - $logger = new DiogenesCoreLogger($uid); + $logger = new CoreLogger($uid); $logger->log('inscription', $email); XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid); - $globals->hook->subscribe($forlife, $uid, $promo, $password); + global $platal; + $platal->on_subscribe($forlife, $uid, $promo, $password); require_once('xorg.mailer.inc.php'); $mymail = new XOrgMailer('register/inscription.reussie.tpl'); @@ -241,7 +278,7 @@ class RegisterModule extends PLModule /***********************************************************/ $res = XDB::iterRow( "SELECT DISTINCT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom, - s.prenom, s.flags AS femme + s.prenom, FIND_IN_SET('femme', s.flags) AS femme 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 @@ -255,7 +292,7 @@ class RegisterModule extends PLModule $mymail->setSubject("$prenom $nom s'est inscrit à Polytechnique.org !"); $mymail->setFrom('"Marketing Polytechnique.org" '); $mymail->addTo("\"$sprenom $snom\" <$salias@{$globals->mail->domain}>"); - $msg = ($sfemme?'Cher':'Chère')." $sprenom,\n\n" + $msg = ($sfemme?'Chère':'Cher')." $sprenom,\n\n" . "Nous t'écrivons pour t'informer que {$prenom} {$nom} (X{$promo}), " . "que tu avais incité".($femme?'e':'')." à s'inscrire à Polytechnique.org, " . "vient à l'instant de terminer son inscription.\n\n" @@ -276,6 +313,7 @@ class RegisterModule extends PLModule { $page->changeTpl('register/success.tpl'); + $_SESSION['sub_state'] = array('step' => 5); if (Env::has('response2')) { $_SESSION['password'] = $password = Post::v('response2'); @@ -294,7 +332,7 @@ class RegisterModule extends PLModule $page->assign('mdpok', true); } - $page->addJsLink('javascript/motdepasse.js'); + $page->addJsLink('motdepasse.js'); } }