plug new marketing into register phase
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 10 Jan 2005 16:54:12 +0000 (16:54 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:22 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-266

configs/mails.conf
htdocs/register/end.php
htdocs/register/index.php
templates/mails/marketing.thanks.tpl [deleted file]

index 50f3e7b..2555c0b 100644 (file)
@@ -1,9 +1,6 @@
 [marketing_relance]
 from=Pre-Inscription <register@polytechnique.org>
 
-[marketing_thanks]
-from="Marketing Polytechnique.org" <register@polytechnique.org>
-
 [inscrire]
 from="Pre-Inscription" <register@polytechnique.org>
 
index 0465eae..5d9869a 100644 (file)
@@ -90,21 +90,30 @@ start_connexion($uid,false);
 /************* envoi d'un mail au démarcheur ***************/
 /***********************************************************/
 $res = $globals->xdb->iterRow(
-        "SELECT  DISTINCT a.alias,e.date_envoi
-           FROM  envoidirect AS e
-     INNER JOIN  aliases     AS a ON ( a.id = e.sender AND a.type='a_vie' )
-          WHERE  e.matricule = {?}", $matricule);
-while (list($sender_usern, $sender_date) = $res->next()) {
-    $mymail = new XOrgMailer('marketing.thanks.tpl');
-    $mymail->assign('to',     $sender_usern);
-    $mymail->assign('prenom', $prenom);
-    $mymail->assign('nom',    $nom);
-    $mymail->assign('promo',  $promo);
+        "SELECT  DISTINCT sa.alias, sa.nom, sa.prenom
+           FROM  register_marketing AS m
+     INNER JOIN  auth_user_md5      AS s  ON ( m.sender = s.user_id )
+     INNER JOIN  aliases            AS sa ON ( a.id = m.sender AND FIND_IN_SET('bestalias', a.flags) )
+          WHERE  m.uid = {?}", $uid);
+
+while (list($salias, $snom, $sprenom) = $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\" <$alias@{$globals->mail->domain}");
+    $msg = "Cher $sprenom,\n\n"
+         . "Nous t'écrivons pour t'informer que {$prenom} {$nom} (X{$promo}), "
+         . "que tu avais incité à 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();
 }
 
-// s'il est dans la table envoidirect, on le marque comme inscrit
-$globals->xdb->execute('UPDATE envoidirect SET date_succes=NOW() WHERE matricule = {?}', $matricule);
+$globals->xdb->execute("DELETE FROM register_mstats WHERE uid = {?}", $uid);
 
 $page->assign('forlife',$forlife);
 $page->run();
index a97be21..e84f147 100644 (file)
@@ -29,9 +29,36 @@ 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.prenom, u.nom, 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['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, NOW()
+                         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 (Post::has('step1')) {
+            $sub_state['step'] = 1;
+            if (isset($sub_date['hash'])) {
+                $sub_state['step'] = 3;
+                create_aliases($sub_state);
+            }
+        }
         break;
 
     case 1:
diff --git a/templates/mails/marketing.thanks.tpl b/templates/mails/marketing.thanks.tpl
deleted file mode 100644 (file)
index e6a5a24..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-{***************************************************************************
- *  Copyright (C) 2003-2004 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                *
- ***************************************************************************}
-
-{config_load file="mails.conf" section="marketing_thanks"}
-{from full=#from#}
-{to addr="$to"}
-{subject text="$prenom $nom s'est inscrit à Polytechnique.org !"}
-Bonjour,
-
-Nous t'écrivons juste pour t'informer que {$prenom} {$nom} (X{$promo}), que tu avais incité à s'inscrire à Polytechnique.org, vient à l'instant de terminer son inscription !! :o)
-
-Merci de ta participation active à la reconnaissance de ce site !!!
-
-Bien cordialement,
-L'équipe Polytechnique.org
-"Le portail des élèves & anciens élèves de l'Ecole polytechnique"
-{* vim:set et sw=2 sts=2 sws=2: *}