Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 3.1.3
-
Fix Version/s: 3.3.alpha
-
Component/s: Core CiviCRM
-
Labels:None
Description
This patch is a fix for the task contribution/pdf to get tokens from token_hook functions but since the code is in the MessageTemplates.php file I expect it will affect other messages as well. (it should affect the contribution receipt sent from a payment processor transaction)
I will be working with this hook over the next bit so will add any observatons. I couldn't think of when this code would be called & the contactId wouldn't be set. so I couldn't think how to test that, so I have left it unchanged
Index: CRM/Core/BAO/MessageTemplates.php
===================================================================
— CRM/Core/BAO/MessageTemplates.php (revision 26904)
+++ CRM/Core/BAO/MessageTemplates.php (working copy)
@@ -407,7 +407,25 @@
$text = CRM_Utils_Token::replaceContactTokens($text, $contact, false, $tokens['text']);
$html = CRM_Utils_Token::replaceContactTokens($html, $contact, false, $tokens['html']);
}
-
+ //substitue in values from hook
+ CRM_Utils_Hook::tokenValues( $details, $params[contactId]);
+ if ($params['contactId'])
else
{ + // nothing here as yet as not sure an example to test it on but hook should still have + // chance to substitue as some tokens could be domain wide (e.g. multisite) + + }+ $tokens = array();
+ CRM_Utils_Hook::tokens( $tokens );
+ $categories = array_keys( $tokens );
+ //for instances where there is no contactID the next few lines can be expected to leave the message
+ // text unchanged. Passing in the $details array should work but not done yet due to
+ // no examples to test on
+ $subject = CRM_Utils_Token::replaceHookTokens ( $text,$contact[$params[contactId]] , $categories, true );
+ $text = CRM_Utils_Token::replaceHookTokens ( $text,$contact[$params[contactId]] , $categories, true );
+ $html = CRM_Utils_Token::replaceHookTokens ( $html,$contact[$params[contactId]] , $categories, true );
+
// strip whitespace from ends and turn into a single line
$subject = "
$subject
{/strip}";