// If we have had a contact email used here the value returned from the line above will be the
// numerical key where as $from for use in the sendEmail in Activity needs to be of format of "To Name" <toemailaddress>
$from = CRM_Utils_Mail::formatFromAddress($from);
- $subject = $formValues['subject'];
$ccArray = $formValues['cc_id'] ? explode(',', $formValues['cc_id']) : [];
$cc = $this->getEmailString($ccArray);
$bcc = $this->getEmailString($bccArray);
$additionalDetails .= empty($bccArray) ? '' : "\nbcc : " . $this->getEmailUrlString($bccArray);
- // CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
- if (isset($this->_caseId) && is_numeric($this->_caseId)) {
- $hash = substr(sha1(CIVICRM_SITE_KEY . $this->_caseId), 0, 7);
- $subject = "[case #$hash] $subject";
- }
-
// format contact details array to handle multiple emails from same contact
$formattedContactDetails = [];
foreach ($this->_contactIds as $key => $contactId) {
// send the mail
list($sent, $activityId) = CRM_Activity_BAO_Activity::sendEmail(
$formattedContactDetails,
- $subject,
+ $this->getSubject($formValues['subject']),
$formValues['text_message'],
$formValues['html_message'],
NULL,
return $attachments;
}
+ /**
+ * Get the subject for the message.
+ *
+ * The case handling should possibly be on the case form.....
+ *
+ * @param string $subject
+ *
+ * @return string
+ */
+ protected function getSubject(string $subject):string {
+ // CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
+ if (isset($this->_caseId) && is_numeric($this->_caseId)) {
+ $hash = substr(sha1(CIVICRM_SITE_KEY . $this->_caseId), 0, 7);
+ $subject = "[case #$hash] $subject";
+ }
+ return $subject;
+ }
+
}