X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fmarketing.inc.php;h=c8fbb9ac20cb1c347d1be54356a6397a70ce3c2f;hb=7c09ce41dca26e3016b843c458092e0d278604a0;hp=c9692f255f8dfd39206d9e8abd52534d019caaf9;hpb=d71befc4b51f0c71cd8358bb0870d9658b21d346;p=platal.git diff --git a/include/validations/marketing.inc.php b/include/validations/marketing.inc.php index c9692f2..c8fbb9a 100644 --- a/include/validations/marketing.inc.php +++ b/include/validations/marketing.inc.php @@ -1,6 +1,6 @@ Validate($sender, false, 'marketing'); + public function __construct($sender, $mark_id, $email, $perso, $type, $data) + { + parent::__construct($sender, false, 'marketing'); $this->m_id = $mark_id; $this->m_email = $email; $this->perso = $perso; - - $res = XDB::query('SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id = {?}', $mark_id); - list ($this->m_nom, $this->m_prenom, $this->m_promo) = $res->fetchOneRow(); + $this->m_type = $type; + $this->m_data = $data; + + $res = XDB::query('SELECT u.nom, u.prenom, u.promo + FROM auth_user_md5 AS u + WHERE user_id = {?} + GROUP BY u.user_id', $mark_id); + list ($this->m_nom, $this->m_prenom, $this->m_promo) = $res->fetchOneRow(); } // }}} // {{{ function formu() - function formu() - { return 'include/form.valid.mark.tpl'; } + public function formu() + { + $res = XDB::query('SELECT IF(MAX(m.last)>p.relance, MAX(m.last), p.relance) + FROM auth_user_md5 AS u + LEFT JOIN register_pending AS p ON p.uid = u.user_id + LEFT JOIN register_marketing AS m ON m.uid = u.user_id + WHERE user_id = {?}', + $this->m_id); + $this->m_relance = $res->fetchOneCell(); + return 'include/form.valid.mark.tpl'; + } // }}} // {{{ function _mail_subj - - function _mail_subj() + + protected function _mail_subj() { return "[Polytechnique.org] Marketing de {$this->m_prenom} {$this->m_nom} ({$this->m_promo})"; } @@ -66,30 +84,33 @@ class MarkReq extends Validate // }}} // {{{ function _mail_body - function _mail_body($isok) + protected function _mail_body($isok) { if ($isok) { - return " Un mail de marketing vient d'être envoyé " + return " Un mail de marketing vient d'être envoyé " .($this->perso ? 'en ton nom' : 'en notre nom') - ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour l'encourager à s'inscrire !\n\n" + ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour l'encourager à s'inscrire !\n\n" ."Merci de ta participation !\n"; } else { - return " Nous n'avons pas jugé bon d'envoyer de mail de marketing à {$this->m_prenom} {$this->m_nom} ({$this->m_promo})."; + return " Nous n'avons pas jugé bon d'envoyer de mail de marketing à {$this->m_prenom} {$this->m_nom} ({$this->m_promo})."; } } // }}} // {{{ function commit() - function commit() + public function commit() { - require_once('marketing.inc.php'); - mark_send_mail($this->m_id, $this->m_email,(!$this->perso)?"staff":"user"); + $market = Marketing::get($this->m_id, $this->m_email); + if ($market == null) { + return false; + } + $market->send(); return true; } // }}} } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>