X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fhomonymes.inc.php;h=33e8da147737a0d9c6b281214a59f43229f54a09;hb=85b2b2257110a8c77d70624f0fa9bba402d99e5f;hp=88ddcf7bd1ab129341dcb3d55bedce2cb4e76c60;hpb=63f06a435ff8e9c058b1dee1eb97fff99606d490;p=platal.git diff --git a/include/validations/homonymes.inc.php b/include/validations/homonymes.inc.php index 88ddcf7..33e8da1 100644 --- a/include/validations/homonymes.inc.php +++ b/include/validations/homonymes.inc.php @@ -1,6 +1,6 @@ warning = $warning; - parent::__construct($_uid, true, $this->title()); + parent::__construct($_user, true, $this->title()); $this->refuse = false; - $this->loginbis = $_loginbis; - $this->homonymes_forlife = $_homonymes_forlife; + $this->email = $_email; + $this->homonymes_hruid = $_homonymes_hruid; } // }}} @@ -53,7 +49,7 @@ class HomonymeReq extends Validate private function title() { - return $this->warning?'alerte alias':'robot répondeur'; + return ($this->warning ? 'alerte alias' : 'robot répondeur'); } // }}} @@ -69,8 +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; + return "[Polytechnique.org/Support] " + . ($this->warning ? "Dans une semaine : suppression de l'alias " : "Mise en place du robot") + . " $email@" . $this->user->mainEmailDomain(); } // }}} @@ -78,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 -ne garder que ".$this->forlife."@".$globals->mail->domain.". +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."; } @@ -96,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->prenom} {$this->nom}\" <{$this->bestalias}@{$globals->mail->domain}>"); - $mailer->addCc($cc); - - $body = $this->prenom.",\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->uid, $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->uid, $this->uid); + Platal::load('admin', 'homonyms.inc.php'); + fix_homonym($this->user, $this->email); } return true;