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 354c627 commit cde4ccd
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions CRM/Case/Form/Task/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,36 @@ 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 = [];
$contactIDSFromUrl = CRM_Utils_Request::retrieve('cid', 'CommaSeparatedIntegers', $this);
$caseIDs = explode(CRM_Utils_Request::retrieve('caseid', 'String', $this), '');
$caseID = (count($caseIDs) === 1) ? $caseIDs[0] : NULL;

if (!empty($contactIDSFromUrl) && !$caseID) {
$contactIDS = explode($contactIDSFromUrl, '');
foreach ($this->getEmails() as $details) {
$contactID = $details['contact_id'];
$index = $contactID . '::' . $details['email'];
$formattedContactDetails[$index] = $details;
if (in_array($contactID, $contactIDS, TRUE)) {
$index = array_search($contactID, $contactIDS, FALSE);
$formattedContactDetails[$index]['schema'] = ['caseId' => $caseIDs[$index]];
}
}
return $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 cde4ccd

Please sign in to comment.