migrate register
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 10 Jul 2006 05:54:15 +0000 (05:54 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 10 Jul 2006 05:54:15 +0000 (05:54 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@413 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/register/end.php [deleted file]
htdocs/register/index.php [deleted file]
htdocs/register/success.php [deleted file]
modules/register.php [new file with mode: 0644]
templates/register/inscription.reussie.tpl [moved from templates/mails/inscription.reussie.tpl with 100% similarity]
templates/register/inscrire.mail.tpl [moved from templates/mails/inscrire.mail.tpl with 98% similarity]
templates/register/step0.tpl
templates/register/step1.tpl
templates/register/step2.tpl
templates/register/step3.tpl
templates/register/success.tpl

diff --git a/htdocs/register/end.php b/htdocs/register/end.php
deleted file mode 100644 (file)
index b7256f8..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-<?
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('xorg.inc.php');
-new_simple_page('register/end.tpl', AUTH_PUBLIC);
-require_once('user.func.inc.php');
-
-if (Env::has('hash')) {
-    $res = $globals->xdb->query(
-            "SELECT  r.uid, r.forlife, r.bestalias, r.mailorg2, r.password, r.email, r.naissance, u.nom, u.prenom, u.promo, u.flags
-               FROM  register_pending AS r
-         INNER JOIN  auth_user_md5    AS u ON r.uid = u.user_id
-              WHERE  hash={?} AND hash!='INSCRIT'", Env::get('hash'));
-}
-
-if ( !Env::has('hash') ||
-        !list($uid, $forlife, $bestalias, $mailorg2, $password, $email, $naissance, $nom, $prenom, $promo, $femme) = $res->fetchOneRow())
-{
-    $page->kill("<p>Cette adresse n'existe pas, ou plus, sur le serveur.</p>
-                 <p>Causes probables :</p>
-                 <ol>
-                   <li>Vérifie que tu visites l'adresse du dernier e-mail reçu s'il y en a eu plusieurs.</li>
-                   <li>Tu as peut-être mal copié l'adresse reçue par mail, vérifie-la à la main.</li>
-                   <li>
-                   Tu as peut-être attendu trop longtemps pour confirmer.  Les
-                   pré-inscriptions sont annulées tous les 30 jours.
-                   </li>
-                   <li>
-                   Tu es en fait déjà inscrit.
-                   </li>
-                </ol>");
-}
-
-
-
-/***********************************************************/
-/****************** REALLY CREATE ACCOUNT ******************/
-/***********************************************************/
-
-$globals->xdb->execute('UPDATE  auth_user_md5
-                           SET  password={?}, perms="user", date=NOW(), naissance={?}, date_ins = NOW()
-                         WHERE  user_id={?}', $password, $naissance, $uid);
-$globals->xdb->execute('REPLACE INTO auth_user_quick (user_id) VALUES ({?})', $uid);
-$globals->xdb->execute('INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, "a_vie")', $uid, $forlife);
-$globals->xdb->execute('INSERT INTO aliases (id,alias,type,flags) VALUES ({?}, {?}, "alias", "bestalias")', $uid, $bestalias);
-if ($mailorg2) {
-    $globals->xdb->execute('INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, "alias")', $uid, $mailorg2);
-}
-
-require_once('emails.inc.php');
-$redirect = new Redirect($uid);
-$redirect->add_email($email);
-
-// on cree un objet logger et on log l'inscription
-$logger = new DiogenesCoreLogger($uid);
-$logger->log('inscription', $email);
-
-$globals->xdb->execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid);
-
-$globals->hook->subscribe($forlife, $uid, $promo, $password);
-
-require_once('xorg.mailer.inc.php');
-$mymail = new XOrgMailer('mails/inscription.reussie.tpl');
-$mymail->assign('forlife', $forlife);
-$mymail->assign('prenom', $prenom);
-$mymail->send();
-
-start_connexion($uid,false);
-$_SESSION['auth'] = AUTH_MDP;
-
-/***********************************************************/
-/************* envoi d'un mail au démarcheur ***************/
-/***********************************************************/
-$res = $globals->xdb->iterRow(
-        "SELECT  DISTINCT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom, s.prenom, 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 AND FIND_IN_SET('bestalias', sa.flags) )
-          WHERE  m.uid = {?}", $uid);
-$globals->xdb->execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid);
-
-while (list($salias, $snom, $sprenom, $sfemme) = $res->next()) {
-    require_once('diogenes/diogenes.hermes.inc.php');
-    $mymail = new HermesMailer();
-    $mymail->setSubject("$prenom $nom s'est inscrit à Polytechnique.org !");
-    $mymail->setFrom('"Marketing Polytechnique.org" <register@polytechnique.org>');
-    $mymail->addTo("\"$sprenom $snom\" <$salias@{$globals->mail->domain}>");
-    $msg = ($sfemme?'Cher':'Chère')." $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"
-         . "Merci de ta participation active à la reconnaissance de ce site !!!\n\n"
-         . "Bien cordialement,\n"
-         . "L'équipe Polytechnique.org";
-    $mymail->setTxtBody(wordwrap($msg, 72));
-    $mymail->send();
-}
-
-$globals->xdb->execute("DELETE FROM register_marketing WHERE uid = {?}", $uid);
-
-redirect('success.php');
-$page->assign('uid', $uid);
-$page->run();
-
-?>
diff --git a/htdocs/register/index.php b/htdocs/register/index.php
deleted file mode 100644 (file)
index 41db686..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('xorg.inc.php');
-
-$sub_state = Session::getMixed('sub_state', Array());
-if (!isset($sub_state['step'])) {
-    $sub_state['step'] = 0;
-}
-if (Get::has('back') && Get::getInt('back') < $sub_state['step']) {
-    $sub_state['step'] = max(0,Get::getInt('back'));
-}
-
-if (Env::has('hash')) {
-    $res = $globals->xdb->query(
-            "SELECT  m.uid, u.promo, u.nom, u.prenom, u.matricule
-               FROM  register_marketing AS m
-         INNER JOIN  auth_user_md5      AS u ON u.user_id = m.uid
-              WHERE  m.hash={?}", Env::get('hash'));
-    if (list($uid, $promo, $nom, $prenom, $ourmat) = $res->fetchOneRow()) {
-        $sub_state['uid']    = $uid;
-        $sub_state['hash']   = Env::get('hash');
-        $sub_state['promo']  = $promo;
-        $sub_state['nom']    = $nom;
-        $sub_state['prenom'] = $prenom;
-        $sub_state['ourmat'] = $ourmat;
-
-        $globals->xdb->execute(
-                "REPLACE INTO  register_mstats (uid,sender,success)
-                       SELECT  m.uid, m.sender, 0
-                         FROM  register_marketing AS m
-                        WHERE  m.hash", $sub_state['hash']);
-    }
-}
-
-switch ($sub_state['step']) {
-    case 0:
-        if (Post::has('step1')) {
-            $sub_state['step'] = 1;
-            if (isset($sub_state['hash'])) {
-                $sub_state['step'] = 3;
-                require_once('register.inc.php');
-                create_aliases($sub_state);
-            }
-        }
-        break;
-
-    case 1:
-        if (Post::has('promo')) {
-            $promo = Post::getInt('promo');
-            if ($promo < 1900 || $promo > date('Y')) {
-                $err = "La promotion saisie est incorrecte !";
-            } else {
-                $sub_state['step']  = 2;
-                $sub_state['promo'] = $promo;
-                if ($promo >= 1996 && $promo<2000) {
-                    $sub_state['mat'] = ($promo % 100)*10 . '???';
-                } elseif($promo >= 2000) {
-                    $sub_state['mat'] = 100 + ($promo % 100) . '???';
-                }
-            }
-        }
-        break;
-
-    case 2:
-        if (count($_POST)) {
-            require_once('register.inc.php');
-            $sub_state['prenom'] = Post::get('prenom');
-            $sub_state['nom']    = Post::get('nom');
-            $sub_state['mat']    = Post::get('mat');
-            $err = check_new_user($sub_state);
-
-            if ($err !== true) { break; }
-            $err = create_aliases($sub_state);
-            if ($err === true) {
-                unset($err);
-                $sub_state['step'] = 3;
-            }
-        }
-        break;
-    
-    case 3:
-        if (count($_POST)) {
-            require_once('register.inc.php');
-            if (!isvalid_email(Post::get('email'))) {
-                $err[] = "Le champ 'E-mail' n'est pas valide.";
-            } elseif (!isvalid_email_redirection(Post::get('email'))) {
-                $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::get('naissance'))) {
-                $err[] = "La 'Date de naissance' n'est pas correcte.";
-            }
-
-            if (isset($err)) {
-                $err = join('<br />', $err);
-            } else {
-                $birth = Env::get('naissance');
-                $sub_state['naissance'] = sprintf("%s-%s-%s", substr($birth,4,4), substr($birth,2,2), substr($birth,0,2));
-                $sub_state['email']     = Post::get('email');
-                $sub_state['step']      = 4;
-                finish_ins($sub_state);
-            }
-        }
-        break;
-}
-
-$_SESSION['sub_state'] = $sub_state;
-new_simple_page('register/step'.intval($sub_state['step']).'.tpl', AUTH_PUBLIC);
-if (isset($err)) { $page->trig($err); }
-$page->run();
-?>
diff --git a/htdocs/register/success.php b/htdocs/register/success.php
deleted file mode 100644 (file)
index ec3f678..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('xorg.inc.php');
-new_simple_page('register/success.tpl', AUTH_MDP);
-
-if (Env::has('response2'))  {
-    $_SESSION['password'] = $password = Post::get('response2');
-
-    $globals->xdb->execute('UPDATE auth_user_md5 SET password={?} WHERE user_id={?}', $password, Session::getInt('uid'));
-
-    $log =& Session::getMixed('log');
-    $log->log('passwd', '');
-
-    if (Cookie::get('ORGaccess')) {
-        require_once('secure_hash.inc.php');
-        setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0);
-    }
-
-    $page->assign('mdpok', true);
-}
-
-$page->addJsLink('javascript/motdepasse.js');
-
-$page->run();
-?>
diff --git a/modules/register.php b/modules/register.php
new file mode 100644 (file)
index 0000000..67f9a26
--- /dev/null
@@ -0,0 +1,300 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+class RegisterModule extends PLModule
+{
+    function handlers()
+    {
+        return array(
+            'register'         => $this->make_hook('register', AUTH_PUB),
+            'register/end'     => $this->make_hook('end',      AUTH_PUB),
+            'register/success' => $this->make_hook('success',  AUTH_MDP),
+        );
+    }
+
+    function handler_register(&$page)
+    {
+        global $globals;
+
+        $sub_state = Session::getMixed('sub_state', Array());
+        if (!isset($sub_state['step'])) {
+            $sub_state['step'] = 0;
+        }
+        if (Get::has('back') && Get::getInt('back') < $sub_state['step']) {
+            $sub_state['step'] = max(0,Get::getInt('back'));
+        }
+
+        if (Env::has('hash')) {
+            $res = $globals->xdb->query(
+                    "SELECT  m.uid, u.promo, u.nom, u.prenom, u.matricule
+                       FROM  register_marketing AS m
+                 INNER JOIN  auth_user_md5      AS u ON u.user_id = m.uid
+                      WHERE  m.hash={?}", Env::get('hash'));
+            if (list($uid, $promo, $nom, $prenom, $ourmat) = $res->fetchOneRow()) {
+                $sub_state['uid']    = $uid;
+                $sub_state['hash']   = Env::get('hash');
+                $sub_state['promo']  = $promo;
+                $sub_state['nom']    = $nom;
+                $sub_state['prenom'] = $prenom;
+                $sub_state['ourmat'] = $ourmat;
+
+                $globals->xdb->execute(
+                        "REPLACE INTO  register_mstats (uid,sender,success)
+                               SELECT  m.uid, m.sender, 0
+                                 FROM  register_marketing AS m
+                                WHERE  m.hash", $sub_state['hash']);
+            }
+        }
+
+        switch ($sub_state['step']) {
+            case 0:
+                if (Post::has('step1')) {
+                    $sub_state['step'] = 1;
+                    if (isset($sub_state['hash'])) {
+                        $sub_state['step'] = 3;
+                        require_once('register.inc.php');
+                        create_aliases($sub_state);
+                    }
+                }
+                break;
+
+            case 1:
+                if (Post::has('promo')) {
+                    $promo = Post::getInt('promo');
+                    if ($promo < 1900 || $promo > date('Y')) {
+                        $err = "La promotion saisie est incorrecte !";
+                    } else {
+                        $sub_state['step']  = 2;
+                        $sub_state['promo'] = $promo;
+                        if ($promo >= 1996 && $promo<2000) {
+                            $sub_state['mat'] = ($promo % 100)*10 . '???';
+                        } elseif($promo >= 2000) {
+                            $sub_state['mat'] = 100 + ($promo % 100) . '???';
+                        }
+                    }
+                }
+                break;
+
+            case 2:
+                if (count($_POST)) {
+                    require_once('register.inc.php');
+                    $sub_state['prenom'] = Post::get('prenom');
+                    $sub_state['nom']    = Post::get('nom');
+                    $sub_state['mat']    = Post::get('mat');
+                    $err = check_new_user($sub_state);
+
+                    if ($err !== true) { break; }
+                    $err = create_aliases($sub_state);
+                    if ($err === true) {
+                        unset($err);
+                        $sub_state['step'] = 3;
+                    }
+                }
+                break;
+
+            case 3:
+                if (count($_POST)) {
+                    require_once('register.inc.php');
+                    if (!isvalid_email(Post::get('email'))) {
+                        $err[] = "Le champ 'E-mail' n'est pas valide.";
+                    } elseif (!isvalid_email_redirection(Post::get('email'))) {
+                        $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::get('naissance')))
+                    {
+                        $err[] = "La 'Date de naissance' n'est pas correcte.";
+                    }
+
+                    if (isset($err)) {
+                        $err = join('<br />', $err);
+                    } else {
+                        $birth = Env::get('naissance');
+                        $sub_state['naissance'] = sprintf("%s-%s-%s",
+                                                          substr($birth,4,4),
+                                                          substr($birth,2,2),
+                                                          substr($birth,0,2));
+                        $sub_state['email']     = Post::get('email');
+                        $sub_state['step']      = 4;
+                        finish_ins($sub_state);
+                    }
+                }
+                break;
+        }
+
+        $_SESSION['sub_state'] = $sub_state;
+        $page->changeTpl('register/step'.intval($sub_state['step']).'.tpl');
+        if (isset($err)) {
+            $page->trig($err);
+        }
+
+        return PL_OK;
+    }
+
+    function handler_end(&$page, $hash = null)
+    {
+        global $globals;
+
+        $page->changeTpl('register/end.tpl');
+
+        require_once('user.func.inc.php');
+
+        if ($hash) {
+            $res = $globals->xdb->query(
+                    "SELECT  r.uid, r.forlife, r.bestalias, r.mailorg2,
+                             r.password, r.email, r.naissance, u.nom, u.prenom,
+                             u.promo, u.flags
+                       FROM  register_pending AS r
+                 INNER JOIN  auth_user_md5    AS u ON r.uid = u.user_id
+                      WHERE  hash={?} AND hash!='INSCRIT'", Env::get('hash'));
+        }
+
+        if (!$hash || !list($uid, $forlife, $bestalias, $mailorg2, $password, $email,
+                            $naissance, $nom, $prenom, $promo, $femme) = $res->fetchOneRow())
+        {
+            $page->kill("<p>Cette adresse n'existe pas, ou plus, sur le serveur.</p>
+                         <p>Causes probables :</p>
+                         <ol>
+                           <li>Vérifie que tu visites l'adresse du dernier
+                               e-mail reçu s'il y en a eu plusieurs.</li>
+                           <li>Tu as peut-être mal copié l'adresse reçue par
+                               mail, vérifie-la à la main.</li>
+                           <li>Tu as peut-être attendu trop longtemps pour
+                               confirmer.  Les pré-inscriptions sont annulées
+                               tous les 30 jours.</li>
+                           <li>Tu es en fait déjà inscrit.</li>
+                        </ol>");
+        }
+
+
+
+        /***********************************************************/
+        /****************** REALLY CREATE ACCOUNT ******************/
+        /***********************************************************/
+
+        $globals->xdb->execute('UPDATE  auth_user_md5
+                                   SET  password={?}, perms="user",
+                                        date=NOW(), naissance={?}, date_ins = NOW()
+                                 WHERE  user_id={?}', $password, $naissance, $uid);
+        $globals->xdb->execute('REPLACE INTO auth_user_quick (user_id) VALUES ({?})', $uid);
+        $globals->xdb->execute('INSERT INTO aliases (id,alias,type)
+                                     VALUES ({?}, {?}, "a_vie")', $uid,
+                                     $forlife);
+        $globals->xdb->execute('INSERT INTO aliases (id,alias,type,flags)
+                                     VALUES ({?}, {?}, "alias", "bestalias")',
+                                     $uid, $bestalias);
+        if ($mailorg2) {
+            $globals->xdb->execute('INSERT INTO aliases (id,alias,type)
+                                         VALUES ({?}, {?}, "alias")', $uid,
+                                         $mailorg2);
+        }
+
+        require_once('emails.inc.php');
+        $redirect = new Redirect($uid);
+        $redirect->add_email($email);
+
+        // on cree un objet logger et on log l'inscription
+        $logger = new DiogenesCoreLogger($uid);
+        $logger->log('inscription', $email);
+
+        $globals->xdb->execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid);
+
+        $globals->hook->subscribe($forlife, $uid, $promo, $password);
+
+        require_once('xorg.mailer.inc.php');
+        $mymail = new XOrgMailer('register/inscription.reussie.tpl');
+        $mymail->assign('forlife', $forlife);
+        $mymail->assign('prenom', $prenom);
+        $mymail->send();
+
+        start_connexion($uid,false);
+        $_SESSION['auth'] = AUTH_MDP;
+
+        /***********************************************************/
+        /************* envoi d'un mail au démarcheur ***************/
+        /***********************************************************/
+        $res = $globals->xdb->iterRow(
+                "SELECT  DISTINCT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom,
+                         s.prenom, 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
+                                                       AND FIND_IN_SET('bestalias', sa.flags) )
+                  WHERE  m.uid = {?}", $uid);
+        $globals->xdb->execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid);
+
+        while (list($salias, $snom, $sprenom, $sfemme) = $res->next()) {
+            require_once('diogenes/diogenes.hermes.inc.php');
+            $mymail = new HermesMailer();
+            $mymail->setSubject("$prenom $nom s'est inscrit à Polytechnique.org !");
+            $mymail->setFrom('"Marketing Polytechnique.org" <register@polytechnique.org>');
+            $mymail->addTo("\"$sprenom $snom\" <$salias@{$globals->mail->domain}>");
+            $msg = ($sfemme?'Cher':'Chère')." $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"
+                 . "Merci de ta participation active à la reconnaissance de ce site !!!\n\n"
+                 . "Bien cordialement,\n"
+                 . "L'équipe Polytechnique.org";
+            $mymail->setTxtBody(wordwrap($msg, 72));
+            $mymail->send();
+        }
+
+        $globals->xdb->execute("DELETE FROM register_marketing WHERE uid = {?}", $uid);
+
+        redirect('success.php');
+        $page->assign('uid', $uid);
+
+        return PL_OK;
+    }
+
+    function handler_success(&$page)
+    {
+        global $globals;
+
+        $page->changeTpl('register/success.tpl');
+
+        if (Env::has('response2'))  {
+            $_SESSION['password'] = $password = Post::get('response2');
+
+            $globals->xdb->execute('UPDATE auth_user_md5 SET password={?}
+                                     WHERE user_id={?}', $password,
+                                   Session::getInt('uid'));
+
+            $log =& Session::getMixed('log');
+            $log->log('passwd', '');
+
+            if (Cookie::get('ORGaccess')) {
+                require_once('secure_hash.inc.php');
+                setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0);
+            }
+
+            $page->assign('mdpok', true);
+        }
+
+        $page->addJsLink('javascript/motdepasse.js');
+
+        return PL_OK;
+    }
+}
+
+?>
similarity index 98%
rename from templates/mails/inscrire.mail.tpl
rename to templates/register/inscrire.mail.tpl
index fc4c20e..43edea5 100644 (file)
@@ -35,7 +35,7 @@ mot de passe : {$pass}
 
 Rends-toi sur la page web suivante afin d'activer ta pré-inscription, et de changer ton mot de passe en quelque chose de plus facile à mémoriser :
 
-{$baseurl}/register/end.php?hash={$hash}
+{$baseurl}/register/end/{$hash}
 
 Si en cliquant dessus tu n'y arrives pas, copie intégralement l'adresse dans la barre de ton navigateur.
 
index aa2b9d4..6cd8875 100644 (file)
@@ -38,7 +38,7 @@ L'enregistrement se d
 
 {include file="docs/charte.tpl"}
 
-<form action="?" method="post">
+<form action="{rel}/register" method="post">
   <div class="center">
     <input type="submit" value="J'accepte ces conditions" name="step1" />
   </div>
index 7be5842..16b8d02 100644 (file)
@@ -22,7 +22,7 @@
 
 <h1>Identification</h1>
 
-<form action="?" method="post">
+<form action="{rel}/register" method="post">
   <p>
     Avant toute chose, il te faut nous donner ta promotion :
   </p>
index acec7b5..0fb394b 100644 (file)
 <h1>Identification</h1>
 
 <p>
-<a href="?back=1">retour</a>
+<a href="{rel}/register?back=1">retour</a>
 </p>
 
-<form action="?" method="post">
+<form action="{rel}/register" method="post">
   <table class="bicol" summary="Identification" cellpadding="3">
     {if $smarty.session.sub_state.promo >= 1996}
     <tr>
index e94c065..73a217a 100644 (file)
@@ -25,7 +25,7 @@
 
 <h1>Formulaire de pré-inscription</h1>
 
-<form action="?" method="post">
+<form action="{rel}/register" method="post">
   {if $smarty.session.sub_state.mailorg2}
   <p>
   Tu n'as pour le moment aucun homonyme dans notre base de données, nous allons
index 13d1278..9418a5b 100644 (file)
@@ -46,7 +46,7 @@ ton mot de passe a bien 
 Tu as recu un mot de passe par défaut, si tu souhaites en changer, tu peux le faire ici :
 </p>
 
-<form action="{$smarty.server.PHP_REQUEST}" method="post" id="changepass">
+<form action="{rel}/register/success" method="post" id="changepass">
   <table class="tinybicol" cellpadding="3" cellspacing="0">
     <tr>
       <th colspan="2">
@@ -77,7 +77,7 @@ Tu as recu un mot de passe par d
   </table>
 </form>
 
-<form action="{$smarty.server.PHP_REQUEST}" method="post" id="changepass2">
+<form action="{rel}/register/success" method="post" id="changepass2">
 <div><input type="hidden" name="response2"  value="" /></div>
 </form>