FIX 16.0 - the e-mail templates configured in the notification module are not used if the recipient is a fixed e-mail address (#29407)
This commit is contained in:
parent
dc988f7e37
commit
54caae51e0
1 changed files with 29 additions and 5 deletions
|
|
@ -847,12 +847,36 @@ class Notify
|
|||
$mimefilename_list[] = $ref.".pdf";
|
||||
}
|
||||
|
||||
$message = '';
|
||||
$message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
|
||||
$message .= "\n";
|
||||
$message .= $mesg;
|
||||
// if an e-mail template is configured for this notification code (for instance
|
||||
// 'SHIPPING_VALIDATE_TEMPLATE'), we fetch this template by its label. Otherwise, a default message
|
||||
// content will be sent.
|
||||
$mailTemplateLabel = isset($conf->global->{$notifcode.'_TEMPLATE'}) ? $conf->global->{$notifcode.'_TEMPLATE'} : '';
|
||||
$emailTemplate = null;
|
||||
if (!empty($mailTemplateLabel)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($this->db);
|
||||
$emailTemplate = $formmail->getEMailTemplate($this->db, $object_type.'_send', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
}
|
||||
if (!empty($mailTemplateLabel) && is_object($emailTemplate) && $emailTemplate->id > 0) {
|
||||
// Set output language
|
||||
$outputlangs = $langs;
|
||||
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang($obj->default_lang);
|
||||
$outputlangs->loadLangs(array('main', 'other'));
|
||||
}
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subject = make_substitutions($emailTemplate->topic, $substitutionarray, $outputlangs);
|
||||
$message = make_substitutions($emailTemplate->content, $substitutionarray, $outputlangs);
|
||||
} else {
|
||||
$message = '';
|
||||
$message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
|
||||
$message .= "\n";
|
||||
$message .= $mesg;
|
||||
|
||||
$message = nl2br($message);
|
||||
$message = nl2br($message);
|
||||
}
|
||||
|
||||
// Replace keyword __SUPERVISOREMAIL__
|
||||
if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue