From 23906784005fe1ff24da27c4c6b88f0bcf95d168 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 8 Sep 2011 00:14:38 +0200 Subject: [PATCH] Move X.net recovery email text into a template. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- configs/mails.conf | 3 ++ modules/platal.php | 22 +++++--------- templates/platal/password_recovery_xnet.mail.tpl | 37 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 templates/platal/password_recovery_xnet.mail.tpl diff --git a/configs/mails.conf b/configs/mails.conf index c8f6888..fc294d4 100644 --- a/configs/mails.conf +++ b/configs/mails.conf @@ -79,6 +79,9 @@ replyto=registration+watch@staff.m4x.org from="Polytechnique.org" cc="Polytechnique.org" +[password_recovery_xnet] +from="Gestion des mots de passe" + [xnet_notification] from="Polytechnique.org" diff --git a/modules/platal.php b/modules/platal.php index 99b6d7c..c9fd3d9 100644 --- a/modules/platal.php +++ b/modules/platal.php @@ -374,20 +374,10 @@ Adresse de secours : ' . $to)); VALUES ({?}, NOW(), {?})', $user->id(), $hash); - $mymail = new PlMailer(); - $mymail->setFrom('"Gestion des mots de passe" mail->domain . '>'); + $mymail = new PlMailer('platal/password_recovery_xnet.mail.tpl'); $mymail->addTo($user); - $mymail->setSubject("Votre certificat d'authentification"); - $mymail->setTxtBody("Visitez la page suivante qui expire dans six heures : -https://www.polytechnique.org/tmpPWD/$hash - -Si en cliquant dessus vous n'y arrivez pas, copiez intégralement l'adresse dans la barre de votre navigateur. Si vous n'avez pas utilisé ce lien dans six heures, vous pouvez tout simplement recommencer cette procédure. - --- -Polytechnique.org -\"Le portail des élèves & anciens élèves de l'École polytechnique\" - -Email envoyé à " . Post::t('login')); + $mymail->assign('hash', $hash); + $mymail->assign('email', Post::t('login')); $mymail->send(); S::logger($user->id())->log('recovery', $user->bestEmail()); @@ -449,7 +439,7 @@ Email envoyé à " . Post::t('login')); { XDB::execute('DELETE FROM register_pending_xnet WHERE DATE_SUB(NOW(), INTERVAL 1 MONTH) > date'); - $res = XDB::fetchOneAssoc('SELECT uid, hruid + $res = XDB::fetchOneAssoc('SELECT uid, hruid, email FROM register_pending_xnet WHERE hash = {?}', $hash); @@ -459,13 +449,15 @@ Email envoyé à " . Post::t('login')); } if (Post::has('pwhash') && Post::t('pwhash')) { + XDB::startTransaction(); XDB::query('UPDATE accounts SET password = {?}, state = \'active\', registration_date = NOW() WHERE uid = {?} AND state = \'pending\' AND type = \'xnet\'', Post::t('pwhash'), $res['uid']); XDB::query('DELETE FROM register_pending_xnet WHERE uid = {?}', - $res['uid']); + $res['uid']); + XDB::commit(); S::logger($res['uid'])->log('passwd', ''); diff --git a/templates/platal/password_recovery_xnet.mail.tpl b/templates/platal/password_recovery_xnet.mail.tpl new file mode 100644 index 0000000..d3f0f9e --- /dev/null +++ b/templates/platal/password_recovery_xnet.mail.tpl @@ -0,0 +1,37 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2011 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="password_recovery_xnet"} +{if $mail_part eq 'head'} +{subject text="Votre certificat d'authentification"} +{from full=#from#} +{elseif $mail_part eq 'text'} + +Visitez la page suivante qui expire dans six heures : +{$globals->baseurl}/tmpPWD/{$hash} + +Si en cliquant dessus vous n'y arrivez pas, copiez intégralement l'adresse dans la barre de votre navigateur. Si vous n'avez pas utilisé ce lien dans six heures, vous pouvez tout simplement recommencer cette procédure. + +{include file="include/signature.mail.tpl"} + +Email envoyé à {$email} +{/if} -- 2.1.4