44f0234311b42b3e0fdcb2e513046efe89c1da3f
2 /***************************************************************************
3 * Copyright (C) 2003-2008 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once 'validations.inc.php';
23 // {{{ class HomonymeReq
25 class HomonymeReq
extends Validate
31 public $warning = true
;
33 public $homonymes_hruid;
35 public $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus ... manuellement";
40 public function __construct(User
&$_user, $_loginbis, $_homonymes_hruid, $warning=true
)
42 $this->warning
= $warning;
44 parent
::__construct($_user, true
, $this->title());
46 $this->refuse
= false
;
47 $this->loginbis
= $_loginbis;
48 $this->homonymes_hruid
= $_homonymes_hruid;
54 private function title()
56 return ($this->warning ?
'alerte alias' : 'robot répondeur');
60 // {{{ function formu()
62 public function formu()
64 return 'include/form.valid.homonymes.tpl';
68 // {{{ function _mail_subj
70 protected function _mail_subj()
73 return "[Polytechnique.org/Support] "
74 . ($this->warning ?
"Dans une semaine : suppression de l'alias " : "Mise en place du robot")
75 . " $loginbis@" . $globals->mail
->domain
;
79 // {{{ function _mail_body
81 protected function _mail_body($isok)
86 Comme nous t'en avons informé par email il y a quelques temps,
87 pour respecter nos engagements en terme d'adresses email devinables,
88 tu te verras bientôt retirer l'alias ".$this->loginbis
."@".$globals->mail
->domain
." pour
89 ne garder que " . $this->user
->forlifeEmail() . ".
91 Toute personne qui écrira à ".$this->loginbis
."@".$globals->mail
->domain
." recevra la
92 réponse d'un robot qui l'informera que ".$this->loginbis
."@".$globals->mail
->domain
."
93 est ambigu pour des raisons d'homonymie et signalera ton email exact.";
97 // {{{ function sendmail()
99 protected function sendmail($isok)
101 if (!$isok) return false
;
103 $mailer = new PlMailer
;
104 $cc = "support+homonyme@" . $globals->mail
->domain
;
105 $from = "\"Support Polytechnique.org\" <$cc>";
106 $mailer->setSubject($this->_mail_subj());
107 $mailer->setFrom($from);
108 $mailer->addTo("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>");
111 $body = $this->user
->displayName() . ",\n\n"
112 . $this->_mail_body($isok)
113 . (Env
::has('comm') ?
"\n\n".Env
::v('comm') : '')
114 . "\n\nCordialement,\n\n-- \nL'équipe de Polytechnique.org\n";
116 $mailer->setTxtBody(wordwrap($body));
120 // {{{ function commit()
122 public function commit()
124 require_once('homonymes.inc.php');
126 switch_bestalias($this->user
->id(), $this->loginbis
);
127 if (!$this->warning
) {
128 XDB
::execute("UPDATE aliases SET type = 'homonyme', expire = NOW() WHERE alias = {?}", $this->loginbis
);
129 XDB
::execute("REPLACE INTO homonymes (homonyme_id, user_id) VALUES({?}, {?})", $this->user
->id(), $this->user
->id());
140 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: