X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fhomonymes.inc.php;h=33e8da147737a0d9c6b281214a59f43229f54a09;hb=85b2b2257110a8c77d70624f0fa9bba402d99e5f;hp=10663c51843b55efc829abe84ff4bb7321bc0c6a;hpb=af744c2d5f4ddf83b738b9cb390926eaca4cf7c3;p=platal.git diff --git a/include/validations/homonymes.inc.php b/include/validations/homonymes.inc.php index 10663c5..33e8da1 100644 --- a/include/validations/homonymes.inc.php +++ b/include/validations/homonymes.inc.php @@ -1,6 +1,6 @@ warning = $warning; parent::__construct($_user, true, $this->title()); $this->refuse = false; - $this->loginbis = $_loginbis; + $this->email = $_email; $this->homonymes_hruid = $_homonymes_hruid; } @@ -69,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(); } // }}} @@ -80,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."; } @@ -98,35 +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() { - require_once('homonymes.inc.php'); - - switch_bestalias($this->user->id(), $this->loginbis); if (!$this->warning) { - XDB::execute("UPDATE aliases SET type = 'homonyme', expire = NOW() WHERE alias = {?}", $this->loginbis); - XDB::execute("REPLACE INTO homonymes (homonyme_id, user_id) VALUES({?}, {?})", $this->user->id(), $this->user->id()); + Platal::load('admin', 'homonyms.inc.php'); + fix_homonym($this->user, $this->email); } return true;