Skip to content

Commit

Permalink
Fixed issue #16901: @@SURVEYURL@@ not replaced when register
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Dec 11, 2020
1 parent ade1dcb commit adf5a10
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion application/controllers/admin/tokens.php
Expand Up @@ -1445,7 +1445,6 @@ public function email($iSurveyId)
$mail->setSurvey($iSurveyId);
$mail->emailType = $sSubAction;
$mail->replaceTokenAttributes = true;
$mail->addUrlsPlaceholders(array('OPTOUT', 'OPTIN', 'SURVEY'));
foreach ($emresult as $emrow) {
$mail = \LimeMailer::getInstance();
if ($this->tokenIsSetInEmailCache($iSurveyId, $emrow['tid'],$bIsInvitation)) {
Expand Down
9 changes: 6 additions & 3 deletions application/core/LimeMailer.php
Expand Up @@ -37,7 +37,7 @@ class LimeMailer extends \PHPMailer\PHPMailer\PHPMailer
/* @var string[] Array for barebone url and url */
public $aUrlsPlaceholders = [];

/* @var string[] Array of replacements */
/* @var string[] Array of replacements key was replaced by value */
public $aReplacements = [];

/**
Expand Down Expand Up @@ -280,7 +280,7 @@ public function addUrlsPlaceholders($aUrlsPlaceholders)
if (is_string($aUrlsPlaceholders)) {
$aUrlsPlaceholders = [$aUrlsPlaceholders];
}
$this->aUrlsPlaceholders = array_merge($this->aUrlsPlaceholders, $aUrlsPlaceholders);
$this->aUrlsPlaceholders = array_unique(array_merge($this->aUrlsPlaceholders, $aUrlsPlaceholders));
}

/**
Expand Down Expand Up @@ -630,13 +630,16 @@ public function getTokenReplacements()
$aTokenReplacements[strtoupper($attribute)] = $value;
}
}
/* Did we need to check if each url are in $this->aUrlsPlaceholders ? */
/* Set the minimal url and add it to Placeholders */
$aTokenReplacements["OPTOUTURL"] = App()->getController()
->createAbsoluteUrl("/optout/tokens", array("surveyid"=>$this->surveyId, "token"=>$token,"langcode"=>$language));
$this->addUrlsPlaceholders("OPTOUT");
$aTokenReplacements["OPTINURL"] = App()->getController()
->createAbsoluteUrl("/optin/tokens", array("surveyid"=>$this->surveyId, "token"=>$token,"langcode"=>$language));
$this->addUrlsPlaceholders("OPTIN");
$aTokenReplacements["SURVEYURL"] = App()->getController()
->createAbsoluteUrl("/survey/index", array("sid"=>$this->surveyId, "token"=>$token,"lang"=>$language));
$this->addUrlsPlaceholders("SURVEY");
return $aTokenReplacements;
}

Expand Down
1 change: 0 additions & 1 deletion application/helpers/admin/token_helper.php
Expand Up @@ -30,7 +30,6 @@ function emailTokens($iSurveyID, $aResultTokens, $sType)
$mail->setSurvey($iSurveyID);
$mail->emailType = $sType;
$mail->replaceTokenAttributes = true;
$mail->addUrlsPlaceholders(array('OPTOUT', 'OPTIN', 'SURVEY'));
foreach ($aResultTokens as $aTokenRow) {
$mail = \LimeMailer::getInstance();
$mail->setToken($aTokenRow['token']);
Expand Down

0 comments on commit adf5a10

Please sign in to comment.