Merge pull request #21640 from eileenmcnaughton/edge
[civicrm-core.git] / CRM / Core / BAO / MessageTemplate.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
965ff8f1 18use Civi\Api4\Email;
c4d7103b 19use Civi\Api4\MessageTemplate;
3dccbd4b 20use Civi\WorkflowMessage\WorkflowMessage;
c4d7103b 21
6a488035 22require_once 'Mail/mime.php';
b5c2afd0
EM
23
24/**
8eedd10a 25 * Class CRM_Core_BAO_MessageTemplate.
b5c2afd0 26 */
c6327d7d 27class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate {
6a488035
TO
28
29 /**
fe482240 30 * Fetch object based on array of properties.
6a488035 31 *
6a0b768e
TO
32 * @param array $params
33 * (reference ) an assoc array of name/value pairs.
34 * @param array $defaults
35 * (reference ) an assoc array to hold the flattened values.
6a488035 36 *
8f86a9e5 37 * @return CRM_Core_DAO_MessageTemplate
6a488035 38 */
00be9182 39 public static function retrieve(&$params, &$defaults) {
c6327d7d 40 $messageTemplates = new CRM_Core_DAO_MessageTemplate();
6a488035
TO
41 $messageTemplates->copyValues($params);
42 if ($messageTemplates->find(TRUE)) {
43 CRM_Core_DAO::storeValues($messageTemplates, $defaults);
44 return $messageTemplates;
45 }
46 return NULL;
47 }
48
49 /**
fe482240 50 * Update the is_active flag in the db.
6a488035 51 *
6a0b768e
TO
52 * @param int $id
53 * Id of the database record.
54 * @param bool $is_active
55 * Value we want to set the is_active field.
6a488035 56 *
8a4fede3 57 * @return bool
58 * true if we found and updated the object, else false
6a488035 59 */
00be9182 60 public static function setIsActive($id, $is_active) {
c6327d7d 61 return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_MessageTemplate', $id, 'is_active', $is_active);
6a488035
TO
62 }
63
64 /**
fe482240 65 * Add the Message Templates.
6a488035 66 *
6a0b768e
TO
67 * @param array $params
68 * Reference array contains the values submitted by the form.
6a488035 69 *
6a488035
TO
70 *
71 * @return object
8f86a9e5 72 * @throws \CiviCRM_API3_Exception
73 * @throws \Civi\API\Exception\UnauthorizedException
6a488035 74 */
00be9182 75 public static function add(&$params) {
781ed314
SL
76 // System Workflow Templates have a specific wodkflow_id in them but normal user end message templates don't
77 // If we have an id check to see if we are update, and need to check if original is a system workflow or not.
78 $systemWorkflowPermissionDeniedMessage = 'Editing or creating system workflow messages requires edit system workflow message templates permission or the edit message templates permission';
79 $userWorkflowPermissionDeniedMessage = 'Editing or creating user driven workflow messages requires edit user-driven message templates or the edit message templates permission';
80 if (!empty($params['check_permissions'])) {
81 if (!CRM_Core_Permission::check('edit message templates')) {
82 if (!empty($params['id'])) {
83 $details = civicrm_api3('MessageTemplate', 'getSingle', ['id' => $params['id']]);
0c5781ae 84 if (!empty($details['workflow_id']) || !empty($details['workflow_name'])) {
781ed314
SL
85 if (!CRM_Core_Permission::check('edit system workflow message templates')) {
86 throw new \Civi\API\Exception\UnauthorizedException(ts('%1', [1 => $systemWorkflowPermissionDeniedMessage]));
87 }
88 }
89 elseif (!CRM_Core_Permission::check('edit user-driven message templates')) {
90 throw new \Civi\API\Exception\UnauthorizedException(ts('%1', [1 => $userWorkflowPermissionDeniedMessage]));
91 }
92 }
93 else {
0c5781ae 94 if (!empty($params['workflow_id']) || !empty($params['workflow_name'])) {
36111e9f
SL
95 if (!CRM_Core_Permission::check('edit system workflow message templates')) {
96 throw new \Civi\API\Exception\UnauthorizedException(ts('%1', [1 => $systemWorkflowPermissionDeniedMessage]));
97 }
781ed314 98 }
36111e9f 99 elseif (!CRM_Core_Permission::check('edit user-driven message templates')) {
781ed314
SL
100 throw new \Civi\API\Exception\UnauthorizedException(ts('%1', [1 => $userWorkflowPermissionDeniedMessage]));
101 }
102 }
103 }
104 }
3c8059c8
KM
105 $hook = empty($params['id']) ? 'create' : 'edit';
106 CRM_Utils_Hook::pre($hook, 'MessageTemplate', CRM_Utils_Array::value('id', $params), $params);
c39c0aa1 107
90a73810 108 if (!empty($params['file_id']) && is_array($params['file_id']) && count($params['file_id'])) {
109 $fileParams = $params['file_id'];
110 unset($params['file_id']);
111 }
112
0c5781ae
TO
113 // The workflow_id and workflow_name should be sync'd. But what mix of inputs do we have to work with?
114 switch ((empty($params['workflow_id']) ? '' : 'id') . (empty($params['workflow_name']) ? '' : 'name')) {
115 case 'id':
116 $params['workflow_name'] = array_search($params['workflow_id'], self::getWorkflowNameIdMap());
117 break;
118
119 case 'name':
120 $params['workflow_id'] = self::getWorkflowNameIdMap()[$params['workflow_name']] ?? NULL;
121 break;
122
123 case 'idname':
124 $map = self::getWorkflowNameIdMap();
125 if ($map[$params['workflow_name']] != $params['workflow_id']) {
126 throw new CRM_Core_Exception("The workflow_id and workflow_name are mismatched. Note: You only need to submit one or the other.");
127 }
128 break;
129
130 case '':
131 // OK, don't care.
132 break;
133
134 default:
135 throw new \RuntimeException("Bad code");
136 }
137
c6327d7d 138 $messageTemplates = new CRM_Core_DAO_MessageTemplate();
6a488035 139 $messageTemplates->copyValues($params);
6a488035 140 $messageTemplates->save();
c39c0aa1 141
90a73810 142 if (!empty($fileParams)) {
143 $params['file_id'] = $fileParams;
04a76231 144 CRM_Core_BAO_File::filePostProcess(
90a73810 145 $params['file_id']['location'],
146 NULL,
147 'civicrm_msg_template',
148 $messageTemplates->id,
149 NULL,
150 TRUE,
151 $params['file_id'],
152 'file_id',
153 $params['file_id']['type']
154 );
90a73810 155 }
156
c9606a53 157 CRM_Utils_Hook::post($hook, 'MessageTemplate', $messageTemplates->id, $messageTemplates);
6a488035
TO
158 return $messageTemplates;
159 }
160
161 /**
fe482240 162 * Delete the Message Templates.
6a488035 163 *
100fef9d 164 * @param int $messageTemplatesID
8f86a9e5 165 *
166 * @throws \CRM_Core_Exception
6a488035 167 */
00be9182 168 public static function del($messageTemplatesID) {
6a488035
TO
169 // make sure messageTemplatesID is an integer
170 if (!CRM_Utils_Rule::positiveInteger($messageTemplatesID)) {
8f86a9e5 171 throw new CRM_Core_Exception(ts('Invalid Message template'));
6a488035
TO
172 }
173
174 // Set mailing msg template col to NULL
175 $query = "UPDATE civicrm_mailing
176 SET msg_template_id = NULL
177 WHERE msg_template_id = %1";
5f351616 178
be2fb01f 179 $params = [1 => [$messageTemplatesID, 'Integer']];
6a488035
TO
180 CRM_Core_DAO::executeQuery($query, $params);
181
c6327d7d 182 $messageTemplates = new CRM_Core_DAO_MessageTemplate();
6a488035
TO
183 $messageTemplates->id = $messageTemplatesID;
184 $messageTemplates->delete();
185 CRM_Core_Session::setStatus(ts('Selected message template has been deleted.'), ts('Deleted'), 'success');
186 }
187
188 /**
fe482240 189 * Get the Message Templates.
6a488035 190 *
6a488035 191 *
dd244018
EM
192 * @param bool $all
193 *
ad37ac8e 194 * @param bool $isSMS
195 *
8f86a9e5 196 * @return array
6a488035 197 */
00be9182 198 public static function getMessageTemplates($all = TRUE, $isSMS = FALSE) {
be2fb01f 199 $msgTpls = [];
6a488035 200
c6327d7d 201 $messageTemplates = new CRM_Core_DAO_MessageTemplate();
6a488035 202 $messageTemplates->is_active = 1;
1e035d58 203 $messageTemplates->is_sms = $isSMS;
6a488035
TO
204
205 if (!$all) {
206 $messageTemplates->workflow_id = 'NULL';
207 }
208 $messageTemplates->find();
209 while ($messageTemplates->fetch()) {
210 $msgTpls[$messageTemplates->id] = $messageTemplates->msg_title;
211 }
212 asort($msgTpls);
213 return $msgTpls;
214 }
215
6a488035 216 /**
8eedd10a 217 * Revert a message template to its default subject+text+HTML state.
6a488035 218 *
608e6658 219 * @param int $id id of the template
8f86a9e5 220 *
221 * @throws \CRM_Core_Exception
6a488035 222 */
00be9182 223 public static function revert($id) {
608e6658 224 $diverted = new CRM_Core_BAO_MessageTemplate();
6a488035
TO
225 $diverted->id = (int) $id;
226 $diverted->find(1);
227
228 if ($diverted->N != 1) {
8f86a9e5 229 throw new CRM_Core_Exception(ts('Did not find a message template with id of %1.', [1 => $id]));
6a488035
TO
230 }
231
608e6658 232 $orig = new CRM_Core_BAO_MessageTemplate();
6a488035
TO
233 $orig->workflow_id = $diverted->workflow_id;
234 $orig->is_reserved = 1;
235 $orig->find(1);
236
237 if ($orig->N != 1) {
8f86a9e5 238 throw new CRM_Core_Exception(ts('Message template with id of %1 does not have a default to revert to.', [1 => $id]));
6a488035
TO
239 }
240
241 $diverted->msg_subject = $orig->msg_subject;
242 $diverted->msg_text = $orig->msg_text;
243 $diverted->msg_html = $orig->msg_html;
244 $diverted->pdf_format_id = is_null($orig->pdf_format_id) ? 'null' : $orig->pdf_format_id;
245 $diverted->save();
246 }
247
fa78ca24
TO
248 /**
249 * Render a message template.
250 *
251 * This method is very similar to `sendTemplate()` - accepting most of the same arguments
252 * and emitting similar hooks. However, it specifically precludes the possibility of
253 * sending a message. It only renders.
254 *
255 * @param $params
256 * Mixed render parameters. See sendTemplate() for more details.
257 * @return array
258 * Rendered message, consistent of 'subject', 'text', 'html'
259 * Ex: ['subject' => 'Hello Bob', 'text' => 'It\'s been so long since we sent you an automated notification!']
260 * @throws \API_Exception
261 * @throws \CRM_Core_Exception
262 * @see sendTemplate()
263 */
264 public static function renderTemplate($params) {
265 $forbidden = ['from', 'toName', 'toEmail', 'cc', 'bcc', 'replyTo'];
266 $intersect = array_intersect($forbidden, array_keys($params));
267 if (!empty($intersect)) {
268 throw new \CRM_Core_Exception(sprintf("renderTemplate() received forbidden fields (%s)",
269 implode(',', $intersect)));
270 }
271
272 $mailContent = [];
273 // sendTemplate has had an obscure feature - if you omit `toEmail`, then it merely renders.
274 // At some point, we may want to invert the relation between renderTemplate/sendTemplate, but for now this is a smaller patch.
275 [$sent, $mailContent['subject'], $mailContent['text'], $mailContent['html']] = static::sendTemplate($params);
276 return $mailContent;
277 }
278
6a488035 279 /**
fe482240 280 * Send an email from the specified template based on an array of params.
6a488035 281 *
6a0b768e
TO
282 * @param array $params
283 * A string-keyed array of function params, see function body for details.
6a488035 284 *
a6c01b45 285 * @return array
16b10e64 286 * Array of four parameters: a boolean whether the email was sent, and the subject, text and HTML templates
8f86a9e5 287 * @throws \CRM_Core_Exception
c4d7103b 288 * @throws \API_Exception
6a488035 289 */
00be9182 290 public static function sendTemplate($params) {
3ace1ae5 291 $modelDefaults = [
3dccbd4b
TO
292 // instance of WorkflowMessageInterface, containing a list of data to provide to the message-template
293 'model' => NULL,
3ace1ae5 294 // Symbolic name of the workflow step. Matches the option-value-name of the template.
6a488035 295 'valueName' => NULL,
6a488035 296 // additional template params (other than the ones already set in the template singleton)
be2fb01f 297 'tplParams' => [],
0238a01e 298 // additional token params (passed to the TokenProcessor)
7a46f8e3 299 // INTERNAL: 'tokenContext' is currently only intended for use within civicrm-core only. For downstream usage, future updates will provide comparable public APIs.
0238a01e 300 'tokenContext' => [],
3ace1ae5
TO
301 // properties to import directly to the model object
302 'modelProps' => NULL,
303 // contact id if contact tokens are to be replaced; alias for tokenContext.contactId
304 'contactId' => NULL,
305 ];
306 $viewDefaults = [
307 // ID of the specific template to load
308 'messageTemplateID' => NULL,
309 // content of the message template
310 // Ex: ['msg_subject' => 'Hello {contact.display_name}', 'msg_html' => '...', 'msg_text' => '...']
311 // INTERNAL: 'messageTemplate' is currently only intended for use within civicrm-core only. For downstream usage, future updates will provide comparable public APIs.
312 'messageTemplate' => NULL,
313 // whether this is a test email (and hence should include the test banner)
314 'isTest' => FALSE,
315 // Disable Smarty?
316 'disableSmarty' => FALSE,
317 ];
318 $envelopeDefaults = [
6a488035
TO
319 // the From: header
320 'from' => NULL,
321 // the recipient’s name
322 'toName' => NULL,
323 // the recipient’s email - mail is sent only if set
324 'toEmail' => NULL,
325 // the Cc: header
326 'cc' => NULL,
327 // the Bcc: header
328 'bcc' => NULL,
329 // the Reply-To: header
330 'replyTo' => NULL,
331 // email attachments
332 'attachments' => NULL,
6a488035
TO
333 // filename of optional PDF version to add as attachment (do not include path)
334 'PDFFilename' => NULL,
be2fb01f 335 ];
6a488035 336
3dccbd4b
TO
337 // Allow WorkflowMessage to run any filters/mappings/cleanups.
338 $model = $params['model'] ?? WorkflowMessage::create($params['valueName'] ?? 'UNKNOWN');
339 $params = WorkflowMessage::exportAll(WorkflowMessage::importAll($model, $params));
340 unset($params['model']);
341 // Subsequent hooks use $params. Retaining the $params['model'] might be nice - but don't do it unless you figure out how to ensure data-consistency (eg $params['tplParams'] <=> $params['model']).
342 // If you want to expose the model via hook, consider interjecting a new Hook::alterWorkflowMessage($model) between `importAll()` and `exportAll()`.
343
3ace1ae5 344 $params = array_merge($modelDefaults, $viewDefaults, $envelopeDefaults, $params);
4335f229 345
ededcdab 346 CRM_Utils_Hook::alterMailParams($params, 'messageTemplate');
e2615a28 347 $mailContent = self::loadTemplate((string) $params['valueName'], $params['isTest'], $params['messageTemplateID'] ?? NULL, $params['groupName'] ?? '', $params['messageTemplate'], $params['subject'] ?? NULL);
c8025280 348
3151fc5d
TO
349 $params['tokenContext'] = array_merge([
350 'smarty' => (bool) !$params['disableSmarty'],
351 'contactId' => $params['contactId'],
352 ], $params['tokenContext']);
353 $rendered = CRM_Core_TokenSmarty::render(CRM_Utils_Array::subset($mailContent, ['text', 'html', 'subject']), $params['tokenContext'], $params['tplParams']);
354 if (isset($rendered['subject'])) {
355 $rendered['subject'] = trim(preg_replace('/[\r\n]+/', ' ', $rendered['subject']));
356 }
357 $nullSet = ['subject' => NULL, 'text' => NULL, 'html' => NULL];
358 $mailContent = array_merge($nullSet, $mailContent, $rendered);
4ee279f4 359
6a488035
TO
360 // send the template, honouring the target user’s preferences (if any)
361 $sent = FALSE;
362
363 // create the params array
94993cf9 364 $params['subject'] = $mailContent['subject'];
14bf6806
AF
365 $params['text'] = $mailContent['text'];
366 $params['html'] = $mailContent['html'];
6a488035
TO
367
368 if ($params['toEmail']) {
965ff8f1
EM
369 // @todo - consider whether we really should be loading
370 // this based on 'the first email in the db that matches'.
371 // when we likely have the contact id. OTOH people probably barely
372 // use preferredMailFormat these days - the good fight against html
373 // emails was lost a decade ago...
97b745fe 374 $preferredMailFormatArray = Email::get(FALSE)->addWhere('email', '=', $params['toEmail'])->addSelect('contact_id.preferred_mail_format')->execute()->first();
375 $preferredMailFormat = $preferredMailFormatArray['contact_id.preferred_mail_format'] ?? 'Both';
965ff8f1
EM
376
377 if ($preferredMailFormat === 'HTML') {
6a488035
TO
378 $params['text'] = NULL;
379 }
965ff8f1 380 if ($preferredMailFormat === 'Text') {
6a488035
TO
381 $params['html'] = NULL;
382 }
383
384 $config = CRM_Core_Config::singleton();
9161952c 385 if (isset($params['isEmailPdf']) && $params['isEmailPdf'] == 1) {
3ace1ae5 386 // FIXME: $params['contributionId'] is not modeled in the parameter list. When is it supplied? Should probably move to tokenContext.contributionId.
d141946b 387 $pdfHtml = CRM_Contribute_BAO_ContributionPage::addInvoicePdfToEmail($params['contributionId'], $params['contactId']);
9161952c 388 if (empty($params['attachments'])) {
be2fb01f 389 $params['attachments'] = [];
9161952c 390 }
14bf6806 391 $params['attachments'][] = CRM_Utils_Mail::appendPDF('Invoice.pdf', $pdfHtml, $mailContent['format']);
9161952c 392 }
6a488035
TO
393 $pdf_filename = '';
394 if ($config->doNotAttachPDFReceipt &&
395 $params['PDFFilename'] &&
396 $params['html']
397 ) {
6a488035 398 if (empty($params['attachments'])) {
be2fb01f 399 $params['attachments'] = [];
6a488035 400 }
14bf6806 401 $params['attachments'][] = CRM_Utils_Mail::appendPDF($params['PDFFilename'], $params['html'], $mailContent['format']);
9849720e
RK
402 if (isset($params['tplParams']['email_comment'])) {
403 $params['html'] = $params['tplParams']['email_comment'];
d9e4ebe7 404 $params['text'] = strip_tags($params['tplParams']['email_comment']);
9849720e 405 }
6a488035
TO
406 }
407
408 $sent = CRM_Utils_Mail::send($params);
409
410 if ($pdf_filename) {
411 unlink($pdf_filename);
412 }
413 }
414
be2fb01f 415 return [$sent, $mailContent['subject'], $mailContent['text'], $mailContent['html']];
6a488035 416 }
96025800 417
0c5781ae
TO
418 /**
419 * Create a map between workflow_name and workflow_id.
420 *
421 * @return array
422 * Array(string $workflowName => int $workflowId)
423 */
424 protected static function getWorkflowNameIdMap() {
425 // There's probably some more clever way to do this, but this seems simple.
426 return CRM_Core_DAO::executeQuery('SELECT cov.name as name, cov.id as id FROM civicrm_option_group cog INNER JOIN civicrm_option_value cov on cov.option_group_id=cog.id WHERE cog.name LIKE %1', [
427 1 => ['msg_tpl_workflow_%', 'String'],
428 ])->fetchMap('name', 'id');
429 }
430
a4965e0c 431 /**
432 * Load the specified template.
433 *
434 * @param string $workflowName
435 * @param bool $isTest
436 * @param int|null $messageTemplateID
437 * @param string $groupName
e2615a28
TO
438 * @param array|null $messageTemplateOverride
439 * Optionally, record with msg_subject, msg_text, msg_html.
440 * If omitted, the record will be loaded from workflowName/messageTemplateID.
441 * @param string|null $subjectOverride
442 * This option is the older, wonkier version of $messageTemplate['msg_subject']...
a4965e0c 443 *
444 * @return array
445 * @throws \API_Exception
446 * @throws \CRM_Core_Exception
447 */
e2615a28
TO
448 protected static function loadTemplate(string $workflowName, bool $isTest, int $messageTemplateID = NULL, $groupName = NULL, ?array $messageTemplateOverride = NULL, ?string $subjectOverride = NULL): array {
449 $base = ['msg_subject' => NULL, 'msg_text' => NULL, 'msg_html' => NULL, 'pdf_format_id' => NULL];
a4965e0c 450 if (!$workflowName && !$messageTemplateID) {
451 throw new CRM_Core_Exception(ts("Message template's option value or ID missing."));
452 }
453
454 $apiCall = MessageTemplate::get(FALSE)
455 ->addSelect('msg_subject', 'msg_text', 'msg_html', 'pdf_format_id', 'id')
456 ->addWhere('is_default', '=', 1);
457
458 if ($messageTemplateID) {
459 $apiCall->addWhere('id', '=', (int) $messageTemplateID);
460 }
461 else {
462 $apiCall->addWhere('workflow_name', '=', $workflowName);
463 }
e2615a28
TO
464 $messageTemplate = array_merge($base, $apiCall->execute()->first() ?: [], $messageTemplateOverride ?: []);
465 if (empty($messageTemplate['id']) && empty($messageTemplateOverride)) {
a4965e0c 466 if ($messageTemplateID) {
467 throw new CRM_Core_Exception(ts('No such message template: id=%1.', [1 => $messageTemplateID]));
468 }
e2615a28 469 throw new CRM_Core_Exception(ts('No message template with workflow name %1.', [1 => $workflowName]));
a4965e0c 470 }
471
472 $mailContent = [
473 'subject' => $messageTemplate['msg_subject'],
474 'text' => $messageTemplate['msg_text'],
475 'html' => $messageTemplate['msg_html'],
476 'format' => $messageTemplate['pdf_format_id'],
87c4c149 477 // Workflow name is the field in the message templates table that denotes the
478 // workflow the template is used for. This is intended to eventually
479 // replace the non-standard option value/group implementation - see
480 // https://github.com/civicrm/civicrm-core/pull/17227 and the longer
481 // discussion on https://github.com/civicrm/civicrm-core/pull/17180
a4965e0c 482 'workflow_name' => $workflowName,
483 // Note messageTemplateID is the id but when present we also know it was specifically requested.
484 'messageTemplateID' => $messageTemplateID,
485 // Group name & valueName are deprecated parameters. At some point it will not be passed out.
486 // https://github.com/civicrm/civicrm-core/pull/17180
487 'groupName' => $groupName,
488 'valueName' => $workflowName,
489 ];
490
491 CRM_Utils_Hook::alterMailContent($mailContent);
492
493 // add the test banner (if requested)
494 if ($isTest) {
495 $testText = MessageTemplate::get(FALSE)
496 ->setSelect(['msg_subject', 'msg_text', 'msg_html'])
497 ->addWhere('workflow_name', '=', 'test_preview')
498 ->addWhere('is_default', '=', TRUE)
499 ->execute()->first();
500
501 $mailContent['subject'] = $testText['msg_subject'] . $mailContent['subject'];
502 $mailContent['text'] = $testText['msg_text'] . $mailContent['text'];
503 $mailContent['html'] = preg_replace('/<body(.*)$/im', "<body\\1\n{$testText['msg_html']}", $mailContent['html']);
504 }
505
e2615a28
TO
506 if (!empty($subjectOverride)) {
507 CRM_Core_Error::deprecatedWarning('CRM_Core_BAO_MessageTemplate: $params[subject] is deprecated. Use $params[messageTemplate][msg_subject] instead.');
508 $mailContent['subject'] = $subjectOverride;
509 }
510
a4965e0c 511 return $mailContent;
512 }
513
6a488035 514}