Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from totten/master-extern-url
Browse files Browse the repository at this point in the history
OpenTracker - Create URL via CRM_Utils_System::externUrl()
  • Loading branch information
totten authored May 28, 2020
2 parents 1c85909 + c4f95e1 commit 7a69cc2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Listener/OpenTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ public function onCompose(ComposeBatchEvent $e) {

$config = \CRM_Core_Config::singleton();

// TODO: After v5.21 goes EOL, remove the $isLegacy check.
$isLegacy = version_compare(\CRM_Utils_System::version(), '5.23.alpha', '<');

foreach ($e->getTasks() as $task) {
/** @var \Civi\FlexMailer\FlexMailerTask $task */
$mailParams = $task->getMailParams();

if (!empty($mailParams) && !empty($mailParams['html'])) {
$mailParams['html'] .= "\n" . '<img src="' .
$config->userFrameworkResourceURL . "extern/open.php?q=" . $task->getEventQueueId() .
"\" width='1' height='1' alt='' border='0'>";
$openUrl = $isLegacy
? $config->userFrameworkResourceURL . "extern/open.php?q=" . $task->getEventQueueId()
: \CRM_Utils_System::externUrl('extern/open', "q=" . $task->getEventQueueId());

$mailParams['html'] .= "\n" . '<img src="' . htmlentities($openUrl) . "\" width='1' height='1' alt='' border='0'>";

$task->setMailParams($mailParams);
}
Expand Down

0 comments on commit 7a69cc2

Please sign in to comment.