2 /***************************************************************************
3 * Copyright (C) 2003-2009 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
23 class MarkReq
extends Validate
35 public $rules = "Accepter si l'adresse email parait correcte, et pas absurde (ou si le marketeur est de confiance). Si le
36 demandeur marque sa propre adresse email, refuser dans tous les cas.
37 Ne pas marqueter au nom de Polytechnique.org plus d'une fois par an.
38 Sauf abus flagrant, il n'y a pas de raison de refuser des marketing perso répétés.";
42 public function __construct(User
&$sender, User
&$mark, $email, $perso, $type, $data)
44 parent
::__construct($sender, false
, 'marketing');
45 $this->m_user
= &$mark;
46 $this->m_email
= $email;
47 $this->perso
= $perso;
48 $this->m_type
= $type;
49 $this->m_data
= $data;
53 // {{{ function formu()
55 public function formu()
57 $res = XDB
::query('SELECT IF(MAX(m.last)>p.relance, MAX(m.last), p.relance)
58 FROM auth_user_md5 AS u
59 LEFT JOIN register_pending AS p ON p.uid = u.user_id
60 LEFT JOIN register_marketing AS m ON m.uid = u.user_id
63 $this->m_relance
= $res->fetchOneCell();
64 return 'include/form.valid.mark.tpl';
68 // {{{ function _mail_subj
70 protected function _mail_subj()
72 return "[Polytechnique.org] Marketing de {$this->m_user->fullName()} ({$this->m_user->promo()})";
76 // {{{ function _mail_body
78 protected function _mail_body($isok)
81 return " Un email de marketing vient d'être envoyé "
82 . ($this->perso ?
'en ton nom' : 'en notre nom')
83 . " à {$this->m_user->fullName()} ({$this->m_user->promo()}) "
84 . "pour l'encourager à s'inscrire !\n\n"
85 . "Merci de ta participation !\n";
87 return " Nous n'avons pas jugé bon d'envoyer d'email de marketing à "
88 . "{$this->m_user->fullName()} ({$this->m_user->promo()}).";
93 // {{{ function commit()
95 public function commit()
97 $market = Marketing
::get($this->m_user
->id(), $this->m_email
);
98 if ($market == null
) {
108 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: