From ee70f3320e2015f94b8b95447adb0cb078c0b61d Mon Sep 17 00:00:00 2001 From: kurund Date: Wed, 21 Aug 2013 19:41:08 +0530 Subject: [PATCH] CRM-13161, fixed token evaluation ---------------------------------------- * CRM-13161: Greetings are not evaluated correctly if it includes prefix / suffix http://issues.civicrm.org/jira/browse/CRM-13161 --- CRM/Utils/Token.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 0e9981f882..28ca9417d3 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -663,6 +663,11 @@ class CRM_Utils_Token { } else { $value = CRM_Utils_Array::retrieveValueRecursive($contact, $token); + + // note that incase of pseudoconstants we get array ( 0 => id, 1 => label ) + if (is_array($value)) { + $value = $value[1]; + } } if (!$html) { @@ -1185,6 +1190,10 @@ class CRM_Utils_Token { if (!empty($greetingTokens)) { // first use the existing contact object for token replacement if (!empty($contactDetails)) { + // unset id's to get labels for the pseudoconstants + foreach ( array('individual_prefix', 'individual_suffix', 'gender') as $field ) { + unset($contactDetails[0][$contactId][$field]); + } $tokenString = CRM_Utils_Token::replaceContactTokens($tokenString, $contactDetails, TRUE, $greetingTokens, TRUE); } -- 2.25.1