From da5c41f1bb9f21aa303c3551b910c91c7619aca8 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 863a3c58f5..b52a37bdd0 100644 --- a/CRM/Case/Form/Task.php +++ b/CRM/Case/Form/Task.php @@ -114,4 +114,13 @@ class CRM_Case_Form_Task extends CRM_Core_Form_Task { ); } + /** + * 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 9c72c8e3d1..06a77451c1 100644 --- a/CRM/Case/Form/Task/Email.php +++ b/CRM/Case/Form/Task/Email.php @@ -33,6 +33,11 @@ class CRM_Case_Form_Task_Email extends CRM_Case_Form_Task { /** * 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 @@ class CRM_Case_Form_Task_Email extends CRM_Case_Form_Task { * 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'] = ['contactId' => $contactID, 'caseId' => $this->getCaseID()]; } - return $rows; + return $formattedContactDetails; } } -- 2.25.1