2 /***************************************************************************
3 * Copyright (C) 2003-2006 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
33 var $homonymes_forlife;
35 var $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus ... manuellement";
40 function HomonymeReq($_uid, $_loginbis, $_homonymes_forlife, $warning=true
)
44 $this->warning
= $warning;
46 $this->Validate($_uid, true
, $this->title());
48 $this->refuse
= false
;
50 $this->loginbis
= $_loginbis;
52 $this->homonymes_forlife
= $_homonymes_forlife;
60 return $this->warning?
'alerte alias':'robot répondeur';
64 // {{{ function get_request()
66 function get_request($uid)
68 return parent
::get_request($uid,$this->title
);
72 // {{{ function formu()
75 { return 'include/form.valid.homonymes.tpl'; }
78 // {{{ function _mail_subj
82 return "[Polytechnique.org/Support] ".($this->warning?
"Dans une semaine : suppression de l'alias":"Mise en place du robot")." $loginbis@polytechnique.org";
86 // {{{ function _mail_body
88 function _mail_body($isok)
93 Comme nous t'en avons informé par mail il y a quelques temps,
94 pour respecter nos engagements en terme d'adresses e-mail devinables,
95 tu te verras bientôt retirer l'alias ".$this->loginbis
."@".$globals->mail
->domain
." pour
96 ne garder que ".$this->forlife
."@".$globals->mail
->domain
.".
98 Toute personne qui écrira à ".$this->loginbis
."@".$globals->mail
->domain
." recevra la
99 réponse d'un robot qui l'informera que ".$this->loginbis
."@".$globals->mail
->domain
."
100 est ambigu pour des raisons d'homonymie et signalera ton email exact.";
104 // {{{ function sendmail()
106 function sendmail($isok)
108 if (!$isok) return false
;
110 require_once('diogenes/diogenes.hermes.inc.php');
111 $mailer = new HermesMailer
;
112 $cc = "support+homonyme@".$globals->mail
->domain
;
113 $FROM = "\"Support Polytechnique.org\" <$cc>";
114 $mailer->setSubject($this->_mail_subj());
115 $mailer->setFrom($FROM);
116 $mailer->addTo("\"{$this->prenom} {$this->nom}\" <{$this->bestalias}@{$globals->mail->domain}>");
119 $body = $this->prenom
.",\n\n"
120 . $this->_mail_body($isok)
121 . (Env
::has('comm') ?
"\n\n".Env
::get('comm') : '')
122 . "\n\nCordialement,\nL'équipe Polytechnique.org\n";
124 $mailer->setTxtBody(wordwrap($body));
128 // {{{ function commit()
133 require_once('homonymes.inc.php');
135 switch_bestalias($this->uid
, $this->loginbis
);
136 if (!$this->warning
) {
137 $globals->xdb
->execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $this->loginbis
);
138 $globals->xdb
->execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $this->uid
, $this->uid
);
149 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: