elseif (isset($actionSearchResult->$field)) {
$row->tokens($entity, $field, $actionSearchResult->$field);
}
- elseif (\CRM_Core_BAO_CustomField::getKeyID($field)) {
- $row->customToken($entity, $field, $actionSearchResult->entity_id);
+ elseif ($cfID = \CRM_Core_BAO_CustomField::getKeyID($field)) {
+ $row->customToken($entity, $cfID, $actionSearchResult->entity_id);
}
else {
$row->tokens($entity, $field, '');
elseif (isset($aliasTokens[$field])) {
$row->dbToken($entity, $field, 'CRM_Contribute_BAO_Contribution', $aliasTokens[$field], $fieldValue);
}
- elseif (\CRM_Core_BAO_CustomField::getKeyID($field)) {
- $row->customToken($entity, $field, $actionSearchResult->entity_id);
+ elseif ($cfID = \CRM_Core_BAO_CustomField::getKeyID($field)) {
+ $row->customToken($entity, $cfID, $actionSearchResult->entity_id);
}
else {
$row->dbToken($entity, $field, 'CRM_Contribute_BAO_Contribution', $field, $fieldValue);
elseif (isset($actionSearchResult->$field)) {
$row->tokens($entity, $field, $actionSearchResult->$field);
}
- elseif (\CRM_Core_BAO_CustomField::getKeyID($field)) {
- $row->customToken($entity, $field, $actionSearchResult->entity_id);
+ elseif ($cfID = \CRM_Core_BAO_CustomField::getKeyID($field)) {
+ $row->customToken($entity, $cfID, $actionSearchResult->entity_id);
}
else {
$row->tokens($entity, $field, '');
elseif (isset($actionSearchResult->$field)) {
$row->tokens($entity, $field, $actionSearchResult->$field);
}
- elseif (\CRM_Core_BAO_CustomField::getKeyID($field)) {
- $row->customToken($entity, $field, $actionSearchResult->entity_id);
+ elseif ($cfID = \CRM_Core_BAO_CustomField::getKeyID($field)) {
+ $row->customToken($entity, $cfID, $actionSearchResult->entity_id);
}
else {
$row->tokens($entity, $field, '');
if (!empty($messageTokens['contact'])) {
foreach ($messageTokens['contact'] as $token) {
if (\CRM_Core_BAO_CustomField::getKeyID($token)) {
- $row->customToken('Contact', $token, $contactId);
+ $contact[$token] = civicrm_api3('Contact', 'getvalue', array(
+ 'return' => $token,
+ 'id' => $contactId,
+ ));
}
}
}
$e->string = \CRM_Utils_Token::replaceDomainTokens($e->string, \CRM_Core_BAO_Domain::getDomain(), $isHtml, $e->message['tokens'], $useSmarty);
if (!empty($e->context['contact'])) {
- \CRM_Utils_Token::replaceGreetingTokens($e->string, $e->context['contact'], $e->context['contact']['contact_id'], NULL, FALSE);
-
- $e->string = \CRM_Utils_Token::replaceContactTokens($e->string, $e->context['contact'], $isHtml, $e->message['tokens'], FALSE, $useSmarty);
+ $e->string = \CRM_Utils_Token::replaceContactTokens($e->string, $e->context['contact'], $isHtml, $e->message['tokens'], TRUE, $useSmarty);
// FIXME: This may depend on $contact being merged with hook values.
$e->string = \CRM_Utils_Token::replaceHookTokens($e->string, $e->context['contact'], $e->context['hookTokenCategories'], $isHtml, $useSmarty);
+
+ \CRM_Utils_Token::replaceGreetingTokens($e->string, $e->context['contact'], $e->context['contact']['contact_id'], NULL, $useSmarty);
}
if ($useSmarty) {
* Update the value of a custom field token.
*
* @param string $entity
- * @param string $fieldName
- * @param string $entityID
+ * @param int $customFieldID
+ * @param int $entityID
* @return TokenRow
*/
- public function customToken($entity, $fieldName, $entityID) {
+ public function customToken($entity, $customFieldID, $entityID) {
+ $customFieldName = "custom_" . $customFieldID;
$fieldValue = civicrm_api3($entity, 'getvalue', array(
- 'return' => $fieldName,
+ 'return' => $customFieldName,
'id' => $entityID,
));
- return $this->tokens($entity, $fieldName, $fieldValue);
+
+ // format the raw custom field value into proper display value
+ if ($fieldValue) {
+ $fieldValue = \CRM_Core_BAO_CustomField::displayValue($fieldValue, $customFieldID);
+ }
+
+ return $this->tokens($entity, $customFieldName, $fieldValue);
}
/**