<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once('validations.inc.php');
+require_once 'validations.inc.php';
// {{{ class HomonymeReq
class HomonymeReq extends Validate
{
// {{{ properties
-
- var $loginbis;
- var $warning = true;
+ public $loginbis;
- var $homonymes_forlife;
+ public $warning = true;
- var $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus ... manuellement";
+ public $homonymes_hruid;
+
+ public $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus … manuellement.";
// }}}
// {{{ constructor
-
- function HomonymeReq($_uid, $_loginbis, $_homonymes_forlife, $warning=true)
- {
- global $global;
+ public function __construct(User &$_user, $_loginbis, $_homonymes_hruid, $warning=true)
+ {
$this->warning = $warning;
- $this->Validate($_uid, true, $this->title());
+ parent::__construct($_user, true, $this->title());
$this->refuse = false;
-
$this->loginbis = $_loginbis;
-
- $this->homonymes_forlife = $_homonymes_forlife;
-
+ $this->homonymes_hruid = $_homonymes_hruid;
}
-
+
// }}}
// {{{ title()
-
- function title() {
- return $this->warning?'alerte alias':'robot répondeur';
+
+ private function title()
+ {
+ return ($this->warning ? 'alerte alias' : 'robot répondeur');
}
// }}}
// {{{ function formu()
- function formu()
- { return 'include/form.valid.homonymes.tpl'; }
+ public function formu()
+ {
+ return 'include/form.valid.homonymes.tpl';
+ }
// }}}
// {{{ function _mail_subj
- function _mail_subj()
+ protected function _mail_subj()
{
- return "[Polytechnique.org/Support] ".($this->warning?"Dans une semaine : suppression de l'alias":"Mise en place du robot")." $loginbis@polytechnique.org";
+ global $globals;
+ return "[Polytechnique.org/Support] "
+ . ($this->warning ? "Dans une semaine : suppression de l'alias " : "Mise en place du robot")
+ . " $loginbis@" . $globals->mail->domain;
}
// }}}
// {{{ function _mail_body
-
- function _mail_body($isok)
+
+ protected function _mail_body($isok)
{
global $globals;
return
"
-Comme nous t'en avons informé par mail il y a quelques temps,
-pour respecter nos engagements en terme d'adresses e-mail devinables,
+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.".
+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."
// }}}
// {{{ function sendmail()
- function sendmail($isok)
+ protected function sendmail($isok)
{
if (!$isok) return false;
global $globals;
$mailer = new PlMailer;
- $cc = "support+homonyme@".$globals->mail->domain;
- $FROM = "\"Support Polytechnique.org\" <$cc>";
+ $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->setFrom($from);
+ $mailer->addTo("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>");
$mailer->addCc($cc);
- $body = $this->prenom.",\n\n"
+ $body = $this->user->displayName() . ",\n\n"
. $this->_mail_body($isok)
. (Env::has('comm') ? "\n\n".Env::v('comm') : '')
- . "\n\nCordialement,\nL'équipe Polytechnique.org\n";
+ . "\n\nCordialement,\n\n-- \nL'équipe de Polytechnique.org\n";
$mailer->setTxtBody(wordwrap($body));
$mailer->send();
}
// }}}
// {{{ function commit()
-
- function commit()
- {
- require_once('homonymes.inc.php');
- switch_bestalias($this->uid, $this->loginbis);
+ 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("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $this->uid, $this->uid);
+ XDB::execute("UPDATE aliases SET type = 'homonyme', expire = NOW() WHERE alias = {?}", $this->loginbis);
+ XDB::execute("REPLACE INTO homonyms (homonyme_id, uid) VALUES({?}, {?})", $this->user->id(), $this->user->id());
}
-
+
return true;
}