From 2e4c07048b93a557b78f9901bc66ce6e0d10f842 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 24 Jul 2015 00:10:23 -0700 Subject: [PATCH] CRM-13244 - CRM_Core_BAO_ActionSchedule - Use TokenProcessor instead of replaceComponentTokens --- CRM/Core/BAO/ActionSchedule.php | 19 +++++++++---------- Civi/Token/TokenCompatSubscriber.php | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index d27b6fae9a..3c6bc37788 100755 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -533,8 +533,6 @@ AND cas.entity_value = $id AND CRM_Core_BAO_ActionSchedule::setCommunicationLanguage($actionSchedule->communication_language, $preferred_language); } - $entityTokenParams = CRM_Core_BAO_ActionSchedule::prepareMailingTokens($tokenEntity, $tokenFields, $dao); - $isError = 0; $errorMsg = $toEmail = $toPhoneNumber = ''; @@ -559,7 +557,7 @@ AND cas.entity_value = $id AND $tokenProcessor = self::createTokenProcessor($actionSchedule); $tokenProcessor->addRow() ->context('contactId', $dao->contactID) - ->context('tmpTokenParams', $entityTokenParams); + ->tokens(CRM_Core_BAO_ActionSchedule::prepareMailingTokens($tokenEntity, $tokenFields, $dao)); foreach ($tokenProcessor->evaluate()->getRows() as $tokenRow) { if ($actionSchedule->mode == 'SMS' or $actionSchedule->mode == 'User_Preference') { self::sendReminderSms($tokenRow, $actionSchedule, $toPhoneNumber); @@ -1292,6 +1290,7 @@ WHERE m.owner_membership_id IS NOT NULL AND * @param $tokenFields * @param $dao * @return array + * Ex: array('activity' => array('subject' => 'Hello world)). */ protected static function prepareMailingTokens($tokenEntity, $tokenFields, $dao) { $entityTokenParams = array(); @@ -1303,16 +1302,16 @@ WHERE m.owner_membership_id IS NOT NULL AND $loc['city'] = $dao->city; $loc['state_province'] = CRM_Utils_Array::value($dao->state_province_id, $stateProvince); $loc['postal_code'] = $dao->postal_code; - $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Address::format($loc); + $entityTokenParams[$tokenEntity][$field] = CRM_Utils_Address::format($loc); } elseif ($field == 'info_url') { - $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE); + $entityTokenParams[$tokenEntity][$field] = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE); } elseif ($field == 'registration_url') { - $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE); + $entityTokenParams[$tokenEntity][$field] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE); } elseif (in_array($field, array('start_date', 'end_date', 'join_date', 'activity_date_time'))) { - $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Date::customFormat($dao->$field); + $entityTokenParams[$tokenEntity][$field] = CRM_Utils_Date::customFormat($dao->$field); } elseif ($field == 'balance') { if ($dao->entityTable == 'civicrm_contact') { @@ -1323,13 +1322,13 @@ WHERE m.owner_membership_id IS NOT NULL AND $balancePay = CRM_Utils_Array::value('balance', $info); $balancePay = CRM_Utils_Money::format($balancePay); } - $entityTokenParams["{$tokenEntity}." . $field] = $balancePay; + $entityTokenParams[$tokenEntity][$field] = $balancePay; } elseif ($field == 'fee_amount') { - $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Money::format($dao->$field); + $entityTokenParams[$tokenEntity][$field] = CRM_Utils_Money::format($dao->$field); } else { - $entityTokenParams["{$tokenEntity}." . $field] = $dao->$field; + $entityTokenParams[$tokenEntity][$field] = $dao->$field; } } return $entityTokenParams; diff --git a/Civi/Token/TokenCompatSubscriber.php b/Civi/Token/TokenCompatSubscriber.php index 1ce2d9ef1d..a0aa9bf689 100644 --- a/Civi/Token/TokenCompatSubscriber.php +++ b/Civi/Token/TokenCompatSubscriber.php @@ -101,7 +101,6 @@ class TokenCompatSubscriber implements EventSubscriberInterface { if (!empty($e->context['contact'])) { $e->string = \CRM_Utils_Token::replaceContactTokens($e->string, $e->context['contact'], $isHtml, $e->message['tokens'], FALSE, $useSmarty); - $e->string = \CRM_Utils_Token::replaceComponentTokens($e->string, $e->context['contact'], $e->message['tokens'], $useSmarty, FALSE); // 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); -- 2.25.1