Remove token case_id handling
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 15 Aug 2022 19:42:23 +0000 (07:42 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 15 Aug 2022 19:42:23 +0000 (07:42 +1200)
CRM/Activity/Tokens.php
tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php

index 21fcd840c6833c8f7a23cac8379823b48b5bd0ca..40d36e8218f1fc720bcdde5b7855a2438d0b7bbc 100644 (file)
@@ -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.
    *
index c122c74a23884d162afb26571bf5a229c5fa1f12..349e3c91968c120eee633abe0e83b8cc4a3ab121 100644 (file)
@@ -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',
     ];
   }