diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php
index d60144a3492..6d92ad21999 100644
--- a/htdocs/admin/commande.php
+++ b/htdocs/admin/commande.php
@@ -182,7 +182,7 @@ else if ($action == 'setdoc')
else if ($action == 'setmod')
{
- // TODO Check if numbering module chosen can be activated
+ // TODO Check if numbering module chosen can be activated
// by calling method canBeActivated
dolibarr_set_const($db, "COMMANDE_ADDON",$value,'chaine',0,'',$conf->entity);
@@ -331,7 +331,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
-
+
print '
'.$module->nom." \n";
print $module->info();
print ' ';
@@ -609,7 +609,7 @@ print " \n";
print '';
// Shippable Icon in List
-/* Kept as hidden feature for the moment, result seems bugged.
+/* Kept as hidden feature for the moment, result seems bugged.
Whet is definition of "shippable" according to all different STOCK_CALCULATE_... options ?
print '';
@@ -631,7 +631,7 @@ print ' ';
// Ask for payment bank during order
if ($conf->banque->enabled)
{
-
+
print '';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'   ';
if (! empty($conf->use_javascript_ajax))
@@ -653,7 +653,7 @@ if ($conf->banque->enabled)
}
else
{
-
+
print ' ';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").' '.$langs->trans('NotAvailable').' ';
}
@@ -661,7 +661,7 @@ else
// Ask for warehouse during order
if ($conf->stock->enabled)
{
-
+
print '';
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'   ';
if (! empty($conf->use_javascript_ajax))
@@ -683,7 +683,7 @@ if ($conf->stock->enabled)
}
else
{
-
+
print ' ';
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '.$langs->trans('NotAvailable').' ';
}
diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php
index 4c0a9572761..47e53a05048 100644
--- a/htdocs/admin/contract.php
+++ b/htdocs/admin/contract.php
@@ -265,7 +265,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
-
+
print ''.$module->nom." \n";
print $module->info();
print ' ';
diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index 40e63de8aea..10d9ec5c282 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -120,11 +120,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
$error++;
}
}
-
+
if (! $error)
{
$db->begin();
-
+
if ($action == 'add' || (GETPOST('add') && $action != 'update'))
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
@@ -134,7 +134,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
$sql.= " WHERE rowid = ".$id;
}
-
+
$result = $db->query($sql);
if ($result > 0)
{
@@ -223,7 +223,7 @@ print ' ';
print ' ';
$head=defaultvalues_prepare_head();
-
+
dol_fiche_head($head, $mode, '', -1, '');
if ($mode == 'sortorder')
@@ -249,11 +249,11 @@ $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp);
print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder);
// Field
$texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField");
-if ($mode != 'sortorder')
+if ($mode != 'sortorder')
{
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
}
-else
+else
{
$texthelp='field or alias.field';
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
@@ -264,22 +264,14 @@ if ($mode != 'focus')
{
if ($mode != 'sortorder')
{
+ $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
+ $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").' ';
- // See list into GETPOST
- $texthelp.='__USERID__ ';
- $texthelp.='__SUPERVISORID__ ';
- $texthelp.='__MYCOUNTRYID__ ';
- $texthelp.='__DAY__ ';
- $texthelp.='__MONTH__ ';
- $texthelp.='__YEAR__ ';
- $texthelp.='__PREVIOUS_DAY__ ';
- $texthelp.='__PREVIOUS_MONTH__ ';
- $texthelp.='__PREVIOUS_YEAR__ ';
- $texthelp.='__NEXT_DAY__ ';
- $texthelp.='__NEXT_MONTH__ ';
- $texthelp.='__NEXT_YEAR__ ';
- if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__ ';
- $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, '');
+ foreach($substitutionarray as $key => $val)
+ {
+ $texthelp.=$key.' ';
+ }
+ $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
}
else
{
@@ -351,18 +343,18 @@ if ($result)
while ($i < $num)
{
$obj = $db->fetch_object($result);
-
+
print "\n";
print '';
-
+
// Page
print '';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page;
else print ' ';
print ' '."\n";
-
+
// Field
print '';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param;
@@ -382,7 +374,7 @@ if ($result)
else print ' ';
print ' ';
}
-
+
// Actions
print '';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
@@ -400,7 +392,7 @@ if ($result)
print ' ';
}
print ' ';
-
+
print " \n";
print "\n";
$i++;
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index 3c89960ede6..e9a9aaedb18 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -82,7 +82,7 @@ else if ($action == 'set_param')
$error++;
setEventMessages($langs->trans("Error"), null, 'errors');
}
-
+
$draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if ($res <= 0)
diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php
index eefe5747abd..92ba9375927 100644
--- a/htdocs/admin/expensereport.php
+++ b/htdocs/admin/expensereport.php
@@ -77,7 +77,7 @@ else if ($action == 'specimen') // For fiche inter
$inter->initAsSpecimen();
$inter->status = 0; // Force statut draft to show watermark
$inter->fk_statut = 0; // Force statut draft to show watermark
-
+
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
@@ -193,13 +193,13 @@ else if ($action == 'setmod')
else if ($action == 'setoptions')
{
$db->begin();
-
+
$freetext= GETPOST('EXPENSEREPORT_FREE_TEXT'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
-
+
$draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK','alpha');
$res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
-
+
if (! $res1 > 0 || ! $res2 > 0) $error++;
if (! $error)
@@ -276,7 +276,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
+
print ''.$module->nom." \n";
print $module->info();
print ' ';
@@ -399,7 +399,7 @@ foreach ($dirmodels as $reldir)
if (file_exists($dir.'/'.$file))
{
-
+
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 77230dc3f68..64ae1abdde6 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -693,7 +693,7 @@ if ($resql)
$i = 0;
while ($i < $num)
{
-
+
$row = $db->fetch_row($resql);
print 'version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
+
print ''.$module->nom." \n";
print $module->info();
print ' ';
@@ -432,7 +432,7 @@ foreach ($dirmodels as $reldir)
{
if (file_exists($dir.'/'.$file))
{
-
+
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 7c23b62f230..f764f40c054 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -90,11 +90,11 @@ if ($action == 'update')
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'),'chaine',0,'',$conf->entity);
-
+
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val,'chaine',0,'',$conf->entity);
-
+
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val,'chaine',0,'',$conf->entity);
@@ -109,25 +109,25 @@ if ($action == 'update')
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val,'chaine',0,'',$conf->entity);
-
+
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity);
-
+
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity);
-
+
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity);
-
+
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
@@ -137,7 +137,7 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
-
+
dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
@@ -150,7 +150,7 @@ if ($action == 'update')
if (preg_match('/([^\\/:]+)$/i',$_FILES[$varforimage]["name"],$reg))
{
$original_file=$reg[1];
-
+
$isimage=image_format_supported($original_file);
if ($isimage >= 0)
{
@@ -185,9 +185,9 @@ if ($action == 'update')
}
}
}
-
-
-
+
+
+
$_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
@@ -222,7 +222,7 @@ if ($action == 'edit') // Edit
print ' ';
clearstatcache();
-
+
print ' ';
print '';
print ''.$langs->trans("Language").' ';
@@ -264,7 +264,7 @@ if ($action == 'edit') // Edit
print ''.$langs->trans("DefaultMaxSizeShortList").' ';
print ' ';
print ' ';
-
+
// show input border
/*
print ''.$langs->trans("showInputBorder").' ';
@@ -273,7 +273,7 @@ if ($action == 'edit') // Edit
print ' ';
print ' ';
*/
-
+
// Disable javascript and ajax
print ''.$langs->trans("DisableJavascript").' ';
print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
@@ -323,17 +323,17 @@ if ($action == 'edit') // Edit
print ' ';
print ' ';
print ' ';
-
+
// Hide version link
/*
-
+
print ''.$langs->trans("HideVersionLink").' ';
print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1);
print ' ';
print ' ';
print ' ';
*/
-
+
// Show bugtrack link
print ''.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).' ';
print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK',$conf->global->MAIN_BUGTRACK_ENABLELINK,1);
@@ -349,7 +349,19 @@ if ($action == 'edit') // Edit
print ' ';
// Message of the day on home page
- print ''.$langs->trans("MessageOfDay").' ';
+ $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object'));
+ complete_substitutions_array($substitutionarray, $langs);
+ $substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
+
+ print ' ';
+ $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").' ';
+ foreach($substitutionarray as $key => $val)
+ {
+ $texthelp.=$key.' ';
+ }
+ print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, '');
+
+ print ' ';
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create();
@@ -359,26 +371,36 @@ if ($action == 'edit') // Edit
print '
'."\n";
print ' ';
-
+
// Other
print '';
print ''.$langs->trans("LoginPage").' ';
print ' ';
print ' ';
-
+
// Message on login page
- print ''.$langs->trans("MessageLogin").' ';
+ $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','user'));
+ complete_substitutions_array($substitutionarray, $langs);
+ $substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
+ print ' ';
+ $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").' ';
+ foreach($substitutionarray as $key => $val)
+ {
+ $texthelp.=$key.' ';
+ }
+ print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, '');
+ print ' ';
$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create();
print ' '."\n";
-
+
// Hide helpcenter link on login page
print ''.$langs->trans("DisableLinkToHelpCenter").' ';
print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK',isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0,1);
print ' ';
print ' ';
print ' ';
-
+
// Background
print ''.$langs->trans("BackgroundImageLogin").' (png,jpg) ';
print '';
@@ -394,9 +416,9 @@ if ($action == 'edit') // Edit
}
print '
';
print ' ';
-
+
print '
'."\n";
-
+
print '';
print ' ';
@@ -421,7 +443,7 @@ else // Show
if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
print '';
print "
";
-
+
print ''.$langs->trans("EnableMultilangInterface").' ' . yn($conf->global->MAIN_MULTILANGS) . ' ';
print ' ';
print " ";
@@ -441,7 +463,7 @@ else // Show
print ''.$langs->trans("DefaultMaxSizeList").' ' . $conf->global->MAIN_SIZE_LISTE_LIMIT . ' ';
print ' ';
print " ";
-
+
print ''.$langs->trans("DefaultMaxSizeShortList").' ' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . ' ';
print ' ';
print " ";
@@ -452,7 +474,7 @@ else // Show
print ' ';
print " ";
*/
-
+
// Disable javascript/ajax
print ''.$langs->trans("DisableJavascript").' ';
print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)." ";
@@ -506,7 +528,7 @@ else // Show
print ' ';
print ' ';
*/
-
+
// Show bugtrack link
print ''.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).' ';
print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)." ";
@@ -527,7 +549,7 @@ else // Show
print ''."\n";
print ' ';
-
+
// Login page
print '';
print ''.$langs->trans("LoginPage").' ';
@@ -537,7 +559,7 @@ else // Show
if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
else print ' ';
print ''."\n";
-
+
// Link to help center
print ''.$langs->trans("DisableLinkToHelpCenter").' ';
print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
@@ -557,9 +579,9 @@ else // Show
}
print '';
print ' ';
-
+
print '
'."\n";
-
+
print '';
diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php
index 74081266f43..cf97b397e44 100644
--- a/htdocs/admin/livraison.php
+++ b/htdocs/admin/livraison.php
@@ -259,7 +259,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
+
print ''.$module->nom." \n";
print $module->info();
print ' ';
@@ -386,7 +386,7 @@ foreach ($dirmodels as $reldir)
{
if (file_exists($dir.'/'.$file))
{
-
+
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index caea3bef9f7..3711b346585 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -59,8 +59,8 @@ $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
$actl[1] = img_picto($langs->trans("Activated"),'switch_on');
-$listoffset=GETPOST('listoffset');
-$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
+$listoffset=GETPOST('listoffset','alpha');
+$listlimit=GETPOST('listlimit','alpha')>0?GETPOST('listlimit','alpha'):1000;
$active = 1;
$sortfield = GETPOST("sortfield",'alpha');
@@ -119,14 +119,14 @@ $formmail=new FormMail($db);
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
$tmp=FormMail::getAvailableSubstitKey('formemail');
- $tmp['__(AnyTransKey)__']='__(AnyTransKey)__';
+ $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").': '.implode(' ', $tmp);
$helpsubstitforlines = $langs->trans("AvailableVariables").': '.implode(' ', $tmp);
}
else
{
$tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
- $tmp['__(AnyTransKey)__']='__(AnyTransKey)__';
+ $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").': '.implode(' ', $tmp);
$tmp=FormMail::getAvailableSubstitKey('formemailforlines');
$helpsubstitforlines = $langs->trans("AvailableVariables").': '.implode(' ', $tmp);
@@ -175,7 +175,7 @@ $id = 25;
if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
{
- //$search_country_id = '';
+ //$search_country_id = '';
}
// Actions add or modify an entry into a dictionary
@@ -479,12 +479,12 @@ if ($action != 'edit')
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
if ($fieldlist[$field]=='content') { $valuetoshow=''; }
if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; }
-
+
if ($valuetoshow != '')
{
print '';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1,$valuetoshow).' ';
- else if (! empty($tabhelp[$id][$value]))
+ else if (! empty($tabhelp[$id][$value]))
{
if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
@@ -494,15 +494,15 @@ if ($action != 'edit')
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
}
-
+
print ' ';
print ' ';
print ' ';
print ' ';
-
+
// Line to enter new values
print "";
-
+
$obj = new stdClass();
// If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd'))
@@ -513,12 +513,12 @@ if ($action != 'edit')
$obj->$val=GETPOST($val);
}
}
-
+
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
-
+
if (empty($reshook))
{
if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit')
@@ -530,11 +530,11 @@ if ($action != 'edit')
fieldList($fieldlist,$obj,$tabname[$id],'add');
}
}
-
+
print '';
print ' ';
print " ";
-
+
$fieldsforcontent = array('content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
@@ -545,7 +545,7 @@ if ($action != 'edit')
print '';
if ($tmpfieldlist == 'content') print ''.$form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' ';
if ($tmpfieldlist == 'content_lines') print ''.$form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' ';
-
+
if ($context != 'hide')
{
//print '';
@@ -556,7 +556,7 @@ if ($action != 'edit')
}
else print ' ';
print ' ';
- if ($tmpfieldlist == 'content')
+ if ($tmpfieldlist == 'content')
{
print '';
if ($action != 'edit')
@@ -568,12 +568,12 @@ if ($action != 'edit')
//else print ' ';
print ' ';
}
-
-
-
+
+
+
$colspan=count($fieldlist)+1;
print ' '; // Keep to have a line with enough height
-}
+}
// List of available record in database
@@ -590,7 +590,7 @@ if ($resql)
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
-
+
// There is several pages
if ($num > $listlimit)
{
@@ -628,7 +628,7 @@ if ($resql)
// Affiche nom du champ
if ($showfield)
{
- if (! empty($tabhelp[$id][$value]))
+ if (! empty($tabhelp[$id][$value]))
{
if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
@@ -653,7 +653,7 @@ if ($resql)
print ' ';
print ' ';
print '';
-
+
if ($num)
{
// Lines with values
@@ -680,7 +680,7 @@ if ($resql)
print '
';
print ' ';
print '';
-
+
$fieldsforcontent = array('content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
@@ -691,11 +691,11 @@ if ($resql)
$showfield = 1;
$align = "left";
$valuetoshow = $obj->{$tmpfieldlist};
-
+
$class = 'tddict';
// Show value for field
if ($showfield) {
-
+
print ''; // To create an artificial CR for the current tr we are on
$okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
@@ -704,9 +704,9 @@ if ($resql)
print $doleditor->Create(1);
print ' ';
print ' ';
-
+
}
- }
+ }
}
else
{
@@ -778,16 +778,16 @@ if ($resql)
{
$fieldsforcontent = array('content', 'content_lines');
}
- foreach ($fieldsforcontent as $tmpfieldlist)
+ foreach ($fieldsforcontent as $tmpfieldlist)
{
$showfield = 1;
$align = "left";
$valuetoshow = $obj->{$tmpfieldlist};
-
+
$class = 'tddict';
// Show value for field
if ($showfield) {
-
+
print ''; // To create an artificial CR for the current tr we are on
$okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
@@ -796,13 +796,13 @@ if ($resql)
print $doleditor->Create(1);
print ' ';
print ' ';
-
+
}
}*/
}
print " \n";
-
-
+
+
$i++;
}
}
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index 7c8413a28a6..e0dc1d3b5b4 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -310,7 +310,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
-
+
print ''.$module->nom." \n";
print $module->info();
print ' ';
@@ -614,7 +614,7 @@ print '';
/* Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
if ($conf->banque->enabled)
{
-
+
print '';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'   ';
if (! empty($conf->use_javascript_ajax))
@@ -636,7 +636,7 @@ if ($conf->banque->enabled)
}
else
{
-
+
print ' ';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").' '.$langs->trans('NotAvailable').' ';
}
diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php
index d408657ac8c..549bb93809b 100644
--- a/htdocs/admin/supplier_invoice.php
+++ b/htdocs/admin/supplier_invoice.php
@@ -251,7 +251,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
+
print ''.$module->nom." \n";
print $module->info();
print ' ';
@@ -370,7 +370,7 @@ foreach ($dirmodels as $reldir)
{
while (($file = readdir($handle))!==false)
{
- if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
+ if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
@@ -378,7 +378,7 @@ foreach ($dirmodels as $reldir)
require_once $dir.'/'.$file;
$module = new $classname($db, new FactureFournisseur($db));
-
+
print "\n";
print "";
print (empty($module->name)?$name:$module->name);
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index acce3a38c7c..55e4e4b3d07 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -280,7 +280,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
+
print ' '.$module->nom." \n";
print $module->info();
print ' ';
@@ -402,7 +402,7 @@ foreach ($dirmodels as $reldir)
require_once $dir.'/'.$file;
$module = new $classname($db, new CommandeFournisseur($db));
-
+
print "\n";
print "";
print (empty($module->name)?$name:$module->name);
@@ -502,14 +502,14 @@ $var=false;
print ' ';
print ' ';
print " \n";
-
+
//}
// Ask for payment bank during supplier order
/* Kept as hidden for the moment
if ($conf->banque->enabled)
{
-
+
print '';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").'   ';
if (! empty($conf->use_javascript_ajax))
@@ -531,7 +531,7 @@ if ($conf->banque->enabled)
}
else
{
-
+
print ' ';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '.$langs->trans('NotAvailable').' ';
}
diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php
index 8a8d2a181a4..82eeddd594c 100644
--- a/htdocs/admin/supplier_proposal.php
+++ b/htdocs/admin/supplier_proposal.php
@@ -289,7 +289,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
-
+
print ''.$module->nom." \n";
print $module->info();
print ' ';
@@ -567,7 +567,7 @@ print '';
if ($conf->banque->enabled)
{
-
+
print '';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").'   ';
if (! empty($conf->use_javascript_ajax))
@@ -589,7 +589,7 @@ if ($conf->banque->enabled)
}
else
{
-
+
print ' ';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').' ';
}
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 3641ac87cef..a8d6d64c45c 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -155,7 +155,7 @@ class FormMail extends Form
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
-
+
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
@@ -182,7 +182,7 @@ class FormMail extends Form
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
-
+
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
@@ -209,7 +209,7 @@ class FormMail extends Form
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
-
+
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
@@ -266,13 +266,13 @@ class FormMail extends Form
$out='';
$disablebademails=1;
-
+
// Define list of attached files
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
-
+
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
@@ -415,7 +415,7 @@ class FormMail extends Form
{
$posalias++;
$listaliasval=trim($listaliasval);
- if ($listaliasval)
+ if ($listaliasval)
{
$listaliasval=preg_replace('/', '<', $listaliasval);
$listaliasval=preg_replace('/>/', '>', $listaliasval);
@@ -720,7 +720,7 @@ class FormMail extends Form
$this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url));
}
}
-
+
//Add lines substitution key from each line
$lines = '';
$defaultlines = $arraydefaultmessage['content_lines'];
@@ -979,14 +979,14 @@ class FormMail extends Form
return -1;
}
}
-
-
-
+
+
+
/**
* Set substit array from object
- *
+ *
* @param CommonObject $object Object to use
- * @param Translate $outputlangs Object lang
+ * @param Translate $outputlangs Object lang
* @return void
*/
function setSubstitFromObject($object, $outputlangs=null)
@@ -1001,14 +1001,14 @@ class FormMail extends Form
$this->substit['__AMOUNT__'] = price($object->total_ttc);
$this->substit['__AMOUNT_WO_TAX__'] = price($object->total_ht);
$this->substit['__AMOUNT_VAT__'] = price($object->total_tva);
-
+
$this->substit['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:'');
$this->substit['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:'');
-
+
$this->substit['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:'');
$this->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:'');
$this->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:'');
-
+
$this->substit['__SIGNATURE__'] = $user->signature;
$this->substit['__PERSONALIZED__'] = '';
$this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending
@@ -1020,7 +1020,7 @@ class FormMail extends Form
foreach ($extrafields->attribute_label as $key => $label) {
$this->substit['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
}
-
+
//Fill substit_lines with each object lines content
if (is_array($object->lines))
{
@@ -1057,36 +1057,37 @@ class FormMail extends Form
}
}
}
-
+
/**
- * Get list of substition keys available.
- *
+ * Get list of substition keys available for emails.
+ * This include the complete_substitutions_array. TODO Include the getCommonSubstitutionArray().
+ *
* @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ...
- * @return void
+ * @return array Array of substitution values for emails.
*/
static function getAvailableSubstitKey($mode='formemail')
{
global $conf, $langs;
-
+
$vars=array();
-
+
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines')
{
$vars=array(
- '__REF__',
- '__REFCLIENT__',
- '__REFSUPPLIER__',
- '__THIRDPARTY_ID__',
- '__THIRDPARTY_NAME__',
- '__PROJECT_ID__',
- '__PROJECT_REF__',
+ '__REF__',
+ '__REFCLIENT__',
+ '__REFSUPPLIER__',
+ '__THIRDPARTY_ID__',
+ '__THIRDPARTY_NAME__',
+ '__PROJECT_ID__',
+ '__PROJECT_REF__',
'__PROJECT_NAME__',
'__CONTACTCIVNAME__',
- '__AMOUNT__',
- '__AMOUNT_WO_TAX__',
- '__AMOUNT_VAT__',
+ '__AMOUNT__',
+ '__AMOUNT_WO_TAX__',
+ '__AMOUNT_VAT__',
'__PERSONALIZED__', // Paypal link will be added here in form mode
- '__SIGNATURE__',
+ '__SIGNATURE__',
);
if ($mode == 'formwithlines')
{
@@ -1127,21 +1128,21 @@ class FormMail extends Form
if ($conf->contrat->enabled) $vars['__SECUREKEYPAYPAL_CONTRACTLINE__']='SecureKeyPaypalUniquePerContractLine';
}
}
- else
+ else
{
$vars['__SECUREKEYPAYPAL__']='';
$vars['__SECUREKEYPAYPAL_MEMBER__']='';
}
}
-
- $tmparray=array();
+
$parameters=array('mode'=>$mode);
+ $tmparray=getCommonSubstitutionArray($langs);
complete_substitutions_array($tmparray, $langs, null, $parameters);
foreach($tmparray as $key => $val)
{
$vars[$key]=$key;
}
-
+
return $vars;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index bd2944fa2f4..a18b9e14110 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5014,8 +5014,100 @@ function dol_concatdesc($text1,$text2,$forxml=false)
return $ret;
}
+
/**
- * Make substition into a string replacing key with vals from $substitutionarray (oldval=>newval)
+ * Return array of possible common substitutions.
+ *
+ * @param Translate $outputlangs Output language
+ * @param int $onlykey Do not calculate heavy values of keys (performance enhancement when we need only the keys)
+ * @param array $exclude Array of family keys we want to exclude. For example array('mycompany', 'object', 'date', 'user', ...)
+ * @param Object $object Object for keys on object
+ * @return array Array of substitutions
+ */
+function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
+{
+ global $conf, $mysoc, $user;
+
+ $substitutionarray=array();
+
+ if (empty($exclude) || ! in_array('mycompany', $exclude))
+ {
+ $substitutionarray=array_merge($substitutionarray, array(
+ '__MYCOMPANY_NAME__' => $mysoc->name,
+ '__MYCOMPANY_EMAIL__' => $mysoc->email,
+ '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
+ '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
+ '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
+ '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
+ '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
+ '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
+ '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
+ '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id
+ ));
+ }
+ if (empty($exclude) || ! in_array('object', $exclude))
+ {
+ if (is_object($object)) // For backward compatibility
+ {
+ $substitutionarray['__TOTAL_TTC__'] =is_object($object)?$object->total_ttc:'';
+ $substitutionarray['__TOTAL_HT__'] =is_object($object)?$object->total_ht:'';
+ $substitutionarray['__TOTAL_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
+ }
+ $substitutionarray['__AMOUNT__'] =is_object($object)?$object->total_ttc:'';
+ $substitutionarray['__AMOUNT_WO_TAX__']=is_object($object)?$object->total_ht:'';
+ $substitutionarray['__AMOUNT_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
+ }
+
+ if (empty($exclude) || ! in_array('date', $exclude))
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+
+ if (! empty($onlykey))
+ {
+ $tmp=$tmp2=$tmp3=$tmp4=$tmp5=array();
+ }
+ else
+ {
+ $tmp=dol_getdate(dol_now(), true);
+ $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
+ $tmp3=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']);
+ $tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
+ $tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']);
+ }
+ $substitutionarray=array_merge($substitutionarray, array(
+ '__DAY__' => $tmp['mday'],
+ '__MONTH__' => $tmp['mon'],
+ '__YEAR__' => $tmp['year'],
+ '__PREVIOUS_DAY__' => $tmp2['day'],
+ '__PREVIOUS_MONTH__' => $tmp3['month'],
+ '__PREVIOUS_YEAR__' => ($tmp['year'] - 1),
+ '__NEXT_DAY__' => $tmp4['day'],
+ '__NEXT_MONTH__' => $tmp5['month'],
+ '__NEXT_YEAR__' => ($tmp['year'] + 1),
+ ));
+ }
+
+ if (empty($exclude) || ! in_array('user', $exclude))
+ {
+ $substitutionarray=array_merge($substitutionarray, array(
+ '__USER_ID__' => $user->id,
+ '__USER_LOGIN__' => $user->login,
+ '__USER_LASTNAME__' => $user->lastname,
+ '__USER_FIRSTNAME__' => $user->firstname,
+ '__USER_FULLNAME__' => $user->getFullName($outputlangs),
+ '__USER_SUPERVISOR_ID__' => $user->fk_user
+ ));
+ }
+ if (! empty($conf->multicompany->enabled))
+ {
+ $substitutionarray=array_merge($substitutionarray, array('__ENTITY_ID__' => $conf->entity));
+ }
+
+ return $substitutionarray;
+}
+
+/**
+ * Make substition into a text string, replacing keys with vals from $substitutionarray (oldval=>newval).
*
* @param string $text Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute
@@ -5034,11 +5126,16 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
// Make substitution for language keys
if (is_object($outputlangs))
{
- while (preg_match('/__\((.*)\)__/', $text, $reg))
+ while (preg_match('/__\(([^\)]*)\)__/', $text, $reg))
{
+ // If key is __(TranslationKey|langfile)__, then force load of langfile.lang
+ $tmp=explode('|',$reg[1]);
+ if (! empty($tmp[1])) $outputlangs->load($tmp[1]);
+
$msgishtml = 0;
if (dol_textishtml($text,1)) $msgishtml = 1;
- $text = preg_replace('/__\('.preg_quote($reg[1]).'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
+
+ $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
}
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index e83faee6c8d..8c48e2301e3 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -588,38 +588,25 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
/**
- * Return array of possible substitutions
+ * Return array of possible substitutions for PDF content (without external module substitutions).
*
* @param Translate $outputlangs Output language
+ * @param Object $object Object
* @return array Array of substitutions
*/
-function pdf_getSubstitutionArray($outputlangs)
+function pdf_getSubstitutionArray($outputlangs, $object=null)
{
- global $conf, $mysoc, $user;
- $substitutionarray=array(
- '__MYCOMPANY_NAME__' => $mysoc->name,
- '__MYCOMPANY_EMAIL__' => $mysoc->email,
- '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
- '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
- '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
- '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
- '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
- '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
- '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
- '__USER_ID__' => $user->id,
- '__USER_LOGIN__' => $user->login,
- '__USER_LASTNAME__' => $user->lastname,
- '__USER_FIRSTNAME__' => $user->firstname,
- '__USER_FULLNAME__' => $user->getFullName($outputlangs)
- );
- return $substitutionarray;
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ $substitutionarray['__FROM_NAME__']='__FROM_NAME__';
+ $substitutionarray['__FROM_EMAIL__']='__FROM_EMAIL__';
+ return $substitutionarray;
}
/**
* Add a draft watermark on PDF files
*
- * @param TCPDF $pdf Object PDF
+ * @param TCPDF $pdf Object PDF
* @param Translate $outputlangs Object lang
* @param int $h Height of PDF
* @param int $w Width of PDF
@@ -630,7 +617,7 @@ function pdf_getSubstitutionArray($outputlangs)
function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
{
global $langs, $mysoc, $user;
-
+
// Print Draft Watermark
if ($unit=='pt') $k=1;
elseif ($unit=='mm') $k=72/25.4;
@@ -638,11 +625,11 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
elseif ($unit=='in') $k=72;
// Make substitution
- $substitutionarray=pdf_getSubstitutionArray($outputlangs);
- complete_substitutions_array($substitutionarray,$outputlangs,$object);
+ $substitutionarray=pdf_getSubstitutionArray($outputlangs,null);
+ complete_substitutions_array($substitutionarray,$outputlangs,null);
$text=make_substitutions($text,$substitutionarray,$outputlangs);
$text=$outputlangs->convToOutputCharset($text);
-
+
$savx=$pdf->getX(); $savy=$pdf->getY();
$watermark_angle=atan($h/$w)/2;
@@ -867,13 +854,10 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
// Line of free text
if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext))
{
- $substitutionarray=pdf_getSubstitutionArray($outputlangs);
+ $substitutionarray=pdf_getSubstitutionArray($outputlangs, $object);
// More substitution keys
$substitutionarray['__FROM_NAME__']=$fromcompany->name;
$substitutionarray['__FROM_EMAIL__']=$fromcompany->email;
- $substitutionarray['__TOTAL_TTC__']=$object->total_ttc;
- $substitutionarray['__TOTAL_HT__']=$object->total_ht;
- $substitutionarray['__TOTAL_VAT__']=$object->total_vat;
complete_substitutions_array($substitutionarray,$outputlangs,$object);
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray,$outputlangs);
$line.=$outputlangs->convToOutputCharset($newfreetext);
@@ -1289,16 +1273,16 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
if (empty($hideref))
{
- if ($issupplierline)
+ if ($issupplierline)
{
if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1)
$ref_prodserv = $ref_supplier;
elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2)
- $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
- else
+ $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
+ else
$ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')';
}
- else
+ else
$ref_prodserv = $prodser->ref; // Show local ref only
if (! empty($libelleproduitservice)) $ref_prodserv .= " - ";
diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php
index 3f41e74b7f6..d20b9612b5f 100644
--- a/htdocs/core/lib/security2.lib.php
+++ b/htdocs/core/lib/security2.lib.php
@@ -265,15 +265,11 @@ function dol_loginfunction($langs,$conf,$mysoc)
$main_home='';
if (! empty($conf->global->MAIN_HOME))
{
- $i=0;
- while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_HOME,$reg) && $i < 100)
- {
- $tmp=explode('|',$reg[1]);
- if (! empty($tmp[1])) $langs->load($tmp[1]);
- $conf->global->MAIN_HOME=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_HOME);
- $i++;
- }
- $main_home=dol_htmlcleanlastbr($conf->global->MAIN_HOME);
+ $substitutionarray=getCommonSubstitutionArray($langs);
+ complete_substitutions_array($substitutionarray, $langs);
+ $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs);
+
+ $main_home=dol_htmlcleanlastbr($texttoshow);
}
// Google AD
@@ -415,7 +411,7 @@ function encodedecode_dbpassconf($level=0)
fflush($fp);
fclose($fp);
clearstatcache();
-
+
// It's config file, so we set read permission for creator only.
// Should set permission to web user and groups for users used by batch
//@chmod($file, octdec('0600'));
diff --git a/htdocs/index.php b/htdocs/index.php
index d2da24471d8..5303587150e 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -77,7 +77,7 @@ if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$langs->trans("HomeAr
llxHeader('',$title);
-
+
$resultboxes=FormOther::getBoxesArea($user,"0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
@@ -88,18 +88,13 @@ if (! empty($conf->global->MAIN_MOTD))
$conf->global->MAIN_MOTD=preg_replace('/ /i',' ',$conf->global->MAIN_MOTD);
if (! empty($conf->global->MAIN_MOTD))
{
- $i=0;
- while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_MOTD,$reg) && $i < 100)
- {
- $tmp=explode('|',$reg[1]);
- if (! empty($tmp[1])) $langs->load($tmp[1]);
- $conf->global->MAIN_MOTD=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_MOTD);
- $i++;
- }
+ $substitutionarray=getCommonSubstitutionArray($langs);
+ complete_substitutions_array($substitutionarray, $langs);
+ $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs);
print "\n\n";
print '';
- print dol_htmlentitiesbr($conf->global->MAIN_MOTD);
+ print dol_htmlentitiesbr($texttoshow);
print '
';
print "\n\n";
}
@@ -136,7 +131,7 @@ if (empty($user->societe_id))
$action='';
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$boxstat.=$hookmanager->resPrint;
-
+
if (empty($reshook))
{
// Condition to be checked for each display line dashboard
@@ -179,7 +174,7 @@ if (empty($user->societe_id))
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php",
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php",
DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php",
- DOL_DOCUMENT_ROOT."/projet/class/project.class.php",
+ DOL_DOCUMENT_ROOT."/projet/class/project.class.php",
DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php",
DOL_DOCUMENT_ROOT."/don/class/don.class.php"
);
@@ -327,12 +322,12 @@ if (empty($user->societe_id))
$board->load_state_board($user);
$boardloaded[$classe]=$board;
}
- else
+ else
{
$board=$boardloaded[$classe];
}
-
+
if (!empty($langfile[$key])) $langs->load($langfile[$key]);
$text=$langs->trans($titres[$key]);
$boxstat.='';
@@ -353,7 +348,7 @@ if (empty($user->societe_id))
$boxstat.=' ';
$boxstat.=' ';
$boxstat.=' ';
-
+
$boxstat.='';
$boxstat.='';
$boxstat.='';
@@ -558,7 +553,7 @@ if (! empty($valid_dashboardlines))
$textlate = $langs->trans("NActionsLate",$board->nbtodolate);
$textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
-
+
$boxwork .='';
$boxwork .= '
';
$boxwork .= ''.$board->img.' '.$board->label.' ';
@@ -579,7 +574,7 @@ if (! empty($valid_dashboardlines))
$boxwork.='
';
$boxwork .="\n";
}
-
+
$boxwork .='
';
$boxwork .='
';
$boxwork .='
';
@@ -693,7 +688,7 @@ function showWeather($totallate,$text,$options)
$out='';
$offset=0;
$factor=10; // By default
-
+
$level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
$level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
$level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;