From f319976e5df84c248123ff6ef3bba9896005a11b Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Thu, 5 Nov 2015 03:02:31 +0100
Subject: [PATCH] FIX #3878 Storing and deleting files on emailing was done at
 wrong place

Conflicts:
	htdocs/comm/mailing/card.php
---
 htdocs/comm/mailing/card.php      | 14 +++++++++++---
 htdocs/core/lib/functions.lib.php |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index b7d4f909fa7..e1d357b6c3a 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -544,7 +544,7 @@ if (empty($reshook))
 
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
-	    dol_remove_file_process($_POST['removedfile'],0);
+	    dol_remove_file_process($_POST['removedfile'],0,0);    // We really delete file linked to mailing
 
 		$action="edit";
 	}
@@ -1093,7 +1093,10 @@ else
 			}
 
 			print '</table>';
-			print "</div>";
+			
+			dol_fiche_end();
+			
+			
 
 			print "\n";
 			print '<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'."\n";
@@ -1103,6 +1106,9 @@ else
 
 			// Print mail content
 			print_fiche_titre($langs->trans("EMail"),'','');
+
+			dol_fiche_head();
+			
 			print '<table class="border" width="100%">';
 
 			// Subject
@@ -1168,7 +1174,9 @@ else
 
 			print '</table>';
 
-			print '<br><div class="center">';
+			dol_fiche_end();
+			
+			print '<div class="center">';
 			print '<input type="submit" class="button" value="'.$langs->trans("Save").'" name="save">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
 			print '<input type="submit" class="button" value="'.$langs->trans("Cancel").'" name="cancel">';
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index df6b3d325c5..8c71b882d21 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3762,7 +3762,7 @@ function get_exdir($num,$level,$alpha,$withoutslash,$object,$modulepart)
 
 	$path = '';
 
-	if (! empty($level) && in_array($modulepart, array('cheque','user','category','holiday','shipment', 'member','don','donation','supplier_invoice','invoice_supplier')))
+	if (! empty($level) && in_array($modulepart, array('cheque','user','category','holiday','shipment', 'member','don','donation','supplier_invoice','invoice_supplier','mailing')))
 	{
 		// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
 		if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
-- 
GitLab