91933c09ee3567ea8d9d27e2f6d107473696a36b
2 /***************************************************************************
3 * Copyright (C) 2003-2013 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 function select_if_homonym(PlUser
$user)
24 return XDB
::fetchOneCell('SELECT email
25 FROM email_source_account
26 WHERE uid = {?} AND expire IS NOT NULL',
30 function send_warning_homonym(PlUser
$user, $email)
32 $cc = "validation+homonyme@" . Platal
::globals()->mail
->domain
;
33 $from = "\"Support Polytechnique.org\" <$cc>";
34 $body = Post
::has('mailbody') ? Post
::t('mailbody') : get_warning_mail_text($user, $email);
36 $mymail = new PlMailer();
37 $mymail->setFrom($from);
39 $mymail->setSubject("Dans 1 semaine, suppression de $email@" . $user->mainEmailDomain());
40 $mymail->setTxtBody($body);
41 $mymail->sendTo($user);
44 function send_robot_homonym(PlUser
$user, $email)
46 $cc = "validation+homonyme@" . Platal
::globals()->mail
->domain
;
47 $from = "\"Support Polytechnique.org\" <$cc>";
48 $body = Post
::has('mailbody') ? Post
::t('mailbody') : get_robot_mail_text($user, $email);
49 $user = User
::getSilentWithUID($user->id());
51 $mymail = new PlMailer();
52 $mymail->setFrom($from);
53 $mymail->setSubject("Mise en place du robot $email@" . $user->mainEmailDomain());
55 $mymail->setTxtBody($body);
56 $mymail->sendTo($user);
59 function get_warning_mail_text(PlUser
$user, $email)
61 $display_name = $user->displayName();
62 $former_email = $email . '@' . $user->mainEmailDomain();
63 $forlife_email = $user->forlifeEmail();
65 return "$display_name,\n\nComme nous t'en avons informé par email il y a "
66 . "quelques temps, pour respecter nos engagements en terme d'adresses "
67 . "email devinables, tu te verras bientôt retirer l'alias $former_email "
68 . "pour ne garder que $forlife_email.\n\nToute personne qui écrira à "
69 . "$former_email recevra la réponse d'un robot qui l'informera que "
70 . "$former_email est ambigu pour des raisons d'homonymie et signalera "
71 . "ton email exact.\n\nCordialement,\n-- \nl'équipe de Polytechnique.org"
72 . "\nLe portail des élèves & anciens élèves de l'École polytechnique";
75 function get_robot_mail_text(PlUser
$user, $email)
77 $display_name = $user->displayName();
78 $former_email = $email . '@' . $user->mainEmailDomain();
80 return "$display_name,\n\nComme nous t'en avons informé par email il y a "
81 . "quelques temps, nous t'avons retiré de façon définitive l'adresse "
82 . "$former_email.\n\nToute personne qui écrit à $former_email reçoit "
83 . "la réponse d'un robot qui l'informe que $former_email est ambigu "
84 . "pour des raisons d'homonymie et indique ton email exact.\n\nTu peux "
85 . "faire l'essai toi-même en écrivant à $former_email.\n\nCordialement,"
86 . "\n-- \nl'équipe de Polytechnique.org"
87 . "\nLe portail des élèves & anciens élèves de l'École polytechnique";
90 function fix_homonym(PlUser
$user, $email)
92 XDB
::execute('DELETE FROM email_source_account
93 WHERE email = {?} AND type = \'alias\'',
96 $hrmid = User
::makeHomonymHrmid($email);
97 // TODO: insert twice into source_other if different domains
98 XDB
::execute('INSERT INTO email_source_other (hrmid, email, domain, type, expire)
99 SELECT {?}, {?}, id, \'homonym\', NOW()
100 FROM email_virtual_domains
102 $hrmid, $email, $user->mainEmailDomain());
103 XDB
::execute("INSERT INTO email_redirect_other (hrmid, redirect, type, action)
104 VALUES ({?}, '', 'homonym', 'homonym')",
108 require_once 'emails.inc.php';
109 fix_bestalias($user);
112 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: