From: Vincent Zanotti Date: Sun, 21 Sep 2008 20:24:50 +0000 (+0200) Subject: Merge commit 'origin/master' into hruid X-Git-Tag: xorg/0.10.0~86^2~14 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=21c7c593d7100a887f984c49a82c03eb32169fc4;p=platal.git Merge commit 'origin/master' into hruid Conflicts: include/emails.inc.php Signed-off-by: Vincent Zanotti --- 21c7c593d7100a887f984c49a82c03eb32169fc4 diff --cc include/emails.inc.php index f285f08,0984c38..db87791 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@@ -176,12 -176,12 +178,12 @@@ class EmailRedirection extends Emai { // 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'); @@@ -225,8 -225,35 +227,24 @@@ 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; + if (!$this->allow_rewrite) { + global $globals; + if (empty($this->hash)) { + $this->hash = rand_url_id(); + XDB::execute("UPDATE emails + SET hash = {?} - WHERE uid = {?} AND email = {?}", $this->hash, $this->uid, $this->email); ++ WHERE uid = {?} AND email = {?}", $this->hash, $this->user->id(), $this->email); + } - $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(); + $mail = new PlMailer('emails/rewrite-in.mail.tpl'); + $mail->assign('mail', $this); - $mail->assign('nom', $nom); - $mail->assign('prenom', $prenom); - $mail->assign('sexe', $sexe); - $mail->assign('forlife', $forlife); ++ $mail->assign('user', $this->user); + $mail->assign('baseurl', $globals->baseurl); + $mail->assign('sitename', $globals->core->sitename); + $mail->assign('to', $this->email); - $mail->send($fmt == 'html'); ++ $mail->send($this->user->isEmailFormatHtml()); + } return; } @@@ -382,18 -409,18 +400,18 @@@ class Redirec // 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. @@@ -452,10 -479,10 +470,10 @@@ 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; } diff --cc templates/emails/rewrite-in.mail.tpl index 0000000,38dfc0c..c9f0a35 mode 000000,100644..100644 --- a/templates/emails/rewrite-in.mail.tpl +++ b/templates/emails/rewrite-in.mail.tpl @@@ -1,0 -1,48 +1,48 @@@ + {**************************************************************************} + {* *} + {* 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 $sexe}Chère{else}Cher{/if} {$prenom}, ++{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: *} diff --cc templates/include/minifiche.tpl index 69f868f,50ca5f4..26d428c --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@@ -59,16 -59,18 +59,18 @@@ *}{icon name=cross title="Retirer de la liste de mes surveillances"} {/if} {elseif $c.wasinscrit} - {* + {* *}{icon name=user_suit title="Afficher la fiche"} {if !$c.dcd} - {* + {* *}{icon name=vcard title="Afficher la carte de visite"} + {* + *}{icon name=email title="Envoyer un email"} {if $show_action eq ajouter} - {* + {* *}{icon name=add title="Ajouter à mes contacts"} {else} - {* + {* *}{icon name=cross title="Retirer de mes contacts"} {/if} {/if}