Commit | Line | Data |
---|---|---|
0d693e2f | 1 | <?php |
2 | /*************************************************************************** | |
179afa7f | 3 | * Copyright (C) 2003-2008 Polytechnique.org * |
0d693e2f | 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 | ||
22 | ||
23 | class BrokenReq extends Validate | |
24 | { | |
25 | // {{{ properties | |
26 | ||
612a2d8a | 27 | public $m_forlife; |
28 | public $m_bestalias; | |
29 | public $m_prenom; | |
30 | public $m_nom; | |
31 | public $m_promo; | |
32 | public $m_sexe; | |
33 | public $m_email; | |
34 | public $old_email; | |
35 | public $m_comment; | |
0d693e2f | 36 | |
0381e170 | 37 | private $m_reactive = false; |
38 | ||
faefdbb7 SJ |
39 | public $rules = "Accepter si l'adresse email parait correcte, et pas absurde (ou si le marketeur est de confiance). |
40 | Si le demandeur marque sa propre adresse email, refuser dans tous les cas. | |
a7de4ef7 | 41 | Si l'adresse proposée est surveillée, refuser. |
2abaa1e5 | 42 | Si le compte associé est désactivé, étudier le cas en fonction de la raison de la désactivation."; |
0d693e2f | 43 | // }}} |
44 | // {{{ constructor | |
45 | ||
612a2d8a | 46 | public function __construct($sender, $user, $email, $comment = null) |
0d693e2f | 47 | { |
612a2d8a | 48 | parent::__construct($sender, false, 'broken'); |
0d693e2f | 49 | $this->m_email = $email; |
50 | $this->m_comment = trim($comment); | |
51 | $this->m_forlife = $user['forlife']; | |
52 | $this->m_bestalias = $user['bestalias']; | |
53 | $this->m_prenom = $user['prenom']; | |
54 | $this->m_nom = $user['nom']; | |
55 | $this->m_promo = $user['promo']; | |
56 | $this->m_sexe = $user['sexe']; | |
57 | $this->old_email = $user['email']; | |
58 | } | |
59 | ||
60 | // }}} | |
61 | // {{{ function formu() | |
62 | ||
612a2d8a | 63 | public function formu() |
0d693e2f | 64 | { |
65 | return 'include/form.valid.broken.tpl'; | |
66 | } | |
67 | ||
68 | // }}} | |
69 | // {{{ function _mail_subj | |
eaf30d86 | 70 | |
612a2d8a | 71 | protected function _mail_subj() |
0d693e2f | 72 | { |
a7de4ef7 | 73 | return "[Polytechnique.org] Récupération de {$this->m_prenom} {$this->m_nom} ({$this->m_promo})"; |
0d693e2f | 74 | } |
75 | ||
76 | // }}} | |
77 | // {{{ function _mail_body | |
78 | ||
612a2d8a | 79 | protected function _mail_body($isok) |
0d693e2f | 80 | { |
0381e170 | 81 | if ($isok && !$this->m_reactive) { |
faefdbb7 | 82 | return " Un email de contact vient d'être envoyé" |
a7de4ef7 | 83 | ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour confirmer sa volonté de" |
87ec7aa3 | 84 | ." mettre à jour sa redirection Polytechnique.org !\n\n" |
0d693e2f | 85 | ."Merci de ta participation !\n"; |
0381e170 | 86 | } elseif ($isok) { |
87 | return " L'adresse de redirection {$this->m_email} de {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) " | |
faefdbb7 | 88 | ."vient d'être réactivée. Un email lui a été envoyé pour l'en informer.\n\n" |
0381e170 | 89 | ."Merci de ta participation !\n"; |
0d693e2f | 90 | } else { |
0381e170 | 91 | return " Nous n'utiliserons pas cette adresse pour contacter {$this->m_prenom} {$this->m_nom} ({$this->m_promo})."; |
0d693e2f | 92 | } |
93 | } | |
94 | ||
95 | // }}} | |
96 | // {{{ function commit() | |
97 | ||
612a2d8a | 98 | public function commit() |
0d693e2f | 99 | { |
100 | global $globals; | |
101 | $email = $this->m_bestalias . '@' . $globals->mail->domain; | |
0381e170 | 102 | |
eaf30d86 | 103 | XDB::execute("UPDATE emails AS e |
0381e170 | 104 | INNER JOIN aliases AS a ON (a.id = e.uid) |
c23010a6 | 105 | SET e.flags = 'active', panne_level = 2 |
0381e170 | 106 | WHERE a.alias = {?} AND e.email = {?}", $this->m_forlife, $this->m_email); |
107 | if (XDB::affectedRows() > 0) { | |
108 | $this->m_reactive = true; | |
109 | $mailer = new PlMailer(); | |
1d55fe45 | 110 | $mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>'); |
0381e170 | 111 | $mailer->addTo($email); |
112 | $mailer->setSubject("Mise à jour de ton adresse $email"); | |
113 | $mailer->setTxtBody(wordwrap("Cher Camarade,\n\n" | |
114 | . "Ton adresse $email étant en panne et ayant été informés que ta redirection {$this->m_email}, jusqu'à présent inactive, " | |
115 | . "est fonctionnelle, nous venons de réactiver cette adresse.\n\n" | |
116 | . "N'hésite pas à aller gérer toi-même tes redirections en te rendant à la page :\n" | |
117 | . "https://www.polytechnique.org/emails/redirect\n" | |
118 | . "Si tu as perdu ton mot de passe d'accès au site, tu peux également effectuer la procédure de récupération à l'adresse :\n" | |
2abaa1e5 | 119 | . "https://www.polytechnique.org/recovery\n\n" |
0b79c292 | 120 | . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n")); |
0381e170 | 121 | $mailer->send(); |
122 | return true; | |
123 | } | |
eaf30d86 | 124 | |
0381e170 | 125 | $email = $this->m_bestalias . '@' . $globals->mail->domain; |
0d693e2f | 126 | if ($this->old_email) { |
127 | $subject = "Ton adresse $email semble ne plus fonctionner"; | |
a7de4ef7 | 128 | $reason = "Nous avons été informés que ton adresse $email ne fonctionne plus correctement par un camarade"; |
0d693e2f | 129 | } else { |
130 | $res = XDB::iterRow("SELECT email | |
131 | FROM emails AS e | |
132 | INNER JOIN aliases AS a ON (a.id = e.uid) | |
133 | WHERE a.alias = {?} AND e.flags = 'panne'", $this->m_forlife); | |
134 | $redirect = array(); | |
135 | while (list($red) = $res->next()) { | |
136 | list(, $redirect[]) = explode('@', $red); | |
137 | } | |
138 | $subject = "Ton adresse $email ne fonctionne plus"; | |
fe1f0019 | 139 | $reason = "Ton adresse $email ne fonctionne plus"; |
0d693e2f | 140 | if (!count($redirect)) { |
141 | $reason .= '.'; | |
142 | } elseif (count($redirect) == 1) { | |
0b79c292 | 143 | $reason .= ' car sa redirection vers ' . $redirect[0] . ' est hors-service depuis plusieurs mois.'; |
0d693e2f | 144 | } else { |
eaf30d86 | 145 | $reason .= ' car ses redirections vers ' . implode(', ', $redirect) |
0d693e2f | 146 | . ' sont hors-services depuis plusieurs mois.'; |
147 | } | |
148 | } | |
a7de4ef7 | 149 | $body = ($this->m_sexe ? 'Chère ' : 'Cher ') . $this->m_prenom . ",\n\n" |
0d693e2f | 150 | . $reason . "\n\n" |
a7de4ef7 | 151 | . "L'adresse {$this->m_email} nous a été communiquée, veux-tu que cette adresse devienne ta nouvelle " |
80e89cb5 | 152 | . "adresse de redirection ? Si oui, envoie nous des informations qui " |
2abaa1e5 | 153 | . "nous permettront de nous assurer de ton identité (par exemple ta date de naissance et ta promotion).\n\n" |
0b79c292 | 154 | . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n"; |
0d693e2f | 155 | $body = wordwrap($body, 78); |
156 | $mailer = new PlMailer(); | |
1d55fe45 | 157 | $mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>'); |
0d693e2f | 158 | $mailer->addTo($this->m_email); |
159 | $mailer->setSubject($subject); | |
160 | $mailer->setTxtBody($body); | |
161 | return $mailer->send(); | |
162 | } | |
163 | ||
164 | // }}} | |
165 | } | |
166 | ||
a7de4ef7 | 167 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0d693e2f | 168 | ?> |