'PDFFilename' => NULL,
);
$params = array_merge($defaults, $params);
+
CRM_Utils_Hook::alterMailParams($params);
+
if ((!$params['groupName'] ||
!$params['valueName']
) &&
}
}
- $subject = $dao->subject;
- $text = $dao->text;
- $html = $dao->html;
- $format = $dao->format;
+ $mailContent = array(
+ 'subject' => $dao->subject,
+ 'text' => $dao->text,
+ 'html' => $dao->html,
+ 'format' => $dao->format,
+ );
$dao->free();
- CRM_Utils_Hook::alterMailContent($dao);
+
+ CRM_Utils_Hook::alterMailContent($mailContent);
+
// add the test banner (if requested)
if ($params['isTest']) {
$query = "SELECT msg_subject subject, msg_text text, msg_html html
$testDao = CRM_Core_DAO::executeQuery($query);
$testDao->fetch();
- $subject = $testDao->subject . $subject;
- $text = $testDao->text . $text;
- $html = preg_replace('/<body(.*)$/im', "<body\\1\n{$testDao->html}", $html);
+ $mailContent['subject'] = $testDao->subject . $mailContent['subject'];
+ $mailContent['text'] = $testDao->text . $mailContent['text'];
+ $mailContent['html'] = preg_replace('/<body(.*)$/im', "<body\\1\n{$testDao->html}", $mailContent['html']);
$testDao->free();
}
$domain = CRM_Core_BAO_Domain::getDomain();
$hookTokens = array();
$mailing = new CRM_Mailing_BAO_Mailing();
- $mailing->subject = $subject;
- $mailing->body_text = $text;
- $mailing->body_html = $html;
+ $mailing->subject = $mailingContent['subject'];
+ $mailing->body_text = $mailContent['text'];
+ $mailing->body_html = $mailContent['html'];
$tokens = $mailing->getTokens();
CRM_Utils_Hook::tokens($hookTokens);
$categories = array_keys($hookTokens);
$contact = $contact[$contactID];
}
- $subject = CRM_Utils_Token::replaceDomainTokens($subject, $domain, FALSE, $tokens['text'], TRUE);
- $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text'], TRUE);
- $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html'], TRUE);
+ $mailingContent['subject'] = CRM_Utils_Token::replaceDomainTokens($mailingContent['subject'], $domain, FALSE, $tokens['text'], TRUE);
+ $mailContent['text'] = CRM_Utils_Token::replaceDomainTokens($mailContent['text'], $domain, FALSE, $tokens['text'], TRUE);
+ $mailContent['html'] = CRM_Utils_Token::replaceDomainTokens($mailContent['html'], $domain, TRUE, $tokens['html'], TRUE);
if ($contactID) {
- $subject = CRM_Utils_Token::replaceContactTokens($subject, $contact, FALSE, $tokens['text'], FALSE, TRUE);
- $text = CRM_Utils_Token::replaceContactTokens($text, $contact, FALSE, $tokens['text'], FALSE, TRUE);
- $html = CRM_Utils_Token::replaceContactTokens($html, $contact, FALSE, $tokens['html'], FALSE, TRUE);
+ $mailingContent['subject'] = CRM_Utils_Token::replaceContactTokens($mailingContent['subject'], $contact, FALSE, $tokens['text'], FALSE, TRUE);
+ $mailContent['text'] = CRM_Utils_Token::replaceContactTokens($mailContent['text'], $contact, FALSE, $tokens['text'], FALSE, TRUE);
+ $mailContent['html'] = CRM_Utils_Token::replaceContactTokens($mailContent['html'], $contact, FALSE, $tokens['html'], FALSE, TRUE);
$contactArray = array($contactID => $contact);
CRM_Utils_Hook::tokenValues($contactArray,
);
$contact = $contactArray[$contactID];
- $subject = CRM_Utils_Token::replaceHookTokens($subject, $contact, $categories, TRUE);
- $text = CRM_Utils_Token::replaceHookTokens($text, $contact, $categories, TRUE);
- $html = CRM_Utils_Token::replaceHookTokens($html, $contact, $categories, TRUE);
+ $mailingContent['subject'] = CRM_Utils_Token::replaceHookTokens($mailingContent['subject'], $contact, $categories, TRUE);
+ $mailContent['text'] = CRM_Utils_Token::replaceHookTokens($mailContent['text'], $contact, $categories, TRUE);
+ $mailContent['html'] = CRM_Utils_Token::replaceHookTokens($mailContent['html'], $contact, $categories, TRUE);
}
// strip whitespace from ends and turn into a single line
- $subject = "{strip}$subject{/strip}";
+ $mailingContent['subject'] = "{strip}{$mailingContent['subject']}{/strip}";
// parse the three elements with Smarty
$smarty = CRM_Core_Smarty::singleton();
$sent = FALSE;
// create the params array
- $params['subject'] = $subject;
- $params['text'] = $text;
- $params['html'] = $html;
+ $params['subject'] = $mailingContent['subject'];
+ $params['text'] = $mailContent['text'];
+ $params['html'] = $mailContent['html'];
if ($params['toEmail']) {
$contactParams = array(array('email', 'LIKE', $params['toEmail'], 0, 1));
if (empty($params['attachments'])) {
$params['attachments'] = array();
}
- $params['attachments'][] = CRM_Utils_Mail::appendPDF('Invoice.pdf', $pdfHtml, $format);
+ $params['attachments'][] = CRM_Utils_Mail::appendPDF('Invoice.pdf', $pdfHtml, $mailContent['format']);
}
$pdf_filename = '';
if ($config->doNotAttachPDFReceipt &&
if (empty($params['attachments'])) {
$params['attachments'] = array();
}
- $params['attachments'][] = CRM_Utils_Mail::appendPDF($params['PDFFilename'], $params['html'], $format);
+ $params['attachments'][] = CRM_Utils_Mail::appendPDF($params['PDFFilename'], $params['html'], $mailContent['format']);
if (isset($params['tplParams']['email_comment'])) {
$params['html'] = $params['tplParams']['email_comment'];
$params['text'] = strip_tags($params['tplParams']['email_comment']);
}
}
- return array($sent, $subject, $text, $html);
+ return array($sent, $mailingContent['subject'], $mailContent['text'], $mailContent['html']);
}
}