Mutualize code of substitutions for emails

This commit is contained in:
Laurent Destailleur 2017-09-22 14:34:31 +02:00
parent 236cf853e5
commit 252f038468
10 changed files with 239 additions and 256 deletions

View File

@ -835,6 +835,8 @@ if ($resql)
if ($value == 'private') if ($value == 'private')
{ {
$align="center"; $align="center";
if ($valuetoshow) $valuetoshow=yn($valuetoshow);
else $valuetoshow='';
} }
if ($value == 'position') if ($value == 'position')
{ {
@ -1042,12 +1044,12 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
{ {
if (empty($user->admin)) if (empty($user->admin))
{ {
print $form->selectyesno($fieldlist[$field], '1'); print $form->selectyesno($fieldlist[$field], '1', 1);
} }
else else
{ {
//print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">'; //print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">';
print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
} }
} }
else else

View File

@ -57,24 +57,17 @@ $hookmanager->initHooks(array('mailingcard','globalcard'));
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing'); $object->substitutionarray=FormMail::getAvailableSubstitKey('emailing');
$object->substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$object->substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord', // Set $object->substitutionarrayfortest
//'__EMAIL__' => 'TESTEMail', // Done into "send" action $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
'__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname', $targetobject = null; // Not defined with mass emailing
'__MAILTOEMAIL__' => 'TESTMailtoEmail',
'__OTHER1__' => 'TESTOther1', $parameters=array('mode'=>'emailing');
'__OTHER2__' => 'TESTOther2', $substitutionarray=FormMail::getAvailableSubstitKey('emailing', $targetobject);
'__OTHER3__' => 'TESTOther3',
'__OTHER4__' => 'TESTOther4', $object->substitutionarrayfortest = $substitutionarray;
'__OTHER5__' => 'TESTOther5',
'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''),
'__CHECK_READ__' => 'TagCheckMail',
'__UNSUBSCRIBE__' => 'TagUnsubscribe'
//,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet
);
// List of sending methods // List of sending methods
$listofmethods=array(); $listofmethods=array();
@ -205,24 +198,28 @@ if (empty($reshook))
$tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
// Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) $targetobject = null; // Not defined with mass emailing
$substitutionarray=array( $parameters=array('mode'=>'emailing');
'__ID__' => $obj->source_id, $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object
'__EMAIL__' => $obj->email,
'__LASTNAME__' => $obj->lastname, // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
'__FIRSTNAME__' => $obj->firstname, $substitutionarray['__ID__'] = $obj->source_id;
'__MAILTOEMAIL__' => '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>', $substitutionarray['__EMAIL__'] = $obj->email;
'__OTHER1__' => $other1, $substitutionarray['__LASTNAME__'] = $obj->lastname;
'__OTHER2__' => $other2, $substitutionarray['__FIRSTNAME__'] = $obj->firstname;
'__OTHER3__' => $other3, $substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>';
'__OTHER4__' => $other4, $substitutionarray['__OTHER1__'] = $other1;
'__OTHER5__' => $other5, $substitutionarray['__OTHER2__'] = $other2;
'__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__OTHER3__'] = $other3;
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>', $substitutionarray['__OTHER4__'] = $other4;
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>' $substitutionarray['__OTHER5__'] = $other5;
); $substitutionarray['__SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
@ -230,18 +227,20 @@ if (empty($reshook))
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{ {
$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); {
else $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
}
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); else
else $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); {
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
else $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
} }
/* For backward compatibility */ /* For backward compatibility */
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
@ -261,6 +260,7 @@ if (empty($reshook))
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
} }
//$substitutionisok=true; //$substitutionisok=true;
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
$newsubject=make_substitutions($subject,$substitutionarray); $newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray); $newmessage=make_substitutions($message,$substitutionarray);
@ -431,9 +431,12 @@ if (empty($reshook))
$msgishtml=-1; // Inconnu par defaut $msgishtml=-1; // Inconnu par defaut
if (preg_match('/[\s\t]*<html>/i',$object->body)) $msgishtml=1; if (preg_match('/[\s\t]*<html>/i',$object->body)) $msgishtml=1;
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; // other are set at begin of page // other are set at begin of page
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto;
$object->substitutionarrayfortest['__MAILTOEMAIL__'] = '<a href="mailto:'.$object->sendto.'">'.$object->sendto.'</a>';
// Pratique les substitutions sur le sujet et message // Pratique les substitutions sur le sujet et message
complete_substitutions_array($object->substitutionarrayfortest, $langs);
$tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest); $tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest);
$tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest); $tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest);
@ -1073,7 +1076,7 @@ else
$formmail->substit=$object->substitutionarrayfortest; $formmail->substit=$object->substitutionarrayfortest;
// Tableau des parametres complementaires du post // Tableau des parametres complementaires du post
$formmail->param["action"]="send"; $formmail->param["action"]="send";
$formmail->param["models"]="body"; $formmail->param["models"]='none';
$formmail->param["mailid"]=$object->id; $formmail->param["mailid"]=$object->id;
$formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id; $formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id;

View File

@ -2251,7 +2251,7 @@ else
} }
$formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
$formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__PERSONALIZED__']=''; // deprecated
$formmail->substit['__CONTACTCIVNAME__']=''; $formmail->substit['__CONTACTCIVNAME__']='';
$custcontact = ''; $custcontact = '';
@ -2276,7 +2276,7 @@ else
// Tableau des parametres complementaires // Tableau des parametres complementaires
$formmail->param['action'] = 'send'; $formmail->param['action'] = 'send';
$formmail->param['models'] = 'contract_send'; $formmail->param['models'] = 'contract';
$formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['contractid'] = $object->id; $formmail->param['contractid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;

View File

@ -293,12 +293,16 @@ class FormMail extends Form
} }
// Get message template for $this->param["models"] into c_email_templates // Get message template for $this->param["models"] into c_email_templates
$arraydefaultmessage=array();
if ($this->param['models'] != 'none')
{
$model_id=0; $model_id=0;
if (array_key_exists('models_id',$this->param)) if (array_key_exists('models_id',$this->param))
{ {
$model_id=$this->param["models_id"]; $model_id=$this->param["models_id"];
} }
$arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
}
//var_dump($this->param["models"]); //var_dump($this->param["models"]);
//var_dump($model_id); //var_dump($model_id);
//var_dump($arraydefaultmessage); //var_dump($arraydefaultmessage);
@ -325,6 +329,8 @@ class FormMail extends Form
$out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n"; $out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
} }
if ($this->param['models'] != 'none')
{
$result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
if ($result < 0) if ($result < 0)
{ {
@ -338,6 +344,7 @@ class FormMail extends Form
if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private"); if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private");
//if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' '; //if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' ';
} }
}
// Zone to select its email template // Zone to select its email template
if (count($modelmail_array)>0) if (count($modelmail_array)>0)
@ -769,7 +776,7 @@ class FormMail extends Form
$paymenturl=$url; $paymenturl=$url;
} }
} }
$this->substit['__PERSONALIZED__']=$paymenturl; $this->substit['__PERSONALIZED__']=$paymenturl; // deprecated
$this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl; $this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl;
//Add lines substitution key from each line //Add lines substitution key from each line
@ -1038,8 +1045,7 @@ class FormMail extends Form
/** /**
* Set substit array from object. This is call when suggesting the email template into forms to send email. * Set substit array from object. This is call when suggesting the email template into forms before sending email.
* TODO Replace with getCommonSubstitutionArray with param onlykey = 2
* *
* @param CommonObject $object Object to use * @param CommonObject $object Object to use
* @param Translate $outputlangs Object lang * @param Translate $outputlangs Object lang
@ -1049,34 +1055,12 @@ class FormMail extends Form
function setSubstitFromObject($object, $outputlangs=null) function setSubstitFromObject($object, $outputlangs=null)
{ {
global $conf, $user; global $conf, $user;
$this->substit['__REF__'] = $object->ref;
$this->substit['__REFCLIENT__'] = isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '');
$this->substit['__REFSUPPLIER__'] = isset($object->ref_supplier) ? $object->ref_supplier : '';
$this->substit['__DATE_YMD__'] = isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : ''; $parameters=array('mode'=>$mode);
$this->substit['__DATE_DUE_YMD__'] = isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : ''; $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
$this->substit['__AMOUNT__'] = price($object->total_ttc); complete_substitutions_array($tmparray, $outputlangs, null, $parameters);
$this->substit['__AMOUNT_EXCL_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=$tmparray;
$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
// Create dynamic tags for __EXTRAFIELD_FIELD__
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element, true);
$object->fetch_optionals($object->id, $extralabels);
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 // Fill substit_lines with each object lines content
if (is_array($object->lines)) if (is_array($object->lines))
@ -1127,55 +1111,43 @@ class FormMail extends Form
{ {
global $conf, $langs; global $conf, $langs;
$vars=array();
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines')
{ {
$vars=array( $parameters=array('mode'=>$mode);
'__REF__'=>'__REF__', $tmparray=getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects
'__REFCLIENT__'=>'__REFCLIENT__', complete_substitutions_array($tmparray, $langs, null, $parameters);
'__REFSUPPLIER__'=>'__REFSUPPLIER__',
'__THIRDPARTY_ID__'=>'__THIRDPARTY_ID__',
'__THIRDPARTY_NAME__'=>'__THIRDPARTY_NAME__',
'__PROJECT_ID__'=>'__PROJECT_ID__',
'__PROJECT_REF__'=>'__PROJECT_REF__',
'__PROJECT_NAME__'=>'__PROJECT_NAME__',
'__CONTACTCIVNAME__'=>'__CONTACTCIVNAME__',
'__AMOUNT__'=>'__AMOUNT__',
'__AMOUNT_EXCL_TAX__'=>'__AMOUNT_EXCL_TAX__',
'__AMOUNT_VAT__'=>'__AMOUNT_VAT__',
'__ONLINE_PAYMENT_URL__'=>'__ONLINE_PAYMENT_URL__',
'__SIGNATURE__'=>'__SIGNATURE__',
'__PERSONALIZED__'=>'__PERSONALIZED__', // deprecated
);
if ($mode == 'formwithlines') if ($mode == 'formwithlines')
{ {
$vars[] = '__LINES__'; // Will be set by the get_form function $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function
} }
if ($mode == 'formforlines') if ($mode == 'formforlines')
{ {
$vars[] = '__QUANTITY__'; // Will be set by the get_form function $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function
} }
} }
if ($mode == 'emailing') if ($mode == 'emailing')
{ {
$parameters=array('mode'=>$mode);
$tmparray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects
complete_substitutions_array($tmparray, $langs, null, $parameters);
// For mass emailing, we have different keys // For mass emailing, we have different keys
$vars=array( $tmparray['__ID__'] = 'IdRecord';
'__ID__' => 'IdRecord', $tmparray['__EMAIL__'] = 'EMailRecipient';
'__EMAIL__' => 'EMailRecipient', $tmparray['__LASTNAME__'] = 'Lastname';
'__LASTNAME__' => 'Lastname', $tmparray['__FIRSTNAME__'] = 'Firstname';
'__FIRSTNAME__' => 'Firstname', $tmparray['__MAILTOEMAIL__'] = 'TagMailtoEmail';
'__MAILTOEMAIL__' => 'TagMailtoEmail', $tmparray['__OTHER1__'] = 'Other1';
'__OTHER1__' => 'Other1', $tmparray['__OTHER2__'] = 'Other2';
'__OTHER2__' => 'Other2', $tmparray['__OTHER3__'] = 'Other3';
'__OTHER3__' => 'Other3', $tmparray['__OTHER4__'] = 'Other4';
'__OTHER4__' => 'Other4', $tmparray['__OTHER5__'] = 'Other5';
'__OTHER5__' => 'Other5', $tmparray['__SIGNATURE__'] = 'TagSignature';
'__SIGNATURE__' => 'TagSignature', $tmparray['__CHECK_READ__'] = 'TagCheckMail';
'__CHECK_READ__' => 'TagCheckMail', $tmparray['__UNSUBSCRIBE__'] = 'TagUnsubscribe';
'__UNSUBSCRIBE__' => 'TagUnsubscribe'
//,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing
);
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
@ -1183,13 +1155,13 @@ class FormMail extends Form
if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++; if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++;
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{ {
$vars['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN; $tmparray['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN;
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{ {
if ($conf->adherent->enabled) $vars['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember'; if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember';
if ($conf->facture->enabled) $vars['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice'; if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice';
if ($conf->commande->enabled) $vars['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder'; if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder';
if ($conf->contrat->enabled) $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine'; if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine';
} }
} }
else else
@ -1202,36 +1174,16 @@ class FormMail extends Form
$vars['__SECUREKEYPAYMENT_CONTRACTLINE__']=''; $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='';
*/ */
} }
// Old vars removed from doc
/*
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
$vars['__SECUREKEYPAYPAL__']='SecureKeyPaypal';
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
{
if ($conf->adherent->enabled) $vars['__SECUREKEYPAYPAL_MEMBER__']='SecureKeyPaypalUniquePerMember';
if ($conf->facture->enabled) $vars['__SECUREKEYPAYPAL_INVOICE__']='SecureKeyPaypalUniquePerInvoice';
if ($conf->commande->enabled) $vars['__SECUREKEYPAYPAL_ORDER__']='SecureKeyPaypalUniquePerOrder';
if ($conf->contrat->enabled) $vars['__SECUREKEYPAYPAL_CONTRACTLINE__']='SecureKeyPaypalUniquePerContractLine';
}
}
else
{
$vars['__SECUREKEYPAYPAL__']='';
$vars['__SECUREKEYPAYPAL_MEMBER__']='';
}*/
} }
$parameters=array('mode'=>$mode); $tmparray['__(AnyTranslationKey)__']="Translation";
$tmparray=getCommonSubstitutionArray($langs, 2, null, $object);
complete_substitutions_array($tmparray, $langs, null, $parameters);
foreach($tmparray as $key => $val) foreach($tmparray as $key => $val)
{ {
$vars[$key]=$key; if (empty($val)) $tmparray[$key]=$key;
} }
return $vars; return $tmparray;
} }
} }

View File

@ -5227,7 +5227,34 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
'__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id
)); ));
} }
if (is_object($object) && (empty($exclude) || ! in_array('object', $exclude))) if (($onlykey || is_object($object)) && (empty($exclude) || ! in_array('object', $exclude)))
{
if ($onlykey)
{
$substitutionarray['__ID__'] = '__ID__';
$substitutionarray['__REF__'] = '__REF__';
$substitutionarray['__REFCLIENT__'] = '__REFCLIENT__';
$substitutionarray['__REFSUPPLIER__'] = '__REFSUPPLIER__';
$substitutionarray['__EXTRAFIELD_XXX__'] = '__EXTRAFIELD_XXX__';
$substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__';
$substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__';
$substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__';
$substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__';
$substitutionarray['__PROJECT_NAME__'] = '__PROJECT_REF__';
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = 'Date for next expired service';
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = 'Date and hour for next expired service';
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'LinkToPayOnlineIfApplicable';
$substitutionarray['__SECUREKEYPAYMENT__'] = 'Security key (if key is not unique per record)';
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = 'Security key for payment on a member subscription (one key per member)';
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = 'Security key for payment on an order';
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = 'Security key for payment on an invoice';
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'Security key for payment on a a service';
}
else
{ {
$substitutionarray['__ID__'] = $object->id; $substitutionarray['__ID__'] = $object->id;
$substitutionarray['__REF__'] = $object->ref; $substitutionarray['__REF__'] = $object->ref;
@ -5258,7 +5285,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
} }
} }
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'LinkToPayOnlineIfApplicable'; $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = 'TODO';
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = 'TODO';
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'TODO';
}
} }
if (empty($exclude) || ! in_array('objectamount', $exclude)) if (empty($exclude) || ! in_array('objectamount', $exclude))
{ {
@ -5280,41 +5311,35 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; 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); $tmp=dol_getdate(dol_now(), true);
$tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp3=dol_get_prev_month($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']); $tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']);
}
$substitutionarray=array_merge($substitutionarray, array( $substitutionarray=array_merge($substitutionarray, array(
'__DAY__' => $tmp['mday'], '__DAY__' => (string) $tmp['mday'],
'__MONTH__' => $tmp['mon'], '__MONTH__' => (string) $tmp['mon'],
'__YEAR__' => $tmp['year'], '__YEAR__' => (string) $tmp['year'],
'__PREVIOUS_DAY__' => $tmp2['day'], '__PREVIOUS_DAY__' => (string) $tmp2['day'],
'__PREVIOUS_MONTH__' => $tmp3['month'], '__PREVIOUS_MONTH__' => (string) $tmp3['month'],
'__PREVIOUS_YEAR__' => ($tmp['year'] - 1), '__PREVIOUS_YEAR__' => (string) ($tmp['year'] - 1),
'__NEXT_DAY__' => $tmp4['day'], '__NEXT_DAY__' => (string) $tmp4['day'],
'__NEXT_MONTH__' => $tmp5['month'], '__NEXT_MONTH__' => (string) $tmp5['month'],
'__NEXT_YEAR__' => ($tmp['year'] + 1), '__NEXT_YEAR__' => (string) ($tmp['year'] + 1),
)); ));
} }
if (empty($exclude) || ! in_array('user', $exclude)) if (empty($exclude) || ! in_array('user', $exclude))
{ {
$substitutionarray=array_merge($substitutionarray, array( $substitutionarray=array_merge($substitutionarray, array(
'__USER_ID__' => $user->id, '__USER_ID__' => (string) $user->id,
'__USER_LOGIN__' => $user->login, '__USER_LOGIN__' => (string) $user->login,
'__USER_LASTNAME__' => $user->lastname, '__USER_LASTNAME__' => (string) $user->lastname,
'__USER_FIRSTNAME__' => $user->firstname, '__USER_FIRSTNAME__' => (string) $user->firstname,
'__USER_FULLNAME__' => $user->getFullName($outputlangs), '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
'__USER_SUPERVISOR_ID__' => $user->fk_user, '__USER_SUPERVISOR_ID__' => (string) $user->fk_user,
'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '') '__SIGNATURE__' => (string) (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '')
)); ));
} }
if (! empty($conf->multicompany->enabled)) if (! empty($conf->multicompany->enabled))
@ -5369,8 +5394,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
} }
/** /**
* Complete the $substitutionarray with more entries. * Complete the $substitutionarray with more entries coming from external module that had set the "substitutions=1" into module_part array.
* Can also add substitution keys coming from external module that had set the "substitutions=1" into module_part array. In this case, method completesubstitutionarray provided by module is called. * In this case, method completesubstitutionarray provided by module is called.
* *
* @param array $substitutionarray Array substitution old value => new value value * @param array $substitutionarray Array substitution old value => new value value
* @param Translate $outputlangs Output language * @param Translate $outputlangs Output language
@ -5386,13 +5411,8 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Add a substitution key for each object property
if (is_object($object))
{
// TODO
}
// Add a substitution key for each extrafields, using key __EXTRA_XXX__ // Add a substitution key for each extrafields, using key __EXTRA_XXX__
// TODO Remove this. Already available into the getCommonSubstitutionArray used to build the substitution array.
if (is_object($object) && is_array($object->array_options)) if (is_object($object) && is_array($object->array_options))
{ {
foreach($object->array_options as $key => $val) foreach($object->array_options as $key => $val)

View File

@ -139,7 +139,7 @@ if ($action == 'presend')
// Make substitution in email content // Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : ''; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$substitutionarray['__PERSONALIZED__'] = ''; $substitutionarray['__PERSONALIZED__'] = ''; // deprecated
$substitutionarray['__CONTACTCIVNAME__'] = ''; $substitutionarray['__CONTACTCIVNAME__'] = '';
// Add specific substitution for contracts // Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))

View File

@ -117,7 +117,7 @@ $formmail->withcancel = 1;
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto; $substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : ''; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$substitutionarray['__PERSONALIZED__'] = ''; $substitutionarray['__PERSONALIZED__'] = ''; // deprecated
$substitutionarray['__CONTACTCIVNAME__'] = ''; $substitutionarray['__CONTACTCIVNAME__'] = '';
// Add specific substitution for contracts // Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))

View File

@ -2488,7 +2488,7 @@ else
$formmail->setSubstitFromObject($object); $formmail->setSubstitFromObject($object);
$formmail->substit['__THIRDPARTY_ID__']=$object->id; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__THIRDPARTY_ID__']=$object->id; // substit in setSubstitFromObject was wrong for this one
$formmail->substit['__THIRDPARTY_NAME__']=$object->name; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__THIRDPARTY_NAME__']=$object->name; // substit in setSubstitFromObject was wrong for this one
$formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__PERSONALIZED__']=''; // deprecated
$formmail->substit['__CONTACTCIVNAME__']=''; $formmail->substit['__CONTACTCIVNAME__']='';
//Find the good contact adress //Find the good contact adress

View File

@ -163,22 +163,25 @@ if ($resql)
$tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
$object = null; // Not defined with mass emailing
$parameters=array('mode'=>'emailing');
$substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On mass emailing, this is null because we don't know object
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray=array( $substitutionarray['__ID__'] = $obj->source_id;
'__ID__' => $obj2->source_id, $substitutionarray['__EMAIL__'] = $obj->email;
'__EMAIL__' => $obj2->email, $substitutionarray['__LASTNAME__'] = $obj->lastname;
'__LASTNAME__' => $obj2->lastname, $substitutionarray['__FIRSTNAME__'] = $obj->firstname;
'__FIRSTNAME__' => $obj2->firstname, $substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>';
'__MAILTOEMAIL__' => '<a href="mailto:'.$obj2->email.'">'.$obj2->email.'</a>', $substitutionarray['__OTHER1__'] = $other1;
'__OTHER1__' => $other1, $substitutionarray['__OTHER2__'] = $other2;
'__OTHER2__' => $other2, $substitutionarray['__OTHER3__'] = $other3;
'__OTHER3__' => $other3, $substitutionarray['__OTHER4__'] = $other4;
'__OTHER4__' => $other4, $substitutionarray['__OTHER5__'] = $other5;
'__OTHER5__' => $other5, $substitutionarray['__SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
'__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj2->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>', $substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj2->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'
);
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
@ -186,18 +189,20 @@ if ($resql)
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{ {
$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); {
else $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
}
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); else
else $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); {
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
else $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
} }
/* For backward compatibility */ /* For backward compatibility */
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
@ -216,6 +221,7 @@ if ($resql)
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
} }
complete_substitutions_array($substitutionarray,$langs); complete_substitutions_array($substitutionarray,$langs);
$newsubject=make_substitutions($subject,$substitutionarray); $newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray); $newmessage=make_substitutions($message,$substitutionarray);