Skip to content
Snippets Groups Projects
Commit da8e9790 authored by Eileen McNaughton's avatar Eileen McNaughton
Browse files

Remove token case_id handling

parent c318f0dd
Branches
Tags
No related merge requests found
......@@ -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.
*
......
......@@ -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',
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment