From da8e97903c1575a009a4c051ae260c8ee4548737 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 16 Aug 2022 07:42:23 +1200 Subject: [PATCH] Remove token case_id handling --- CRM/Activity/Tokens.php | 27 ------------------- .../Form/Task/PDFLetterCommonTest.php | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/CRM/Activity/Tokens.php b/CRM/Activity/Tokens.php index 21fcd840c6..40d36e8218 100644 --- a/CRM/Activity/Tokens.php +++ b/CRM/Activity/Tokens.php @@ -81,38 +81,11 @@ class CRM_Activity_Tokens extends CRM_Core_EntityTokens { parent::evaluateToken($row, $entity, $realField, $prefetch); $row->format('text/plain')->tokens($entity, $field, $row->tokens['activity'][$realField]); } - elseif ($field === 'case_id') { - // An activity can be linked to multiple cases so case_id is always an array. - // We just return the first case ID for the token. - // this weird hack might exist because apiv3 is weird & - $caseID = CRM_Core_DAO::singleValueQuery('SELECT case_id FROM civicrm_case_activity WHERE activity_id = %1 LIMIT 1', [1 => [$activityId, 'Integer']]); - $row->tokens($entity, $field, $caseID ?? ''); - } else { parent::evaluateToken($row, $entity, $field, $prefetch); } } - /** - * Get tokens that are special or calculated for this entity. - * - * @return array|array[] - */ - protected function getBespokeTokens(): array { - $tokens = []; - if (CRM_Core_Component::isEnabled('CiviCase')) { - $tokens['case_id'] = [ - 'title' => ts('Activity Case ID'), - 'name' => 'case_id', - 'type' => 'calculated', - 'options' => NULL, - 'data_type' => 'Integer', - 'audience' => 'user', - ]; - } - return $tokens; - } - /** * Get fields historically not advertised for tokens. * diff --git a/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php b/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php index c122c74a23..349e3c9196 100644 --- a/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php +++ b/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php @@ -78,7 +78,7 @@ class CRM_Activity_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase { '{activity.activity_type_id:label}' => 'Activity Type', '{activity.status_id:label}' => 'Activity Status', '{activity.campaign_id:label}' => 'Campaign', - '{activity.case_id}' => 'Activity Case ID', + '{activity.case_id}' => 'Case ID', ]; } -- 2.25.1