From a5c6582bc1ad8b80d400b33a0661ad1980fb234d Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 12 Sep 2015 12:52:07 +0200
Subject: [PATCH] Fix duplicate translation/encoding on setEventMessage

Conflicts:
	htdocs/ftp/index.php
---
 dev/skeletons/skeleton_page.php    |  4 ++--
 htdocs/comm/action/card.php        |  2 +-
 htdocs/core/lib/functions.lib.php  | 15 +++++++++------
 htdocs/expensereport/card.php      |  2 +-
 htdocs/ftp/index.php               |  3 +--
 htdocs/holiday/define_holiday.php  |  6 +++---
 htdocs/projet/activity/perday.php  |  8 ++++----
 htdocs/projet/activity/perweek.php |  6 +++---
 htdocs/user/card.php               |  2 +-
 9 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php
index 3d0454f5423..2dd9f08e18f 100644
--- a/dev/skeletons/skeleton_page.php
+++ b/dev/skeletons/skeleton_page.php
@@ -152,7 +152,7 @@ if (empty($reshook))
 		if (empty($object->ref))
 		{
 			$error++;
-			setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),null,'errors');
+			setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),null,'errors');
 		}
 
 		if (! $error)
@@ -183,7 +183,7 @@ if (empty($reshook))
 		if ($result > 0)
 		{
 			// Delete OK
-			setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
+			setEventMessages("RecordDeleted", null, 'mesgs');
 			header("Location: ".dol_buildpath('/buildingmanagement/list.php',1));
 			exit;
 		}
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index b442a6266ec..8eef2b06b8b 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -407,7 +407,7 @@ if ($action == 'update')
 		if (! $datef && $percentage == 100)
 		{
 			$error++; $donotclearsession=1;
-			setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")),$object->errors,'errors');
+			setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")),$object->errors,'errors');
 			$action = 'edit';
 		}
 
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index f5dc621aaf3..4672f7a88e2 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -4385,15 +4385,17 @@ function dol_htmloutput_events()
 
 /**
  *	Get formated messages to output (Used to show messages on html output).
+ *  This include also the translation of the message key.
  *
- *	@param	string		$mesgstring		Message string
- *	@param	array		$mesgarray      Messages array
+ *	@param	string		$mesgstring		Message string or message key
+ *	@param	string[]	$mesgarray      Array of message strings or message keys
  *  @param  string		$style          Style of message output ('ok' or 'error')
  *  @param  int			$keepembedded   Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
  *	@return	string						Return html output
  *
  *  @see    dol_print_error
  *  @see    dol_htmloutput_errors
+ *  @see    setEventMessages
  */
 function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepembedded=0)
 {
@@ -4478,14 +4480,15 @@ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
 /**
  *	Print formated messages to output (Used to show messages on html output).
  *
- *	@param	string	$mesgstring		 Message
- *	@param	array	$mesgarray       Messages array
- *  @param  string	$style           Which style to use ('ok', 'warning', 'error')
- *  @param  int		$keepembedded    Set to 1 if message must be kept embedded into its html place (this disable jnotify)
+ *	@param	string		$mesgstring		Message string or message key
+ *	@param	string[]	$mesgarray      Array of message strings or message keys
+ *  @param  string      $style          Which style to use ('ok', 'warning', 'error')
+ *  @param  int         $keepembedded   Set to 1 if message must be kept embedded into its html place (this disable jnotify)
  *  @return	void
  *
  *  @see    dol_print_error
  *  @see    dol_htmloutput_errors
+ *  @see    setEventMessages
  */
 function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepembedded=0)
 {
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 1eb5d8d47ba..7220e869350 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -709,7 +709,7 @@ if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 &&
 	}
 	else
 	{
-		setEventMessages($langs->transnoentitiesnoconv("NOT_AUTHOR"), '', 'errors');
+		setEventMessages("NOT_AUTHOR", '', 'errors');
 	}
 }
 
diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php
index 4da37cde779..7a376263656 100644
--- a/htdocs/ftp/index.php
+++ b/htdocs/ftp/index.php
@@ -339,8 +339,7 @@ if ($_REQUEST['action'] == 'download')
 		}
 		else
 		{
-			//TODO: Translate
-			setEventMessage('Failed to get file '.$remotefile, 'errors');
+			setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile',$remotefile), null, 'errors');
 		}
 
 	}
diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php
index c0179c55bd0..3c5d9f40ab4 100644
--- a/htdocs/holiday/define_holiday.php
+++ b/htdocs/holiday/define_holiday.php
@@ -102,7 +102,7 @@ if ($action == 'update' && isset($_POST['update_cp']))
 		}
     }
 
-    if (! $error) setEventMessages($langs->trans('UpdateConfCPOK'), '', 'mesgs');
+    if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
 }
 elseif($action == 'add_event')
 {
@@ -122,7 +122,7 @@ elseif($action == 'add_event')
 
     if ($error)
     {
-	    setEventMessages($langs->trans('ErrorAddEventToUserCP'), '', 'errors');
+	    setEventMessages('ErrorAddEventToUserCP', '', 'errors');
     }
     else
 	{
@@ -135,7 +135,7 @@ elseif($action == 'add_event')
 
         $holiday->updateSoldeCP($userCP,$new_holiday);
 
-		setEventMessages($langs->trans('AddEventToUserOkCP'), '', 'mesgs');
+		setEventMessages('AddEventToUserOkCP', '', 'mesgs');
     }
 }
 
diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index f8e106a7e7e..93305dbc63c 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -96,12 +96,12 @@ if ($action == 'assign')
     }
     else
     {
-    	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
+    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
     	$error++;
     }
     if (! GETPOST('type'))
     {
-    	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
+    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
     	$error++;
     }
     if (! $error)
@@ -126,7 +126,7 @@ if ($action == 'assign')
 
 	if (! $error)
 	{
-		setEventMessages($langs->trans("TaskAssignedToEnterTime"), null);
+		setEventMessages("TaskAssignedToEnterTime", null);
 	}
 
 	$action='';
@@ -180,7 +180,7 @@ if ($action == 'addtime' && $user->rights->projet->creer)
 			}
 			else
 			{
-				setEventMessages($langs->trans("ErrorBadDate"), null, 'errors');
+				setEventMessages("ErrorBadDate", null, 'errors');
 				$error++;
 				break;
 			}
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index 619803ecbc3..6201c601d18 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -108,12 +108,12 @@ if ($action == 'assign')
     }
     else
     {
-    	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
+    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
     	$error++;
     }
     if (! GETPOST('type'))
     {
-    	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
+    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
     	$error++;
     }
     if (! $error)
@@ -138,7 +138,7 @@ if ($action == 'assign')
 
 	if (! $error)
 	{
-		setEventMessages($langs->trans("TaskAssignedToEnterTime"), null);
+		setEventMessages("TaskAssignedToEnterTime", null);
 	}
 
 	$action='';
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index 79c4a123022..f545e325712 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -482,7 +482,7 @@ if ($action == 'update' && ! $_POST["cancel"])
                     {
                     	$error++;
                     	$langs->load("errors");
-                    	setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
+                    	setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
                     }
                 }
             }
-- 
GitLab