Skip to content

Commit

Permalink
dev/core#2895 handle case ids passed via url
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Oct 12, 2021
1 parent bfeae56 commit 82d8043
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CRM/Case/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

}
21 changes: 15 additions & 6 deletions CRM/Case/Form/Task/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}

}

0 comments on commit 82d8043

Please sign in to comment.