50% done for #256
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Tue, 11 Jan 2005 12:22:13 +0000 (12:22 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:25 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-282

htdocs/marketing/public.php
include/validations/marketing.inc.php [new file with mode: 0644]
templates/include/form.valid.mark.tpl [new file with mode: 0644]
upgrade/0.9.4/40_requests.sql [new file with mode: 0644]

index 068df30..cb82dc2 100644 (file)
@@ -49,6 +49,9 @@ if (list($nom, $prenom, $promo) = $res->fetchOneRow()) {
                     "INSERT INTO  register_marketing (uid,sender,email,date,last,nb,type,hash)
                           VALUES  ({?}, {?}, {?}, NOW(), 0, 0, {?}, '')",
                     $uid, Session::getInt('uid'), $email, Env::get('origine'));
+            require_once('validations.inc.php');
+            $req = new MarkReq(Session::getInt('uid'), $uid, $email, Env::get('origine')=='user');
+            $req->submit();
         }
     }
 }
diff --git a/include/validations/marketing.inc.php b/include/validations/marketing.inc.php
new file mode 100644 (file)
index 0000000..3c1cfb2
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+/***************************************************************************
+ *  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                *
+ ***************************************************************************/
+
+// {{{ class MarkReq
+
+class MarkReq extends Validate
+{
+    // {{{ properties
+
+    var $perso;
+
+    var $m_id;
+    var $m_email;
+    var $m_nom;
+    var $m_prenom;
+    var $m_promo;
+    
+    // }}}
+    // {{{ constructor
+
+    function MarkReq($sender, $mark_id, $email, $perso = false) {
+        global $globals;
+        $this->Validate($sender, false, 'marketing');
+        $this->m_id    = $mark_id;
+        $this->m_email = $email;
+        $this->perso   = $perso;
+
+        $res = $globals->xdb->query('SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id = {?}', $mark_id);
+        list ($this->m_nom, $this->m_prenom, $this->m_promo) = $res->fetchOneRow(); 
+    }
+
+    // }}}
+    // {{{ function formu()
+
+    function formu()
+    { return 'include/form.valid.mark.tpl'; }
+
+    // }}}
+    // {{{ function _mail_subj
+    
+    function _mail_subj()
+    {
+        return "[Polytechnique.org] Marketing de {$this->m_prenom} {$this->m_nom} ({$this->m_promo})";
+    }
+
+    // }}}
+    // {{{ function _mail_body
+
+    function _mail_body($isok)
+    {
+        if ($isok) {
+            return "  Un mail de marketing vient d'être envoyé "
+                .($this->perso ? 'en ton nom' : 'en notre nom')
+                ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour l'encourrager à s'inscrire !\n\n"
+                ."Merci de ta participation !\n";
+        } else {
+            return "  Nous n'avons pas jugé bon d'envoyer de mail de marketing à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}).";
+        }
+    }
+
+    // }}}
+    // {{{ function commit()
+
+    function commit()
+    {
+        global $globals;
+        $hash = rand_url_id(12);
+        $globals->xdb->execute('UPDATE register_marketing SET nb=1,hash={?} WHERE uid={?} AND email={?}', $hash, $this->m_id, $this->m_email);
+        // TODO HERE SEND A MARKETING MAIL
+        return true;
+    }
+
+    // }}}
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/templates/include/form.valid.mark.tpl b/templates/include/form.valid.mark.tpl
new file mode 100644 (file)
index 0000000..d7c766d
--- /dev/null
@@ -0,0 +1,35 @@
+{***************************************************************************
+ *  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                *
+ ***************************************************************************}
+
+
+<tr class="pair">
+  <td class="titre">Marketing sur</td>
+  <td>{$valid->m_prenom} {$valid->m_nom} ({$valid->m_promo})</td>
+</tr>
+<tr class="pair">
+  <td class="titre">Mail deviné</td>
+  <td>{$valid->m_email}</td>
+</tr>
+<tr class="pair">
+  <td class="titre">Envoi de mail ...</td>
+  <td>{if $valid->perso}perso{else}par poly.org{/if}</td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/upgrade/0.9.4/40_requests.sql b/upgrade/0.9.4/40_requests.sql
new file mode 100644 (file)
index 0000000..2e60686
--- /dev/null
@@ -0,0 +1,2 @@
+alter table requests change column type type char(16);
+