Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2851 Remove calls to replaceContributionTokens in contribution pdf letter task #21524

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions CRM/Contribute/Form/Task/PDFLetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,19 +546,19 @@ public static function isValidHTMLWithTableSeparator($tokens, $html) {
* @return string
*/
protected function resolveTokens(string $html_message, $contact, $contribution, $messageToken, $grouped, $separator, $contributions): string {
if ($grouped) {
$tokenHtml = CRM_Utils_Token::replaceMultipleContributionTokens($separator, $html_message, $contributions, $messageToken);
}
else {
// no change to normal behaviour to avoid risk of breakage
$tokenHtml = CRM_Utils_Token::replaceContributionTokens($html_message, $contribution, TRUE, $messageToken);
}
$tokenContext = [
'smarty' => (defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY),
'contactId' => $contact['contact_id'],
];
if ($grouped) {
$html_message = CRM_Utils_Token::replaceMultipleContributionTokens($separator, $html_message, $contributions, $messageToken);
}
else {
$tokenContext['schema'] = ['contributionId'];
$tokenContext['contributionId'] = $contribution['id'];
}
$smarty = ['contact' => $contact];
return CRM_Core_TokenSmarty::render(['html' => $tokenHtml], $tokenContext, $smarty)['html'];
return CRM_Core_TokenSmarty::render(['html' => $html_message], $tokenContext, $smarty)['html'];
}

}
2 changes: 1 addition & 1 deletion Civi/Token/TokenRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function customToken($entity, $customFieldID, $entityID) {
$fieldValue = \CRM_Core_BAO_CustomField::displayValue($fieldValue, $customFieldID);
}

return $this->tokens($entity, $customFieldName, $fieldValue);
return $this->format('text/html')->tokens($entity, $customFieldName, $fieldValue);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,19 @@ public function testAllContributionTokens(): void {
<body>
<div id="crm-container">
id : 1
total_amount : 9,999.99
fee_amount : 1,111.11
net_amount : 7,777.78
non_deductible_amount : 2,222.22
total_amount : &euro; 9,999.99
fee_amount : &euro; 1,111.11
net_amount : &euro; 7,777.78
non_deductible_amount : &euro; 2,222.22
receive_date : July 20th, 2018 12:00 AM
payment_instrument_id:label : Check
trxn_id : 1234
invoice_id : 568
currency : EUR
cancel_date : 2019-12-30 00:00:00
cancel_date : December 30th, 2019 12:00 AM
cancel_reason : Contribution Cancel Reason
receipt_date : October 30th, 2019 12:00 AM
thankyou_date : 2019-11-30 00:00:00
thankyou_date : November 30th, 2019 12:00 AM
source : Contribution Source
amount_level : Amount Level
contribution_status_id : 2
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Utils/TokenConsistencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ protected function getExpectedEventTokenOutput(): string {
Emerald City, Maine 90210
$ 50.00
' . CRM_Utils_System::url('civicrm/event/info', NULL, TRUE) . '&amp;reset=1&amp;id=1
' . CRM_Utils_System::url('civicrm/event/register', NULL, TRUE) . '&amp;reset=1&amp;id=1
' . CRM_Utils_System::url('civicrm/event/info', NULL, TRUE) . '&reset=1&id=1
' . CRM_Utils_System::url('civicrm/event/register', NULL, TRUE) . '&reset=1&id=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by how changing the pdf for contribution thank you letters affects the event urls for scheduled event reminders? I admit I haven't followed it thru yet but maybe you already know the answer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah it is - that line is saying 'this is the html version I'm giving you' - which results in less change to the pdf output

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&Thanks.

my field';
}
Expand Down