From 45d14044f8fe6fd935dfcb2241eb594a9095ce4a Mon Sep 17 00:00:00 2001
From: Olivier PEREZ <olivier@olivierperez.fr>
Date: Tue, 14 Apr 2015 22:32:41 +0200
Subject: [PATCH] Factorize a little the mails

---
 app/classes/Framadate/Services/MailService.php | 4 ++--
 create_classic_poll.php                        | 4 ++--
 create_date_poll.php                           | 4 ++--
 locale/fr.json                                 | 2 +-
 studs.php                                      | 1 -
 5 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/app/classes/Framadate/Services/MailService.php b/app/classes/Framadate/Services/MailService.php
index 3c445ec8..2b7dd66a 100644
--- a/app/classes/Framadate/Services/MailService.php
+++ b/app/classes/Framadate/Services/MailService.php
@@ -14,7 +14,7 @@ class MailService {
     }
 
     function send($to, $subject, $body, $param = '') {
-        if($this->smtp_allowed == true) {
+        if ($this->smtp_allowed == true) {
             mb_internal_encoding('UTF-8');
 
             $subject = mb_encode_mimeheader(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'), 'UTF-8', 'B', "\n", 9);
@@ -39,7 +39,7 @@ class MailService {
             $headers .= "Auto-Submitted:auto-generated\n";
             $headers .= 'Return-Path: <>';
 
-            $body = html_entity_decode($body, ENT_QUOTES, 'UTF-8') . __('Mail', 'FOOTER');
+            $body = $body . '<br/><br/>' . __('Mail', 'Thanks for your trust.') . '<br/>' . NOMAPPLICATION . '<hr/>' . __('Mail', 'FOOTER');
 
             mail($to, $subject, $body, $headers, $param);
         }
diff --git a/create_classic_poll.php b/create_classic_poll.php
index 6e64e8f6..f39c9af3 100644
--- a/create_classic_poll.php
+++ b/create_classic_poll.php
@@ -99,10 +99,10 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
             $message = __('Mail', "This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.");
             $message .= '<br/><br/>';
             $message .= Utils::htmlEscape($_SESSION['form']->admin_name) . ' ' . __('Mail', 'hast just created a poll called') . ' : "' . Utils::htmlEscape($_SESSION['form']->title, ENT_QUOTES) . '".<br/>';
-            $message .= __('Mail', 'Thanks for filling the poll at the link above') . ' :<br/><br/>%s<br/><br/>' . __('Mail', 'Thanks for your trust.') . '<br/>' . NOMAPPLICATION;
+            $message .= __('Mail', 'Thanks for filling the poll at the link above') . ' :<br/><br/>%s';
 
             $message_admin = __('Mail', "This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above");
-            $message_admin .= ' :<br/><br/>%s<br/><br/>' . __('Mail', 'Thanks for your trust.') . '<br/>' . NOMAPPLICATION;
+            $message_admin .= ' :<br/><br/>%s';
 
             $message = sprintf($message, Utils::getUrlSondage($poll_id));
             $message_admin = sprintf($message_admin, Utils::getUrlSondage($admin_poll_id, true));
diff --git a/create_date_poll.php b/create_date_poll.php
index beb3f2a3..2cffcda6 100644
--- a/create_date_poll.php
+++ b/create_date_poll.php
@@ -97,10 +97,10 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) ||
             $message = __('Mail', "This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.");
             $message .= '<br/><br/>';
             $message .= Utils::htmlEscape($_SESSION['form']->admin_name) . ' ' . __('Mail', 'hast just created a poll called') . ' : "' . Utils::htmlEscape($_SESSION['form']->title) . '".<br/>';
-            $message .= __('Mail', 'Thanks for filling the poll at the link above') . ' :<br/><br/>%s<br/><br/>' . __('Mail', 'Thanks for your trust.') . '<br/>' . NOMAPPLICATION;
+            $message .= __('Mail', 'Thanks for filling the poll at the link above') . ' :<br/><br/>%s';
 
             $message_admin = __('Mail', "This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above");
-            $message_admin .= ' :<br/><br/>%s<br/><br/>' . __('Mail', 'Thanks for your trust.') . '<br/>' . NOMAPPLICATION;
+            $message_admin .= ' :<br/><br/>%s';
 
             $message = sprintf($message, Utils::getUrlSondage($poll_id));
             $message_admin = sprintf($message_admin, Utils::getUrlSondage($admin_poll_id, true));
diff --git a/locale/fr.json b/locale/fr.json
index 81f23b60..0161f3cf 100644
--- a/locale/fr.json
+++ b/locale/fr.json
@@ -291,7 +291,7 @@
     "updated a vote.\nYou can find your poll at the link": "vient de mettre à jour un vote.<br/>Vous pouvez retrouver votre sondage avec le lien suivant",
     "wrote a comment.\nYou can find your poll at the link": "vient de rédiger un commentaire.<br/>Vous pouvez retrouver votre sondage avec le lien suivant",
     "Thanks for your trust.": "Merci de votre confiance.",
-    "FOOTER": "<hr/><br/>« La route est longue, mais la voie est libre… »<br/>Framasoft ne vit que par vos dons (déductibles des impôts).<br/>Merci d'avance pour votre soutien http://soutenir.framasoft.org.",
+    "FOOTER": "« La route est longue, mais la voie est libre… »<br/>Framasoft ne vit que par vos dons (déductibles des impôts).<br/>Merci d'avance pour votre soutien http://soutenir.framasoft.org.",
     "[ADMINISTRATOR] New settings for your poll": "[ADMINISTRATEUR] Changement de configuration du sondage",
     "You have changed the settings of your poll. \nYou can modify this poll with this link": "Vous avez modifié la configuration de votre sondage.<br/>Vous pouvez modifier ce sondage avec le lien suivant",
     "This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.": "Ceci est le message qui doit être envoyé aux sondés.<br/>Vous pouvez maintenant transmettre ce message à toutes les personnes susceptibles de participer au vote.",
diff --git a/studs.php b/studs.php
index b13c0334..f5a1a8fe 100644
--- a/studs.php
+++ b/studs.php
@@ -81,7 +81,6 @@ function sendUpdateNotification($poll, $mailService, $name, $type) {
                 break;
         }
         $message .= Utils::getUrlSondage($poll->admin_id, true) . "\n\n";
-        $message .= __('Mail', 'Thanks for your trust.') . "\n" . NOMAPPLICATION;
 
         $mailService->send($poll->admin_mail, $subject, $message);
 
-- 
GitLab