From 081ee4443a2bd0fea13e3d0f7504dffe9ba5e424 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 1 Aug 2020 17:35:38 +1200 Subject: [PATCH] [Ref] Simplify is_email_receipt in sendMail This function has evolved through refactoring so there was a time when this code needed to decide whether to send emails out or not. However, the function is now called more deliberately -ie 1) from completeTransaction - where it is only called if the decision to send an email is made 2) from the search action send Email receipts - where a user has made the decision to send (or pdf) receipts and unless it's being called with returnMessageText = TRUE (to construct a pdf) then send makes sense Ergo we should send unless returnMessageText = TRUE --- CRM/Contribute/BAO/Contribution.php | 19 +------------------ api/v3/Contribution.php | 1 - 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 397409a66825..cd653dad612b 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2927,7 +2927,7 @@ public function composeMessageArray(&$input, &$ids, &$values, $returnMessageText //not really sure what params might be passed in but lets merge em into values $values = array_merge($this->_gatherMessageValues($input, $values, $ids), $values); - $values['is_email_receipt'] = $this->isEmailReceipt($input, $values); + $values['is_email_receipt'] = !$returnMessageText; if (!empty($input['receipt_date'])) { $values['receipt_date'] = $input['receipt_date']; } @@ -5706,23 +5706,6 @@ protected function loadRelatedEntitiesByID($ids) { } } - /** - * Should an email receipt be sent for this contribution when complete. - * - * @param array $input - * - * @return mixed - */ - protected function isEmailReceipt($input) { - if (isset($input['is_email_receipt'])) { - return $input['is_email_receipt']; - } - if (!empty($this->_relatedObjects['contribution_page_id'])) { - return $this->_relatedObjects['contribution_page_id']->is_email_receipt; - } - return TRUE; - } - /** * Function to replace contribution tokens. * diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 805e483bd61b..89212a64718e 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -404,7 +404,6 @@ function civicrm_api3_contribution_sendconfirmation($params) { 'payment_processor_id', ]; $input = array_intersect_key($params, array_flip($allowedParams)); - $input['is_email_receipt'] = TRUE; CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $params['id']); }