Fix #17475 : Update of previous fix

This commit is contained in:
lmarcouiller 2021-05-07 09:19:44 +02:00
parent 7d649dd90e
commit 0f2ce8687d
3 changed files with 17 additions and 8 deletions

View File

@ -265,10 +265,16 @@ if (empty($reshook)) {
}
//$substitutionisok=true;
$moreinheader = '';
complete_substitutions_array($substitutionarray, $langs);
$newsubject = make_substitutions($subject, $substitutionarray);
$newmessage = make_substitutions($message, $substitutionarray, null, 0, $moreinheader);
$newmessage = make_substitutions($message, $substitutionarray, null, 0);
$moreinheader = '';
if (preg_match('/__UNSUBSCRIBE__/', $message)) {
$moreinheader = make_substitutions('__UNSUBSCRIBE__', $substitutionarray);
$moreinheader = explode('"', $moreinheader);
$moreinheader = "List-Unsubscribe: <".$moreinheader[1].">\n";
}
$arr_file = array();
$arr_mime = array();

View File

@ -7212,7 +7212,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
* @return string Output string after substitutions
* @see complete_substitutions_array(), getCommonSubstitutionArray()
*/
function make_substitutions($text, $substitutionarray, $outputlangs = null, $converttextinhtmlifnecessary = 0, &$moreinheader = null)
function make_substitutions($text, $substitutionarray, $outputlangs = null, $converttextinhtmlifnecessary = 0)
{
global $conf, $langs;
@ -7317,10 +7317,6 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con
}
$text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
}
if ($key == '__UNSUBSCRIBE__' && (isset($moreinheader))) {
$tmptext = explode('"', $text);
$moreinheader = "List-Unsubscribe: <".$tmptext[1].">\n";
}
}
return $text;

View File

@ -268,6 +268,13 @@ if ($resql) {
$substitutionisok = true;
$moreinheader = '';
if (preg_match('/__UNSUBSCRIBE__/', $message)) {
$moreinheader = make_substitutions('__UNSUBSCRIBE__', $substitutionarray);
$moreinheader = explode('"', $moreinheader);
$moreinheader = "List-Unsubscribe: <".$moreinheader[1].">\n";
}
$arr_file = array();
$arr_mime = array();
$arr_name = array();
@ -284,7 +291,7 @@ if ($resql) {
}
// Fabrication du mail
$trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid;
$mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing');
$mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, $moreinheader, 'emailing');
if ($mail->error) {
$res = 0;