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

Commit

Permalink
Also use simple tokens for the newsletter subscription modules (see #…
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Nov 20, 2014
1 parent d0d81e2 commit 81af96a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions contao/modules/ModuleSubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,19 @@ protected function addRecipient()
// Get the channels
$objChannel = \NewsletterChannelModel::findByIds($arrChannels);

// Prepare the e-mail text
$strText = str_replace('##token##', $strToken, $this->nl_subscribe);
$strText = str_replace('##domain##', \Idna::decode(\Environment::get('host')), $strText);
$strText = str_replace('##link##', \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ((\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false) ? '&' : '?') . 'token=' . $strToken, $strText);
$strText = str_replace(array('##channel##', '##channels##'), implode("\n", $objChannel->fetchEach('title')), $strText);
// Prepare the simple token data
$arrData = array();
$arrData['token'] = $strToken;
$arrData['domain'] = \Idna::decode(\Environment::get('host'));
$arrData['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ((\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false) ? '&' : '?') . 'token=' . $strToken;
$arrData['channel'] = $arrData['channels'] = implode("\n", $objChannel->fetchEach('title'));

// Activation e-mail
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['nl_subject'], \Idna::decode(\Environment::get('host')));
$objEmail->text = $strText;
$objEmail->text = \String::parseSimpleTokens($this->nl_subscribe, $arrData);
$objEmail->sendTo($varInput);

// Redirect to the jumpTo page
Expand Down
9 changes: 5 additions & 4 deletions contao/modules/ModuleUnsubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,17 @@ protected function removeRecipient()
}
}

// Prepare the e-mail text
$strText = str_replace('##domain##', \Idna::decode(\Environment::get('host')), $this->nl_unsubscribe);
$strText = str_replace(array('##channel##', '##channels##'), implode("\n", $arrChannels), $strText);
// Prepare the simple token data
$arrData = array();
$arrData['domain'] = \Idna::decode(\Environment::get('host'));
$arrData['channel'] = $arrData['channels'] = implode("\n", $arrChannels);

// Confirmation e-mail
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['nl_subject'], \Idna::decode(\Environment::get('host')));
$objEmail->text = $strText;
$objEmail->text = \String::parseSimpleTokens($this->nl_unsubscribe, $arrData);
$objEmail->sendTo($varInput);

// Redirect to the jumpTo page
Expand Down

0 comments on commit 81af96a

Please sign in to comment.