From 76d0286401651d3b0fdd62a115965c6d1ffc595b Mon Sep 17 00:00:00 2001
From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr>
Date: Wed, 16 Dec 2020 16:08:51 +0100
Subject: [PATCH] hotline#123836 : mail subject of sent answers from forms are
 customized by form

---
 VERSIONS_HOTLINE/123836                                     | 1 +
 .../modules/opac/controllers/FormulaireController.php       | 6 +++---
 .../modules/opac/controllers/FormulaireControllerTest.php   | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/123836

diff --git a/VERSIONS_HOTLINE/123836 b/VERSIONS_HOTLINE/123836
new file mode 100644
index 00000000000..c77bdd5e1a7
--- /dev/null
+++ b/VERSIONS_HOTLINE/123836
@@ -0,0 +1 @@
+ - ticket #123836 : Pouvoir personnaliser l'objet des mails envoyés par formulaire
\ No newline at end of file
diff --git a/application/modules/opac/controllers/FormulaireController.php b/application/modules/opac/controllers/FormulaireController.php
index 822c42455f7..cc16abf59ab 100644
--- a/application/modules/opac/controllers/FormulaireController.php
+++ b/application/modules/opac/controllers/FormulaireController.php
@@ -46,17 +46,17 @@ class FormulaireController extends ZendAfi_Controller_Action {
     $this->view->article = $article;
 
     if ($address = $article->getDestinationEmail()) {
-      $this->_sendFormEmail($address, $formulaire->dataAsBodyText());
+      $this->_sendFormEmail($address, $formulaire->dataAsBodyText(), $article->getTitre());
       $this->view->email_sent = true;
     }
   }
 
 
-  protected function _sendFormEmail($address, $body) {
+  protected function _sendFormEmail($address, $body, $subject) {
     $mail = new ZendAfi_Mail('utf8');
     $mail->setFrom(Class_Profil::getCurrentProfil()->getMailSiteOrPortail())
          ->addTo($address)
-         ->setSubject('[Bokeh] ' . $this->_('Envoi d\'un formulaire'))
+         ->setSubject('[ '.Class_Profil::getPortail()->getLibelle().' ] '. $this->_('Réponse formulaire :').' '.$subject)
          ->setBodyText($body);
 
     $this->_sendMail($mail);
diff --git a/tests/application/modules/opac/controllers/FormulaireControllerTest.php b/tests/application/modules/opac/controllers/FormulaireControllerTest.php
index 7d16714b713..37ec8f9aa8b 100644
--- a/tests/application/modules/opac/controllers/FormulaireControllerTest.php
+++ b/tests/application/modules/opac/controllers/FormulaireControllerTest.php
@@ -104,7 +104,7 @@ class FormulaireControllerWithEmailPostActionTest extends FormulaireControllerPo
 
   /** @test */
   public function emailSubjectShouldBeFormSent() {
-    $this->assertEquals('[Bokeh] Envoi d\'un formulaire', $this->mock_transport->getSentMails()[0]->getSubject());
+    $this->assertContains('[ portail ] Réponse formulaire : Contactez nous', quoted_printable_decode($this->mock_transport->getSentMails()[0]->getSubject()));
   }
 }
 
-- 
GitLab