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