Move X.net recovery email text into a template.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Wed, 7 Sep 2011 22:14:38 +0000 (00:14 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Thu, 8 Sep 2011 23:57:02 +0000 (01:57 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
configs/mails.conf
modules/platal.php
templates/platal/password_recovery_xnet.mail.tpl [new file with mode: 0644]

index c8f6888..fc294d4 100644 (file)
@@ -79,6 +79,9 @@ replyto=registration+watch@staff.m4x.org
 from="Polytechnique.org" <validation_modification@polytechnique.org>
 cc="Polytechnique.org" <validation_modification@polytechnique.org>
 
+[password_recovery_xnet]
+from="Gestion des mots de passe" <support+password@polytechnique.org>
+
 [xnet_notification]
 from="Polytechnique.org" <contact@polytechnique.org>
 
index 99b6d7c..c9fd3d9 100644 (file)
@@ -374,20 +374,10 @@ Adresse de secours : ' . $to));
                            VALUES  ({?}, NOW(), {?})',
                      $user->id(), $hash);
 
-        $mymail = new PlMailer();
-        $mymail->setFrom('"Gestion des mots de passe" <support+password@' . Platal::globals()->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 (file)
index 0000000..d3f0f9e
--- /dev/null
@@ -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}