X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContribute%2FTokens.php;h=40a5c832a9beeb8cf8fc7ec5818c657fc44c27f5;hb=d7b226af900687b6e59e098329fbedf6e0d861a7;hp=d199af8a3700b1a9b534a5aedf10de2852e95834;hpb=da82de8fc3b033f0c5076f790d0755592d4ba46d;p=civicrm-core.git diff --git a/CRM/Contribute/Tokens.php b/CRM/Contribute/Tokens.php index d199af8a37..40a5c832a9 100644 --- a/CRM/Contribute/Tokens.php +++ b/CRM/Contribute/Tokens.php @@ -4,7 +4,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -85,15 +85,28 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { $tokens['source'] = ts('Contribution Source'); $tokens['status'] = ts('Contribution Status'); $tokens['type'] = ts('Financial Type'); + $tokens = array_merge($tokens, $this->getCustomTokens('Contribution')); parent::__construct('contribution', $tokens); } + /** + * Check if the token processor is active. + * + * @param \Civi\Token\TokenProcessor $processor + * + * @return bool + */ public function checkActive(\Civi\Token\TokenProcessor $processor) { return !empty($processor->context['actionMapping']) && $processor->context['actionMapping']->getEntity() === 'civicrm_contribution'; } + /** + * Alter action schedule query. + * + * @param \Civi\ActionSchedule\Event\MailingQueryEvent $e + */ public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQueryEvent $e) { if ($e->mapping->getEntity() !== 'civicrm_contribution') { return; @@ -109,18 +122,7 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { } /** - * Evaluate the content of a single token. - * - * @param \Civi\Token\TokenRow $row - * The record for which we want token values. - * @param string $entity - * @param string $field - * The name of the token field. - * @param mixed $prefetch - * Any data that was returned by the prefetch(). - * - * @return mixed - * @throws \CRM_Core_Exception + * @inheritDoc */ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) { $actionSearchResult = $row->context['actionSearchResult']; @@ -134,6 +136,9 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { elseif (isset($aliasTokens[$field])) { $row->dbToken($entity, $field, 'CRM_Contribute_BAO_Contribution', $aliasTokens[$field], $fieldValue); } + 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); }