From d20c4dadf2da83b20ba026f4584c27346890f1db Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 5 Feb 2014 14:15:59 +1300 Subject: [PATCH] CRM-13967 allow additional of anonymous tokens for logged out users when viewing mailing ---------------------------------------- * CRM-13967: Public Mailing View page doesn't render hook tokens http://issues.civicrm.org/jira/browse/CRM-13967 --- CRM/Mailing/Page/View.php | 10 ++++++++++ CRM/Utils/Token.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/CRM/Mailing/Page/View.php b/CRM/Mailing/Page/View.php index 42cb594f20..7d9129798d 100644 --- a/CRM/Mailing/Page/View.php +++ b/CRM/Mailing/Page/View.php @@ -129,6 +129,16 @@ class CRM_Mailing_Page_View extends CRM_Core_Page { } else { $details = array('test'); + //get tokens that are not contact specific resolved + $params = array('contact_id' => 0); + $details = CRM_Utils_Token::getAnonymousTokenDetails($params, + $returnProperties, + TRUE, TRUE, NULL, + $this->_mailing->getFlattenedTokens(), + get_class($this) + ); + + $details = $details[0][0]; $contactId = 0; } $mime = &$this->_mailing->compose(NULL, NULL, NULL, $contactId, diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 2d659e5edd..0f3c069a4e 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1135,6 +1135,39 @@ class CRM_Utils_Token { return $details; } + /** + * Call hooks on tokens for anonymous users - contact id is set to 0 - this allows non-contact + * specific tokens to be rendered + * + * @param array $contactIDs - this should always be array(0) or its not anonymous - left to keep signature same + * as main fn + * @param string $returnProperties + * @param boolean $skipOnHold + * @param boolean $skipDeceased + * @param string $extraParams + * @param array $tokens + * @param string $className sent as context to the hook + * @param string $jobID + * @return array contactDetails with hooks swapped out + */ + function getAnonymousTokenDetails($contactIDs = array(0), + $returnProperties = NULL, + $skipOnHold = TRUE, + $skipDeceased = TRUE, + $extraParams = NULL, + $tokens = array(), + $className = NULL, + $jobID = NULL) { + $details = array(0 => array()); + // also call a hook and get token details + CRM_Utils_Hook::tokenValues($details[0], + $contactIDs, + $jobID, + $tokens, + $className + ); + return $details; + } /** * gives required details of contribuion in an indexed array format so we * can iterate in a nice loop and do token evaluation -- 2.25.1