Skip to content
Snippets Groups Projects
Unverified Commit 64ada38c authored by colemanw's avatar colemanw Committed by GitHub
Browse files

Merge pull request #14591 from JKingsnorth/dev/core#1064

#1064 Allow personalised 'view in browser' links for mass emails
parents e6568db5 b56b8b0e
No related branches found
No related tags found
No related merge requests found
......@@ -477,6 +477,7 @@ class CRM_Core_SelectValues {
'{domain.address}' => ts('Domain (organization) address'),
'{domain.phone}' => ts('Domain (organization) phone'),
'{domain.email}' => ts('Domain (organization) email'),
'{mailing.key}' => ts('Mailing key'),
'{mailing.name}' => ts('Mailing name'),
'{mailing.group}' => ts('Mailing group'),
'{mailing.viewUrl}' => ts('Mailing permalink'),
......
......@@ -81,6 +81,10 @@ class CRM_Mailing_Page_View extends CRM_Core_Page {
$this->_mailingID = CRM_Utils_Request::retrieve('id', 'String', CRM_Core_DAO::$_nullObject, TRUE);
}
// Retrieve contact ID and checksum from the URL
$cs = CRM_Utils_Request::retrieve('cs', 'String');
$cid = CRM_Utils_Request::retrieve('cid', 'Int');
// # CRM-7651
// override contactID from the function level if passed in
if (isset($contactID) &&
......@@ -88,6 +92,12 @@ class CRM_Mailing_Page_View extends CRM_Core_Page {
) {
$this->_contactID = $contactID;
}
// Support checksummed view of the mailing to replace tokens
elseif (!empty($cs) && !empty($cid) && CRM_Contact_BAO_Contact_Utils::validChecksum($cid, $cs)) {
$this->_contactID = $cid;
}
else {
$this->_contactID = CRM_Core_Session::getLoggedInContactID();
}
......
......@@ -26,6 +26,7 @@ class CRM_Mailing_Tokens extends \Civi\Token\AbstractTokenSubscriber {
public function __construct() {
parent::__construct('mailing', [
'id' => ts('Mailing ID'),
'key' => ts('Mailing Key'),
'name' => ts('Mailing Name'),
'group' => ts('Mailing Group(s)'),
'subject' => ts('Mailing Subject'),
......
......@@ -35,6 +35,7 @@ class CRM_Utils_Token {
],
'mailing' => [
'id',
'key',
'name',
'group',
'subject',
......@@ -450,6 +451,14 @@ class CRM_Utils_Token {
$value = $mailing ? $mailing->id : 'undefined';
break;
// Key is the ID, or the hash when the hash URLs setting is enabled
case 'key':
$value = $mailing->id;
if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($value)) {
$value = $hash;
}
break;
case 'name':
$value = $mailing ? $mailing->name : 'Mailing Name';
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment