X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fmarketing.inc.php;h=69156063bd3732be45e79df3c2ebb0cd694006c7;hb=85b2b2257110a8c77d70624f0fa9bba402d99e5f;hp=91b61b29fed9732c442cc35d4c068570029a2b26;hpb=9ac41f819c57086035f2ba3f8bc738d01cb8ff28;p=platal.git diff --git a/include/validations/marketing.inc.php b/include/validations/marketing.inc.php index 91b61b2..6915606 100644 --- a/include/validations/marketing.inc.php +++ b/include/validations/marketing.inc.php @@ -1,6 +1,6 @@ Validate($sender, false, 'marketing'); - $this->m_id = $mark_id; + public function __construct(User $sender, User $mark, $email, $perso, $type, $data, $personal_notes) + { + parent::__construct($sender, false, 'marketing'); + $this->m_user = &$mark; $this->m_email = $email; $this->perso = $perso; - - $res = XDB::query('SELECT u.nom, u.prenom, u.promo, - 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 = {?} - GROUP BY u.user_id', $mark_id); - list ($this->m_nom, $this->m_prenom, $this->m_promo, $this->m_relance) = $res->fetchOneRow(); + $this->m_type = $type; + $this->m_data = $data; + $this->m_personal_notes = $personal_notes; } // }}} // {{{ 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 accounts AS a + LEFT JOIN register_pending AS p ON p.uid = a.uid + LEFT JOIN register_marketing AS m ON m.uid = a.uid + WHERE a.uid = {?}', + $this->m_user->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})"; + return "[Polytechnique.org] Marketing de {$this->m_user->fullName()} ({$this->m_user->promo()})"; } // }}} // {{{ function _mail_body - function _mail_body($isok) + protected function _mail_body($isok) { + $your1 = ($this->formal ? 'votre' : 'ton'); + $your2 = ($this->formal ? 'votre' : 'ta'); if ($isok) { - 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" - ."Merci de ta participation !\n"; + return " Un email de marketing vient d'être envoyé " + . ($this->perso ? "en $your1 nom" : 'en notre nom') + . " à {$this->m_user->fullName()} ({$this->m_user->promo()}) " + . "pour l'encourager à s'inscrire !\n\n" + . "Merci de $your2 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 d'email de marketing à " + . "{$this->m_user->fullName()} ({$this->m_user->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_user->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: ?>