diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php
index 0a93eac7c9a..02b178df455 100755
--- a/htdocs/adherents/cartes/carte.php
+++ b/htdocs/adherents/cartes/carte.php
@@ -138,15 +138,15 @@ else
'%MONTH%'=>$month,
'%DAY%'=>$day
);
-
+ complete_substitutions_array($substitutionarray, $langs);
// For business cards
if (empty($mode) || $mode=='card' || $mode=='cardlogin')
{
- $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray, $langs);
- $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray, $langs);
- $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray, $langs);
- $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray, $langs);
+ $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
+ $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
+ $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
+ $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
if (is_numeric($foruserid) || $foruserlogin)
{
@@ -175,7 +175,7 @@ else
if ($mode == 'label')
{
$conf->global->ADHERENT_ETIQUETTE_TEXT="%PRENOM% %NOM%\n%ADRESSE%\n%CP% %VILLE%\n%PAYS%";
- $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray, $langs);
+ $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
$textheader='';
$textfooter='';
$textright='';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index cfbaaee8d6c..b4fea76bbff 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -199,7 +199,7 @@ class Adherent extends CommonObject
$infos.= $langs->transnoentities("Public").": ".yn($this->public);
// Substitutions
- $substit=array(
+ $substitutionarray=array(
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
'%CIVILITE%'=>$this->getCivilityLabel($msgishtml?0:1),
@@ -217,7 +217,9 @@ class Adherent extends CommonObject
'%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass
);
- return make_substitutions($text,$substit,$langs);
+ $substitutionarray=complete_substitutions_array($substitutionarray, $langs);
+
+ return make_substitutions($text,$substitutionarray);
}
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 058bc23135f..8c5ac745689 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -38,11 +38,13 @@ if (!$user->admin)
accessforbidden();
$substitutionarrayfortest=array(
+'__LOGIN__' => $user->login,
'__ID__' => 'TESTIdRecord',
'__EMAIL__' => 'TESTEMail',
'__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname'
);
+complete_substitutions_array($substitutionarrayfortest, $langs);
/*
@@ -204,8 +206,8 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'sendhtml')
if ($_POST['action'] == 'sendhtml') $msgishtml=1; // Force message to HTML
// Pratique les substitutions sur le sujet et message
- $subject=make_substitutions($subject,$substitutionarrayfortest,$langs);
- $body=make_substitutions($body,$substitutionarrayfortest,$langs);
+ $subject=make_substitutions($subject,$substitutionarrayfortest);
+ $body=make_substitutions($body,$substitutionarrayfortest);
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
$mailfile = new CMailFile($subject,$sendto,$email_from,$body,
@@ -716,6 +718,7 @@ else
$formmail->withtopicreadonly=0;
$formmail->withfile=2;
$formmail->withbody=(isset($_POST['message'])?$_POST['message']:$langs->trans("PredefinedMailTestHtml"));
+ //$formmail->withbody='Test aaa __LOGIN__';
$formmail->withbodyreadonly=0;
$formmail->withcancel=1;
$formmail->withdeliveryreceipt=1;
diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php
index 60a05c00045..64013cd3cca 100755
--- a/htdocs/admin/sms.php
+++ b/htdocs/admin/sms.php
@@ -108,7 +108,8 @@ if ($action == 'send' && ! $_POST['cancel'])
if (! $error)
{
// Make substitutions into message
- $body=make_substitutions($body,$substitutionarrayfortest,$langs);
+ complete_substitutions_array($substitutionarrayfortest, $langs);
+ $body=make_substitutions($body,$substitutionarrayfortest);
require_once(DOL_DOCUMENT_ROOT."/lib/CSMSFile.class.php");
diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php
index 9bd5b28e911..ce1a5b02c5e 100644
--- a/htdocs/comm/mailing/fiche.php
+++ b/htdocs/comm/mailing/fiche.php
@@ -191,8 +191,9 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
);
$substitutionisok=true;
- $newsubject=make_substitutions($subject,$substitutionarray,$langs);
- $newmessage=make_substitutions($message,$substitutionarray,$langs);
+ complete_substitutions_array($substitutionarray, $langs);
+ $newsubject=make_substitutions($subject,$substitutionarray);
+ $newmessage=make_substitutions($message,$substitutionarray);
$arr_file = array();
$arr_mime = array();
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 215c3f5dcb8..ed40638bb7c 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -412,7 +412,7 @@ class FormMail
// Topic
if ($this->withtopic)
{
- $this->withtopic=make_substitutions($this->withtopic,$this->substit,$langs);
+ $this->withtopic=make_substitutions($this->withtopic,$this->substit);
print "
";
print "| ".$langs->trans("MailTopic")." | ";
@@ -473,7 +473,7 @@ class FormMail
if ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); }
if ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); }
if ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); }
- $defaultmessage=make_substitutions($defaultmessage,$this->substit,$langs);
+ $defaultmessage=make_substitutions($defaultmessage,$this->substit);
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php
index 82bb4c6ff5d..bc5a6a0d19a 100755
--- a/htdocs/core/class/html.formsms.class.php
+++ b/htdocs/core/class/html.formsms.class.php
@@ -238,38 +238,11 @@ function limitChars(textarea, limit, infodiv)
print "
\n";
}
- // Topic
- /*
- if ($this->withtopic)
- {
- $this->withtopic=make_substitutions($this->withtopic,$this->substit,$langs);
-
- print "";
- print "| ".$langs->trans("MailTopic")." | ";
- print "";
- if ($this->withtopicreadonly)
- {
- print $this->withtopic;
- print "withtopic."\">";
- }
- else
- {
- print "withtopic) ."\">";
- }
- print " |
\n";
- }*/
-
// Message
if ($this->withbody)
{
$defaultmessage='';
if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; }
- /*if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); }
- if ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }
- if ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); }
- if ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); }
- if ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); }
- if ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } */
$defaultmessage=make_substitutions($defaultmessage,$this->substit,$langs);
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
diff --git a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php
index 3b9b90cd177..a2eeb204139 100644
--- a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -103,7 +103,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$invoice_source->fetch($object->fk_facture_source);
}
$alreadypayed=price($object->getSommePaiement(),'MT');
-
+
return array(
'object_id'=>$object->id,
'object_ref'=>$object->ref,
@@ -129,7 +129,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
'object_remain_to_pay'=>price($object->total_ttc - $alreadypayed,'MT')
);
}
-
+
/**
* Define array with couple substitution key => substitution value
*
@@ -353,23 +353,24 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$socobject=$object->client;
}
+ // Make substitution
+ $substitutionarray=array(
+ '__FROM_NAME__' => $this->emetteur->nom,
+ '__FROM_EMAIL__' => $this->emetteur->email,
+ '__TOTAL_TTC__' => $object->total_ttc,
+ '__TOTAL_HT__' => $object->total_ht,
+ '__TOTAL_VAT__' => $object->total_vat
+ );
+ complete_substitutions_array($substitutionarray, $langs, $object);
+
// Line of free text
$newfreetext='';
$paramfreetext='FACTURE_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
{
- // Make substitution
- $substitutionarray=array(
- '__FROM_NAME__' => $this->emetteur->nom,
- '__FROM_EMAIL__' => $this->emetteur->email,
- '__TOTAL_TTC__' => $object->total_ttc,
- '__TOTAL_HT__' => $object->total_ht,
- '__TOTAL_VAT__' => $object->total_vat
- );
-
- $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray,$outputlangs,$object);
+ $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
}
-
+
// Open and load template
require_once(DOL_DOCUMENT_ROOT.'/includes/odtphp/odf.php');
$odfHandler = new odf($srctemplatepath, array(
@@ -384,7 +385,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
//print html_entity_decode($odfHandler->__toString());
//print exit;
-
+
// Make substitutions into odt
if ($newfreetext)
{
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index a3f220b7b7c..32ea53c2701 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -1051,7 +1051,7 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=
'__PHONETO__'=>urlencode($phone),
'__LOGIN__'=>urlencode($user->clicktodial_login),
'__PASS__'=>urlencode($user->clicktodial_password));
- $url = make_substitutions($url, $substitarray, $langs);
+ $url = make_substitutions($url, $substitarray);
$newphonesav=$newphone;
$newphone ='global->CLICKTODIAL_FORCENEWTARGET)) $newphone.=' target="_blank"';
@@ -3571,16 +3571,11 @@ function dol_textishtml($msg,$option=0)
* - From $substitutionarray (oldval=>newval)
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
* @param chaine Source string in which we must do substitution
- * @param substitutionarray Array substitution old value => new value value
- * @param outputlangs If we want substitution from special constants, we provide a language
- * @param object If we want substitution from special constants, we provide data in a source object
* @return string Output string after subsitutions
*/
-function make_substitutions($chaine,$substitutionarray,$outputlangs,$object='')
+function make_substitutions($chaine,$substitutionarray)
{
- global $conf,$user;
-
- complete_substitutions_array($substitutionarray,$outputlangs,$object);
+ if (! is_array($substitutionarray)) return 'ErrorBadParametersCalling_make_substitutions';
// Make substitition
foreach ($substitutionarray as $key => $value)
diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php
index 4fef97dc03e..4e4ea3471ee 100644
--- a/htdocs/lib/pdf.lib.php
+++ b/htdocs/lib/pdf.lib.php
@@ -470,8 +470,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
-
- $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray,$outputlangs,$object);
+ complete_substitutions_array($substitutionarray,$outputlangs,$object);
+ $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
$line.=$outputlangs->convToOutputCharset($newfreetext);
}
@@ -1032,7 +1032,7 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0)
function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
{
include_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
-
+
if ($object->lines[$i]->special_code != 3)
{
if (! empty($object->hooks['objectcard']) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php
index 9182c14fa3d..d398043aee5 100644
--- a/scripts/emailings/mailing-send.php
+++ b/scripts/emailings/mailing-send.php
@@ -146,11 +146,13 @@ if ($resql)
'__OTHER5__' => $other5
);
- $substitutionisok=true;
- $newsubject=make_substitutions($subject,$substitutionarray,$langs);
- $newmessage=make_substitutions($message,$substitutionarray,$langs);
+ $substitutionarray=complete_substitutions_array($substitutionarray,$langs);
+ $newsubject=make_substitutions($subject,$substitutionarray);
+ $newmessage=make_substitutions($message,$substitutionarray);
- // Fabrication du mail
+ $substitutionisok=true;
+
+ // Fabrication du mail
$mail = new CMailFile($newsubject, $sendto, $from, $newmessage,
array(), array(), array(),
'', '', 0, $msgishtml, $errorsto);