Skip to content

Commit

Permalink
Merge pull request #16 from CanadaHelps/CRM-954-1
Browse files Browse the repository at this point in the history
CRM-954: Token fixes for CDN taxreceipt thank-you form
  • Loading branch information
irfanhaq1 authored Jan 26, 2022
2 parents 7469b12 + 9e181b4 commit 12c4db4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CRM/Cdntaxreceipts/Task/PDFLetterCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static function postProcess(&$form, $formValues = NULL) {
//@todo - comment on what is stored there
$contributionIDs = $form->getVar('_contributionContactIds');
}

[$contributions, $contacts] = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->_includesSoftCredits);
$html = [];
$contactHtml = $emailedHtml = [];
Expand All @@ -86,7 +87,6 @@ public static function postProcess(&$form, $formValues = NULL) {
$contribution = $contact['combined'][$groupBy][$groupByID];
$grouped = TRUE;
}

if (empty($groupBy) || empty($contact['is_sent'][$groupBy][$groupByID])) {
$html[$contributionId] = self::generateHtml($contact, $contribution, $groupBy, $contributions, $realSeparator, $tableSeparators, $messageToken, $html_message, $separator, $grouped, $groupByID);
$contactHtml[$contact['contact_id']][] = $html[$contributionId];
Expand Down Expand Up @@ -161,19 +161,19 @@ public static function isHtmlTokenInTableCell($token, $entity, $textToSearch) {
* @return string
* @throws \CRM_Core_Exception
*/
private static function resolveTokens(string $html_message, $contact, $contribution, $messageToken, $grouped, $separator, $contributions): string {
public static function resolveTokens(string $html_message, $contact, $contribution, $messageToken, $grouped, $separator, $contributions): string {
$categories = self::getTokenCategories();
$domain = CRM_Core_BAO_Domain::getDomain();
$tokenHtml = CRM_Utils_Token::replaceDomainTokens($html_message, $domain, TRUE, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceContactTokens($tokenHtml, $contact, TRUE, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact, $categories, TRUE);
if ($grouped) {
$tokenHtml = CRM_Utils_Token::replaceMultipleContributionTokens($separator, $tokenHtml, $contributions, $messageToken);
}
else {
// no change to normal behaviour to avoid risk of breakage
$tokenHtml = CRM_Utils_Token::replaceContributionTokens($tokenHtml, $contribution, TRUE, $messageToken);
}
$tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact, $categories, TRUE);
if (defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY) {
$smarty = CRM_Core_Smarty::singleton();
// also add the tokens to the template
Expand Down Expand Up @@ -362,7 +362,7 @@ public static function emailLetter($contact, $html, $is_pdf, $format = [], $para
* @return string
* @throws \CRM_Core_Exception
*/
protected static function generateHtml(&$contact, $contribution, $groupBy, $contributions, $realSeparator, $tableSeparators, $messageToken, $html_message, $separator, $grouped, $groupByID) {
public static function generateHtml(&$contact, $contribution, $groupBy, $contributions, $realSeparator, $tableSeparators, $messageToken, $html_message, $separator, $grouped, $groupByID) {
static $validated = FALSE;
$html = NULL;

Expand Down

0 comments on commit 12c4db4

Please sign in to comment.