Skip to content

Commit

Permalink
New feature: @@OPTOUTURL@@ & @@OPTINURL@@ placeholders for invitation…
Browse files Browse the repository at this point in the history
…/reminder emails
  • Loading branch information
c-schmitz committed Dec 11, 2017
1 parent 38be325 commit 192cc30
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions application/helpers/admin/token_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,12 @@ function emailTokens($iSurveyID, $aResultTokens, $sType)
$fieldsarray["{OPTOUTURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optout/tokens/langcode/".trim($aTokenRow['language'])."/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
$fieldsarray["{OPTINURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optin/tokens/langcode/".trim($aTokenRow['language'])."/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
$fieldsarray["{SURVEYURL}"] = Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$iSurveyID}/token/{$aTokenRow['token']}/lang/".trim($aTokenRow['language'])."/");

$aBareboneURLs = [];
if ($bHtml) {
foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key) {
$url = $fieldsarray["{{$key}URL}"];
$fieldsarray["{{$key}URL}"] = "<a href='{$url}'>".htmlspecialchars($url).'</a>';
if ($key == 'SURVEY') {
$barebone_link = $url;
}
$aBareboneURLs['@@'.$key.'URL@@']=$fieldsarray["{{$key}URL}"];
}
}

Expand Down Expand Up @@ -132,9 +130,9 @@ function emailTokens($iSurveyID, $aResultTokens, $sType)
$modsubject = $sSubject;
$modmessage = $sMessage;

if (isset($barebone_link)) {
$modsubject = str_replace("@@SURVEYURL@@", $barebone_link, $modsubject);
$modmessage = str_replace("@@SURVEYURL@@", $barebone_link, $modmessage);
foreach ($aBareboneURLs as $sSearch=>$sReplace) {
$modsubject = str_replace($sSearch, $sReplace, $modsubject);
$modmessage = str_replace($sSearch, $sReplace, $modmessage);
}

$modsubject = ReplaceFields($modsubject, $fieldsarray);
Expand Down

0 comments on commit 192cc30

Please sign in to comment.