Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
12262f13 | 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
0337d704 | 4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
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. * | |
10 | * * | |
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. * | |
15 | * * | |
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 * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
0337d704 | 22 | // {{{ class HomonymeReq |
23 | ||
24 | class HomonymeReq extends Validate | |
25 | { | |
26 | // {{{ properties | |
eaf30d86 | 27 | |
612a2d8a | 28 | public $loginbis; |
612a2d8a | 29 | public $warning = true; |
6e828e47 | 30 | public $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus … manuellement."; |
0337d704 | 31 | |
32 | // }}} | |
33 | // {{{ constructor | |
eaf30d86 | 34 | |
26ba053e | 35 | public function __construct(User $_user, $_loginbis, $_homonymes_hruid, $warning=true) |
0337d704 | 36 | { |
0337d704 | 37 | $this->warning = $warning; |
38 | ||
5daf68f6 | 39 | parent::__construct($_user, true, $this->title()); |
0337d704 | 40 | |
41 | $this->refuse = false; | |
0337d704 | 42 | $this->loginbis = $_loginbis; |
0337d704 | 43 | } |
eaf30d86 | 44 | |
0337d704 | 45 | // }}} |
46 | // {{{ title() | |
eaf30d86 | 47 | |
612a2d8a | 48 | private function title() |
49 | { | |
5daf68f6 | 50 | return ($this->warning ? 'alerte alias' : 'robot répondeur'); |
0337d704 | 51 | } |
52 | ||
53 | // }}} | |
0337d704 | 54 | // {{{ function formu() |
55 | ||
612a2d8a | 56 | public function formu() |
57 | { | |
58 | return 'include/form.valid.homonymes.tpl'; | |
59 | } | |
0337d704 | 60 | |
61 | // }}} | |
62 | // {{{ function _mail_subj | |
63 | ||
612a2d8a | 64 | protected function _mail_subj() |
0337d704 | 65 | { |
5daf68f6 VZ |
66 | return "[Polytechnique.org/Support] " |
67 | . ($this->warning ? "Dans une semaine : suppression de l'alias " : "Mise en place du robot") | |
f036c896 | 68 | . " $loginbis@" . $this->user->mainEmailDomain(); |
0337d704 | 69 | } |
70 | ||
71 | // }}} | |
72 | // {{{ function _mail_body | |
eaf30d86 | 73 | |
612a2d8a | 74 | protected function _mail_body($isok) |
0337d704 | 75 | { |
0337d704 | 76 | return |
77 | " | |
faefdbb7 SJ |
78 | Comme nous t'en avons informé par email il y a quelques temps, |
79 | pour respecter nos engagements en terme d'adresses email devinables, | |
f036c896 | 80 | tu te verras bientôt retirer l'alias " . $this->loginbis . "@" . $this->user->mainEmailDomain() . " pour |
5daf68f6 | 81 | ne garder que " . $this->user->forlifeEmail() . ". |
0337d704 | 82 | |
f036c896 SJ |
83 | Toute personne qui écrira à " . $this->loginbis . "@" . $this->user->mainEmailDomain() . " recevra la |
84 | réponse d'un robot qui l'informera que " . $this->loginbis . "@" . $this->user->mainEmailDomain() . " | |
0337d704 | 85 | est ambigu pour des raisons d'homonymie et signalera ton email exact."; |
86 | } | |
87 | ||
88 | // }}} | |
89 | // {{{ function sendmail() | |
90 | ||
612a2d8a | 91 | protected function sendmail($isok) |
0337d704 | 92 | { |
93 | if (!$isok) return false; | |
94 | global $globals; | |
1e33266a | 95 | $mailer = new PlMailer; |
5daf68f6 VZ |
96 | $cc = "support+homonyme@" . $globals->mail->domain; |
97 | $from = "\"Support Polytechnique.org\" <$cc>"; | |
0337d704 | 98 | $mailer->setSubject($this->_mail_subj()); |
5daf68f6 VZ |
99 | $mailer->setFrom($from); |
100 | $mailer->addTo("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>"); | |
0337d704 | 101 | $mailer->addCc($cc); |
102 | ||
5daf68f6 | 103 | $body = $this->user->displayName() . ",\n\n" |
0337d704 | 104 | . $this->_mail_body($isok) |
5e2307dc | 105 | . (Env::has('comm') ? "\n\n".Env::v('comm') : '') |
780bc68d | 106 | . "\n\nCordialement,\n\n-- \nL'équipe de Polytechnique.org\n"; |
0337d704 | 107 | |
108 | $mailer->setTxtBody(wordwrap($body)); | |
109 | $mailer->send(); | |
110 | } | |
111 | // }}} | |
112 | // {{{ function commit() | |
eaf30d86 | 113 | |
612a2d8a | 114 | public function commit() |
0337d704 | 115 | { |
191711d5 | 116 | Platal::load('admin', 'homonyms.inc.php'); |
0337d704 | 117 | if (!$this->warning) { |
4371e993 SJ |
118 | require_once 'emails.inc.php'; |
119 | ||
f036c896 SJ |
120 | XDB::execute('DELETE FROM email_source_account |
121 | WHERE email = {?} AND type = \'alias\'', | |
122 | $this->loginbis); | |
4371e993 | 123 | XDB::execute('INSERT INTO email_source_other (hrmid, email, domain, type, expire) |
f036c896 | 124 | SELECT {?}, {?}, id, \'homonym\', NOW() |
4371e993 SJ |
125 | FROM email_virtual_domains |
126 | WHERE name = {?}', | |
f88d9154 | 127 | User::makeHomonymHrmid($this->loginbis), $this->loginbis, $this->user->mainEmailDomain()); |
4371e993 | 128 | fix_bestalias($this->user); |
0337d704 | 129 | } |
eaf30d86 | 130 | |
0337d704 | 131 | return true; |
132 | } | |
133 | ||
134 | // }}} | |
135 | } | |
136 | ||
137 | // }}} | |
138 | ||
a7de4ef7 | 139 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 140 | ?> |