Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
ba6ae046 | 3 | * Copyright (C) 2003-2013 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 | ||
612a2d8a | 27 | public $perso; |
0337d704 | 28 | |
5daf68f6 | 29 | public $m_user; |
612a2d8a | 30 | public $m_email; |
612a2d8a | 31 | public $m_relance; |
e654517d | 32 | public $m_type; |
33 | public $m_data; | |
232577de | 34 | public $m_personal_notes; |
0337d704 | 35 | |
faefdbb7 SJ |
36 | public $rules = "Accepter si l'adresse email parait correcte, et pas absurde (ou si le marketeur est de confiance). Si le |
37 | demandeur marque sa propre adresse email, refuser dans tous les cas. | |
cb04af2c | 38 | Ne pas marqueter au nom de Polytechnique.org plus d'une fois par an. |
7c09ce41 | 39 | Sauf abus flagrant, il n'y a pas de raison de refuser des marketing perso répétés."; |
0337d704 | 40 | // }}} |
41 | // {{{ constructor | |
42 | ||
26ba053e | 43 | public function __construct(User $sender, User $mark, $email, $perso, $type, $data, $personal_notes) |
612a2d8a | 44 | { |
45 | parent::__construct($sender, false, 'marketing'); | |
532c06cf | 46 | $this->m_user = &$mark; |
0337d704 | 47 | $this->m_email = $email; |
48 | $this->perso = $perso; | |
e654517d | 49 | $this->m_type = $type; |
50 | $this->m_data = $data; | |
232577de | 51 | $this->m_personal_notes = $personal_notes; |
0337d704 | 52 | } |
53 | ||
54 | // }}} | |
55 | // {{{ function formu() | |
56 | ||
612a2d8a | 57 | public function formu() |
6e112b58 | 58 | { |
59 | $res = XDB::query('SELECT IF(MAX(m.last)>p.relance, MAX(m.last), p.relance) | |
bd84f1ae FB |
60 | FROM accounts AS a |
61 | LEFT JOIN register_pending AS p ON p.uid = a.uid | |
62 | LEFT JOIN register_marketing AS m ON m.uid = a.uid | |
63 | WHERE a.uid = {?}', | |
5daf68f6 | 64 | $this->m_user->id()); |
6e112b58 | 65 | $this->m_relance = $res->fetchOneCell(); |
66 | return 'include/form.valid.mark.tpl'; | |
67 | } | |
0337d704 | 68 | |
69 | // }}} | |
70 | // {{{ function _mail_subj | |
eaf30d86 | 71 | |
612a2d8a | 72 | protected function _mail_subj() |
0337d704 | 73 | { |
5daf68f6 | 74 | return "[Polytechnique.org] Marketing de {$this->m_user->fullName()} ({$this->m_user->promo()})"; |
0337d704 | 75 | } |
76 | ||
77 | // }}} | |
78 | // {{{ function _mail_body | |
79 | ||
612a2d8a | 80 | protected function _mail_body($isok) |
0337d704 | 81 | { |
a3923909 SJ |
82 | $your1 = ($this->formal ? 'votre' : 'ton'); |
83 | $your2 = ($this->formal ? 'votre' : 'ta'); | |
0337d704 | 84 | if ($isok) { |
faefdbb7 | 85 | return " Un email de marketing vient d'être envoyé " |
a3923909 | 86 | . ($this->perso ? "en $your1 nom" : 'en notre nom') |
5daf68f6 VZ |
87 | . " à {$this->m_user->fullName()} ({$this->m_user->promo()}) " |
88 | . "pour l'encourager à s'inscrire !\n\n" | |
a3923909 | 89 | . "Merci de $your2 participation !\n"; |
0337d704 | 90 | } else { |
5daf68f6 VZ |
91 | return " Nous n'avons pas jugé bon d'envoyer d'email de marketing à " |
92 | . "{$this->m_user->fullName()} ({$this->m_user->promo()})."; | |
0337d704 | 93 | } |
94 | } | |
95 | ||
96 | // }}} | |
97 | // {{{ function commit() | |
98 | ||
612a2d8a | 99 | public function commit() |
0337d704 | 100 | { |
5daf68f6 | 101 | $market = Marketing::get($this->m_user->id(), $this->m_email); |
e654517d | 102 | if ($market == null) { |
103 | return false; | |
104 | } | |
eaf30d86 | 105 | $market->send(); |
0337d704 | 106 | return true; |
107 | } | |
108 | ||
109 | // }}} | |
110 | } | |
111 | ||
a7de4ef7 | 112 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 113 | ?> |