X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fhomonymes.inc.php;h=33e8da147737a0d9c6b281214a59f43229f54a09;hb=85b2b2257110a8c77d70624f0fa9bba402d99e5f;hp=684ef29db05e520054f559542231b81e3c02a3a3;hpb=d645ceb701b0e8aa1de2e5271bed35e56ef169f1;p=platal.git diff --git a/include/validations/homonymes.inc.php b/include/validations/homonymes.inc.php index 684ef29..33e8da1 100644 --- a/include/validations/homonymes.inc.php +++ b/include/validations/homonymes.inc.php @@ -25,25 +25,22 @@ class HomonymeReq extends Validate { // {{{ properties - public $loginbis; - - public $warning = true; - + public $email; public $homonymes_hruid; - + public $warning = true; public $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus … manuellement."; // }}} // {{{ constructor - public function __construct(User &$_user, $_loginbis, $_homonymes_hruid, $warning=true) + public function __construct(User $_user, $_email, $_homonymes_hruid, $warning = true) { $this->warning = $warning; parent::__construct($_user, true, $this->title()); $this->refuse = false; - $this->loginbis = $_loginbis; + $this->email = $_email; $this->homonymes_hruid = $_homonymes_hruid; } @@ -68,10 +65,9 @@ class HomonymeReq extends Validate protected function _mail_subj() { - global $globals; return "[Polytechnique.org/Support] " . ($this->warning ? "Dans une semaine : suppression de l'alias " : "Mise en place du robot") - . " $loginbis@" . $globals->mail->domain; + . " $email@" . $this->user->mainEmailDomain(); } // }}} @@ -79,16 +75,15 @@ class HomonymeReq extends Validate protected function _mail_body($isok) { - global $globals; return " Comme nous t'en avons informé par email il y a quelques temps, pour respecter nos engagements en terme d'adresses email devinables, -tu te verras bientôt retirer l'alias ".$this->loginbis."@".$globals->mail->domain." pour +tu te verras bientôt retirer l'alias " . $this->email . "@" . $this->user->mainEmailDomain() . " pour ne garder que " . $this->user->forlifeEmail() . ". -Toute personne qui écrira à ".$this->loginbis."@".$globals->mail->domain." recevra la -réponse d'un robot qui l'informera que ".$this->loginbis."@".$globals->mail->domain." +Toute personne qui écrira à " . $this->email . "@" . $this->user->mainEmailDomain() . " recevra la +réponse d'un robot qui l'informera que " . $this->email . "@" . $this->user->mainEmailDomain() . " est ambigu pour des raisons d'homonymie et signalera ton email exact."; } @@ -97,36 +92,25 @@ est ambigu pour des raisons d'homonymie et signalera ton email exact."; protected function sendmail($isok) { - if (!$isok) return false; - global $globals; - $mailer = new PlMailer; - $cc = "support+homonyme@" . $globals->mail->domain; - $from = "\"Support Polytechnique.org\" <$cc>"; - $mailer->setSubject($this->_mail_subj()); - $mailer->setFrom($from); - $mailer->addTo("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>"); - $mailer->addCc($cc); - - $body = $this->user->displayName() . ",\n\n" - . $this->_mail_body($isok) - . (Env::has('comm') ? "\n\n".Env::v('comm') : '') - . "\n\nCordialement,\n\n-- \nL'équipe de Polytechnique.org\n"; - - $mailer->setTxtBody(wordwrap($body)); - $mailer->send(); + if (!$isok) { + return false; + } + + Platal::load('admin', 'homonyms.inc.php'); + if ($this->warning) { + send_warning_homonym($this->user, $this->email); + } else { + send_robot_homonym($this->user, $this->email); + } } // }}} // {{{ function commit() public function commit() { - Platal::load('admin', 'homonyms.inc.php'); - switch_bestalias($this->user, $this->loginbis); if (!$this->warning) { - XDB::execute("UPDATE aliases SET type = 'homonyme', expire = NOW() WHERE alias = {?}", $this->loginbis); - XDB::execute('INSERT IGNORE INTO homonyms (homonyme_id, uid) - VALUES ({?}, {?})', - $this->user->id(), $this->user->id()); + Platal::load('admin', 'homonyms.inc.php'); + fix_homonym($this->user, $this->email); } return true;