Skip to content

Commit

Permalink
#17935 - parse logo placeholders in system messages
Browse files Browse the repository at this point in the history
  • Loading branch information
michield committed Nov 28, 2015
1 parent c6a890f commit 80f5828
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
18 changes: 18 additions & 0 deletions public_html/lists/admin/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ function constructSystemMail($message, $subject = '')
} else {
$htmlcontent .= $phpListPowered;
}
$htmlcontent = parseLogoPlaceholders($htmlcontent);
}

return array($htmlcontent,$textmessage);
Expand Down Expand Up @@ -1978,3 +1979,20 @@ function flushLogoCache()
{
Sql_Query(sprintf('delete from %s where template = 0 and filename like "ORGANISATIONLOGO%%.png"', $GLOBALS['tables']['templateimage']));
}

function parseLogoPlaceholders($content) {
## replace Logo placeholders
preg_match_all('/\[LOGO\:?(\d+)?\]/', $content, $logoInstances);
foreach ($logoInstances[0] as $index => $logoInstance) {
$size = sprintf('%d', $logoInstances[1][$index]);
if (!empty($size)) {
$logoSize = $size;
} else {
$logoSize = '500';
}
createCachedLogoImage($logoSize);
$content = str_replace($logoInstance, 'ORGANISATIONLOGO'.$logoSize.'.png', $content);
}
return $content;
}

17 changes: 3 additions & 14 deletions public_html/lists/admin/sendemaillib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1608,20 +1608,9 @@ function precacheMessage($messageid, $forwardContent = 0)
$cached[$messageid]['content'] = preg_replace('/<img(.*)src="\/'.$dir.'(.*)>/iU', '<img\\1src="'.$GLOBALS['public_scheme'].'://'.$baseurl.'/'.UPLOADIMAGES_DIR.'\\2>', $cached[$messageid]['content']);
}

## replace Logo placeholders
foreach (array('content', 'template', 'htmlfooter') as $element) {
preg_match_all('/\[LOGO\:?(\d+)?\]/', $cached[$messageid][$element], $logoInstances);
foreach ($logoInstances[0] as $index => $logoInstance) {
$size = sprintf('%d', $logoInstances[1][$index]);
if (!empty($size)) {
$logoSize = $size;
} else {
$logoSize = '500';
}
createCachedLogoImage($logoSize);
$cached[$messageid][$element] = str_replace($logoInstance, 'ORGANISATIONLOGO'.$logoSize.'.png', $cached[$messageid][$element]);
}
}
foreach (array('content', 'template', 'htmlfooter') as $element) {
$cached[$messageid][$element] = parseLogoPlaceholders($cached[$messageid][$element]);
}

return 1;
}
Expand Down

0 comments on commit 80f5828

Please sign in to comment.