Skip to content

Commit

Permalink
Merge pull request #21059 from eileenmcnaughton/contribuion_mode
Browse files Browse the repository at this point in the history
dev/core#2748 Remove unused token assigns
  • Loading branch information
eileenmcnaughton authored Sep 9, 2021
2 parents f634283 + 1f7cb15 commit 60fb93d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
7 changes: 0 additions & 7 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2983,15 +2983,8 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
// and this function should assign them (assigning null if not set).
// the way the pcpParams & honor Params section works is a baby-step towards this.
$template = CRM_Core_Smarty::singleton();
$template->assign('first_name', $this->_relatedObjects['contact']->first_name);
$template->assign('last_name', $this->_relatedObjects['contact']->last_name);
$template->assign('displayName', $this->_relatedObjects['contact']->display_name);
$template->assign('billingName', $values['billingName']);

// For some unit tests contribution cannot contain paymentProcessor information
$billingMode = empty($this->_relatedObjects['paymentProcessor']) ? CRM_Core_Payment::BILLING_MODE_NOTIFY : $this->_relatedObjects['paymentProcessor']['billing_mode'];
$template->assign('contributeMode', CRM_Core_SelectValues::contributeMode()[$billingMode] ?? NULL);

//assign honor information to receipt message
$softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);

Expand Down
12 changes: 11 additions & 1 deletion CRM/Upgrade/Incremental/php/FiveFortyThree.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,19 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
*
* @param string $rev
*/
public function upgrade_5_43_alpha1($rev) {
public function upgrade_5_43_alpha1(string $rev): void {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addTask('Fix DB Collation if needed on the relatonship cache table', 'fixRelationshipCacheTableCollation');

$this->addTask('Replace legacy displayName smarty token in Online contribution workflow template',
'updateMessageToken', 'contribution_online_receipt', '$displayName', 'contact.display_name', $rev
);
$this->addTask('Replace legacy first_name smarty token in Online contribution workflow template',
'updateMessageToken', 'contribution_online_receipt', '$first_name', 'contact.first_name', $rev
);
$this->addTask('Replace legacy last_name smarty token in Online contribution workflow template',
'updateMessageToken', 'contribution_online_receipt', '$last_name', 'contact.last_name', $rev
);
}

public static function fixRelationshipCacheTableCollation():bool {
Expand Down
6 changes: 6 additions & 0 deletions CRM/Utils/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,12 @@ public static function getTokenDeprecations(): array {
'contribution_invoice_receipt' => [
'$display_name' => 'contact.display_name',
],
'contribution_online_receipt' => [
'$contributeMode' => 'no longer available / relevant',
'$first_name' => 'contact.first_name',
'$last_name' => 'contact.last_name',
'$displayName' => 'contact.display_name',
],
],
];
}
Expand Down
7 changes: 0 additions & 7 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2072,9 +2072,7 @@ public function testCompleteTransaction() {
'currency:::USD',
'receive_date:::' . date('Ymd', strtotime($contribution['receive_date'])),
"receipt_date:::\n",
'contributeMode:::notify',
'title:::Contribution',
'displayName:::Mr. Anthony Anderson II',
'contributionStatus:::Completed',
]);
$mut->stop();
Expand Down Expand Up @@ -2112,9 +2110,7 @@ public function testCompleteTransactionEuro() {
'currency:::EUR',
'receive_date:::' . date('Ymd', strtotime($contribution['receive_date'])),
"receipt_date:::\n",
'contributeMode:::notify',
'title:::Contribution',
'displayName:::Mr. Anthony Anderson II',
'contributionStatus:::Completed',
]);
$mut->stop();
Expand Down Expand Up @@ -2150,7 +2146,6 @@ public function testPayLater(): void {
'is_pay_later:::1',
'email:::anthony_anderson@civicrm.org',
'pay_later_receipt:::This is a pay later receipt',
'displayName:::Mr. Anthony Anderson II',
'contributionPageId:::' . $contributionPageID,
'title:::Test Contribution Page',
'amount:::100',
Expand Down Expand Up @@ -3185,9 +3180,7 @@ public function testCompleteTransactionWithTestTemplate() {
'currency:::USD',
'receive_date:::' . date('Ymd', strtotime($receive_date)),
'receipt_date:::' . date('Ymd'),
'contributeMode:::notify',
'title:::Contribution',
'displayName:::Mr. Anthony Anderson II',
'trxn_id:::kazam',
'contactID:::' . $this->_params['contact_id'],
'contributionID:::' . $contribution['id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
receipt_text:::{$receipt_text}
{/if}
is_pay_later:::{$is_pay_later}
displayName:::{$displayName}
financialTypeId:::{$financialTypeId}
financialTypeName:::{$financialTypeName}
contactID:::{$contactID}
Expand Down Expand Up @@ -52,9 +51,6 @@
{if isset($is_recur)}
is_recur:::{$is_recur}
{/if}
{if isset($contributeMode)}
contributeMode:::{$contributeMode}
{/if}
{if isset($trxn_id)}
trxn_id:::{$trxn_id}
{/if}
Expand Down

0 comments on commit 60fb93d

Please sign in to comment.