diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 7d4e382723c..01dcc3b5381 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -745,7 +745,7 @@ else { if (function_exists('fsockopen') && $port && $server) { - print ''.$langs->trans("DoTestServerAvailability").''; + print ''.$langs->trans("DoTestServerAvailability").''; } } else @@ -753,11 +753,11 @@ else print ''.$langs->trans("DoTestServerAvailability").''; } - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; if (! empty($conf->fckeditor->enabled)) { - print ''.$langs->trans("DoTestSendHTML").''; + print ''.$langs->trans("DoTestSendHTML").''; } print ''; @@ -834,7 +834,7 @@ else $formmail->fromalsorobot=1; $formmail->fromtype=(GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); $formmail->withfromreadonly=1; - $formmail->withsubstit=0; + $formmail->withsubstit=1; $formmail->withfrom=1; $formmail->witherrorsto=1; $formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1)); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d0de3d2002f..89f3700c4f7 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -776,6 +776,7 @@ if ($resql) } if ($tmpfieldlist == 'content') { + print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '
'; $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 4309c689b9e..b9043626c51 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -240,13 +240,13 @@ class FormMail extends Form * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files * this->withfile - * this->param: Contains more parameteres like email templates info + * this->param: Contains more parameters like email templates info * * @param string $addfileaction Name of action when posting file attachments * @param string $removefileaction Name of action when removing file attachments * @return string Form to show */ - function get_form($addfileaction='addfile',$removefileaction='removefile') + function get_form($addfileaction='addfile', $removefileaction='removefile') { global $conf, $langs, $user, $hookmanager, $form; @@ -409,18 +409,19 @@ class FormMail extends Form $out.= ''."\n"; - // Substitution array + // Substitution array/string + $helpforsubstitution=''; + if (is_array($this->substit) && count($this->substit)) $helpforsubstitution.=$langs->trans('AvailableVariables').' :
'."\n"; + foreach($this->substit as $key => $val) + { + $helpforsubstitution.=$key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'
'; + } if (! empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this. { $out.= '\n"; //$out.=''; } @@ -773,7 +774,9 @@ class FormMail extends Form $defaulttopic=make_substitutions($defaulttopic,$this->substit); $out.= ''; - $out.= ''; + $out.= ''; $out.= ''; - $out.= ''; + $out.= ''; $out.= '
'; //$out.='
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'
'; - } - if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage - else $out.= $form->textwithpicto($langs->trans('AvailableVariables'), $help, 1, 'help', '', 0, 2, 'substittooltip'); // New usage + if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage + else $out.= $form->textwithpicto($langs->trans('AvailableVariables'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // New usage $out.= "
'.$langs->trans("MailTopic").''; + $out.=$form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic'); + $out.=''; if ($this->withtopicreadonly) { @@ -917,7 +920,9 @@ class FormMail extends Form } $out.= '
'.$langs->trans("MailText").''; + $out.=$form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); + $out.=''; if ($this->withbodyreadonly) { diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index edeabc5865d..5baa70825d8 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ * $modelmail * $defaulttopic * $diroutput + * $arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...); */ // Protection to avoid direct call of template @@ -144,8 +145,11 @@ if ($action == 'presend') } else { - foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) { - $liste[$key] = $value; + if (is_object($object->thirdparty)) + { + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) { + $liste[$key] = $value; + } } } @@ -158,8 +162,11 @@ if ($action == 'presend') $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; + //$arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...); + if (! isset($arrayoffamiliestoexclude)) $arrayoffamiliestoexclude=null; + // Make substitution in email content - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; $substitutionarray['__PERSONALIZED__'] = ''; // deprecated $substitutionarray['__CONTACTCIVNAME__'] = ''; @@ -179,8 +186,6 @@ if ($action == 'presend') $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; $formmail->param['fileinit'] = array($file); - $formmail->withsubstit = 1; - // Show form print $formmail->get_form();