first reimport from platal
[platal.git] / include / validations / marketing.inc.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
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 MarkReq
23
24 class MarkReq extends Validate
25 {
26 // {{{ properties
27
28 var $perso;
29
30 var $m_id;
31 var $m_email;
32 var $m_nom;
33 var $m_prenom;
34 var $m_promo;
35
36 var $rules = "Accepter si l'adresse mail parait correcte, et pas absurde (ou si le marketeur est de confiance). Si le
37 demandeur marque sa propre adresse mail, refuser dans tous les cas.
38 Ne pas marqueter au nom de Polytechnique.org plus d'une
39 fois par an.";
40 // }}}
41 // {{{ constructor
42
43 function MarkReq($sender, $mark_id, $email, $perso = false) {
44 global $globals;
45 $this->Validate($sender, false, 'marketing');
46 $this->m_id = $mark_id;
47 $this->m_email = $email;
48 $this->perso = $perso;
49
50 $res = $globals->xdb->query('SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id = {?}', $mark_id);
51 list ($this->m_nom, $this->m_prenom, $this->m_promo) = $res->fetchOneRow();
52 }
53
54 // }}}
55 // {{{ function formu()
56
57 function formu()
58 { return 'include/form.valid.mark.tpl'; }
59
60 // }}}
61 // {{{ function _mail_subj
62
63 function _mail_subj()
64 {
65 return "[Polytechnique.org] Marketing de {$this->m_prenom} {$this->m_nom} ({$this->m_promo})";
66 }
67
68 // }}}
69 // {{{ function _mail_body
70
71 function _mail_body($isok)
72 {
73 if ($isok) {
74 return " Un mail de marketing vient d'être envoyé "
75 .($this->perso ? 'en ton nom' : 'en notre nom')
76 ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour l'encourager à s'inscrire !\n\n"
77 ."Merci de ta participation !\n";
78 } else {
79 return " Nous n'avons pas jugé bon d'envoyer de mail de marketing à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}).";
80 }
81 }
82
83 // }}}
84 // {{{ function commit()
85
86 function commit()
87 {
88 global $globals;
89 require_once('marketing.inc.php');
90 mark_send_mail($this->m_id, $this->m_email,(!$this->perso)?"staff":"user");
91 return true;
92 }
93
94 // }}}
95 }
96
97 // }}}
98
99 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
100 ?>