0337d704 |
1 | <?php |
2 | /*************************************************************************** |
5ddeb07c |
3 | * Copyright (C) 2003-2007 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; |
9ac41f81 |
34 | var $m_relance; |
0337d704 |
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) { |
0337d704 |
44 | $this->Validate($sender, false, 'marketing'); |
45 | $this->m_id = $mark_id; |
46 | $this->m_email = $email; |
47 | $this->perso = $perso; |
48 | |
9ac41f81 |
49 | $res = XDB::query('SELECT u.nom, u.prenom, u.promo, |
9ac41f81 |
50 | FROM auth_user_md5 AS u |
9ac41f81 |
51 | WHERE user_id = {?} |
52 | GROUP BY u.user_id', $mark_id); |
6e112b58 |
53 | list ($this->m_nom, $this->m_prenom, $this->m_promo) = $res->fetchOneRow(); |
0337d704 |
54 | } |
55 | |
56 | // }}} |
57 | // {{{ function formu() |
58 | |
59 | function formu() |
6e112b58 |
60 | { |
61 | $res = XDB::query('SELECT IF(MAX(m.last)>p.relance, MAX(m.last), p.relance) |
62 | FROM auth_user_md5 AS u |
63 | LEFT JOIN register_pending AS p ON p.uid = u.user_id |
64 | LEFT JOIN register_marketing AS m ON m.uid = u.user_id |
65 | WHERE user_id = {?}', |
66 | $this->m_id); |
67 | $this->m_relance = $res->fetchOneCell(); |
68 | return 'include/form.valid.mark.tpl'; |
69 | } |
0337d704 |
70 | |
71 | // }}} |
72 | // {{{ function _mail_subj |
73 | |
74 | function _mail_subj() |
75 | { |
76 | return "[Polytechnique.org] Marketing de {$this->m_prenom} {$this->m_nom} ({$this->m_promo})"; |
77 | } |
78 | |
79 | // }}} |
80 | // {{{ function _mail_body |
81 | |
82 | function _mail_body($isok) |
83 | { |
84 | if ($isok) { |
85 | return " Un mail de marketing vient d'être envoyé " |
86 | .($this->perso ? 'en ton nom' : 'en notre nom') |
87 | ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour l'encourager à s'inscrire !\n\n" |
88 | ."Merci de ta participation !\n"; |
89 | } else { |
90 | return " Nous n'avons pas jugé bon d'envoyer de mail de marketing à {$this->m_prenom} {$this->m_nom} ({$this->m_promo})."; |
91 | } |
92 | } |
93 | |
94 | // }}} |
95 | // {{{ function commit() |
96 | |
97 | function commit() |
98 | { |
0337d704 |
99 | require_once('marketing.inc.php'); |
100 | mark_send_mail($this->m_id, $this->m_email,(!$this->perso)?"staff":"user"); |
101 | return true; |
102 | } |
103 | |
104 | // }}} |
105 | } |
106 | |
0337d704 |
107 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
108 | ?> |