From 82d80434ad71047d45100c7a100de1967fe54215 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 12 Oct 2021 14:24:49 +1300 Subject: [PATCH] dev/core#2895 handle case ids passed via url --- CRM/Case/Form/Task.php | 9 +++++++++ CRM/Case/Form/Task/Email.php | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CRM/Case/Form/Task.php b/CRM/Case/Form/Task.php index 863a3c58f5de..b52a37bdd0a2 100644 --- a/CRM/Case/Form/Task.php +++ b/CRM/Case/Form/Task.php @@ -114,4 +114,13 @@ protected function getContactIDs(): array { ); } + /** + * Get the token processor schema required to list any tokens for this task. + * + * @return array + */ + protected function getTokenSchema(): array { + return ['contactId', 'caseId']; + } + } diff --git a/CRM/Case/Form/Task/Email.php b/CRM/Case/Form/Task/Email.php index 9c72c8e3d116..d3d742106d8d 100644 --- a/CRM/Case/Form/Task/Email.php +++ b/CRM/Case/Form/Task/Email.php @@ -33,6 +33,11 @@ public function isSearchContext(): bool { /** * List available tokens for this form. * + * @todo - this is not standard behaviour. We should either stop filtering + * case tokens by type and just remove this function (which would allow + * domain tokens to show up too) or + * resolve https://lab.civicrm.org/dev/core/-/issues/2788 + * * @return array * @throws \CRM_Core_Exception */ @@ -70,14 +75,18 @@ protected function getSubject():string { * Get the result rows to email. * * @return array + * + * @throws \CRM_Core_Exception */ - protected function getRows(): array { - // format contact details array to handle multiple emails from same contact - $rows = parent::getRows(); - foreach ($rows as $index => $row) { - $rows[$index]['schema']['caseId'] = $this->getCaseID(); + protected function getRowsForEmails(): array { + $formattedContactDetails = []; + foreach ($this->getEmails() as $details) { + $contactID = $details['contact_id']; + $index = $contactID . '::' . $details['email']; + $formattedContactDetails[$index] = $details; + $formattedContactDetails[$index]['schema'] = ['caseId' => $this->getCaseID()]; } - return $rows; + return $formattedContactDetails; } }