Skip to content

Commit

Permalink
[Ref] Simplify is_email_receipt in sendMail
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eileenmcnaughton committed Aug 1, 2020
1 parent eae974d commit b79ad34
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit b79ad34

Please sign in to comment.