{
// constructor {{{2
- public function __construct($uid, $row)
+ public function __construct(User &$user, $row)
{
- $this->uid = $uid;
+ $this->user = &$user;
$this->sufficient = true;
- list($this->email, $flags, $this->rewrite, $this->panne, $this->last, $this->panne_level) = $row;
+ list($this->email, $flags, $this->rewrite, $this->allow_rewrite, $this->hash, $this->panne, $this->last, $this->panne_level) = $row;
$this->display_email = $this->email;
$this->active = ($flags == 'active');
$this->broken = ($flags == 'panne');
if (!$rewrite || !isvalid_email($rewrite)) {
$rewrite = '';
}
- XDB::execute('UPDATE emails SET rewrite={?} WHERE uid={?} AND email={?}', $rewrite, $this->uid, $this->email);
+ XDB::execute('UPDATE emails SET rewrite = {?} WHERE uid = {?} AND email = {?}', $rewrite, $this->user->id(), $this->email);
$this->rewrite = $rewrite;
- WHERE uid = {?} AND email = {?}", $this->hash, $this->uid, $this->email);
+ if (!$this->allow_rewrite) {
+ global $globals;
+ if (empty($this->hash)) {
+ $this->hash = rand_url_id();
+ XDB::execute("UPDATE emails
+ SET hash = {?}
- $res = XDB::query("SELECT IF(u.nom_usage = '', u.nom, u.nom_usage) AS nom, u.prenom, FIND_IN_SET('femme', u.flags) AS sex,
- q.core_mail_fmt, a.alias AS forlife, a2.alias AS bestalias
- FROM auth_user_md5 AS u
- INNER JOIN auth_user_quick AS q ON (u.user_id = q.user_id)
- INNER JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie')
- INNER JOIN aliases AS a2 ON (a2.id = u.user_id AND FIND_IN_SET('bestalias', a2.flags))
- WHERE u.user_id = {?}", $this->uid);
- list($nom, $prenom, $sexe, $fmt, $forlife, $bestalias) = $res->fetchOneRow();
++ WHERE uid = {?} AND email = {?}", $this->hash, $this->user->id(), $this->email);
+ }
- $mail->assign('nom', $nom);
- $mail->assign('prenom', $prenom);
- $mail->assign('sexe', $sexe);
- $mail->assign('forlife', $forlife);
+ $mail = new PlMailer('emails/rewrite-in.mail.tpl');
+ $mail->assign('mail', $this);
- $mail->send($fmt == 'html');
++ $mail->assign('user', $this->user);
+ $mail->assign('baseurl', $globals->baseurl);
+ $mail->assign('sitename', $globals->core->sitename);
+ $mail->assign('to', $this->email);
++ $mail->send($this->user->isEmailFormatHtml());
+ }
return;
}
// constructor {{{2
- public function __construct($_uid)
+ public function __construct(User &$user)
{
- $this->uid = $_uid;
- $this->bogo = new Bogo($_uid);
+ $this->user = &$user;
+ $this->bogo = new Bogo($user);
// Adds third-party email redirections.
- $res = XDB::iterRow("SELECT email, flags, rewrite, panne, last, panne_level
+ $res = XDB::iterRow("SELECT email, flags, rewrite, allow_rewrite, hash, panne, last, panne_level
FROM emails
- WHERE uid = {?} AND flags != 'filter'", $_uid);
+ WHERE uid = {?} AND flags != 'filter'", $user->id());
$this->emails = Array();
while ($row = $res->next()) {
- $this->emails[] = new EmailRedirection($_uid, $row);
+ $this->emails[] = new EmailRedirection($user, $row);
}
// Adds local email storage backends.
return SUCCESS;
}
}
- $this->emails[] = new EmailRedirection($this->user, array($email, 'active', '', '0000-00-00', '0000-00-00', 0));
- $this->emails[] = new EmailRedirection($this->uid, array($email, 'active', '', 0, null, '0000-00-00', '0000-00-00', 0));
++ $this->emails[] = new EmailRedirection($this->user, array($email, 'active', '', 0, null, '0000-00-00', '0000-00-00', 0));
// security stuff
- check_email($email, "Ajout d'une adresse surveillée aux redirections de " . $this->uid);
+ check_email($email, "Ajout d'une adresse surveillée aux redirections de " . $this->user->login());
check_redirect($this);
return SUCCESS;
}
--- /dev/null
-{if $sexe}Chère{else}Cher{/if} {$prenom},
+ {**************************************************************************}
+ {* *}
+ {* Copyright (C) 2003-2008 Polytechnique.org *}
+ {* http://opensource.polytechnique.org/ *}
+ {* *}
+ {* This program is free software; you can redistribute it and/or modify *}
+ {* it under the terms of the GNU General Public License as published by *}
+ {* the Free Software Foundation; either version 2 of the License, or *}
+ {* (at your option) any later version. *}
+ {* *}
+ {* This program is distributed in the hope that it will be useful, *}
+ {* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+ {* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+ {* GNU General Public License for more details. *}
+ {* *}
+ {* You should have received a copy of the GNU General Public License *}
+ {* along with this program; if not, write to the Free Software *}
+ {* Foundation, Inc., *}
+ {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+ {* *}
+ {**************************************************************************}
+
+ {config_load file="mails.conf" section="rewrite_email"}
+ {if $mail_part eq 'head'}
+ {from full=#from#}
+ {to addr=$to}
+ {subject text="Validation de la demande de réécriture pour l'adresse `$mail->email`"}
+ {elseif $mail_part eq 'wiki'}
++{if $user->isFemale()}Chère{else}Cher{/if} {$user->displayName()},
+
+ Tu reçois cet email car une demande de réécriture vient d'être effectuée sur {$sitename} pour que les mails
+ l'adresse {$mail->email} soit automatiquement réécrite en {$mail->rewrite}.
+
+ Si tu es à l'origine de cette demande, clique sur le lien suivant pour activer la réécriture :
+ * {$baseurl}/emails/rewrite/in/{$mail->email|replace:'@':'_'}/{$mail->hash}
+
+ Si tu n'est pas à l'origine de cette demande, il peut s'agir d'une tentative de détournement de ta correspondance par un
+ camarade mal intentionné. Dans ce cas, clique sur le lien suivant pour avertir l'équipe de {$sitename} :
+ * {$baseurl}/emails/rewrite/out/{$mail->email|replace:'@':'_'}/{$mail->hash}
+
+ Merci encore de la confiance que tu portes à nos services.
+
+ -- \\
+ Très Cordialement,\\
+ L'Équipe de Polytechnique.org
+ {/if}
+
+ {* vim:set et sw=2 sts=2 sws=2: *}