From 5743040370ad633257fa9862990cdc84dcbce501 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 24 May 2022 11:26:00 +0100 Subject: [PATCH] show honor roll only if it's enabled for the PCP page for contribution confirm, thank you and email receipt --- CRM/Contribute/BAO/Contribution.php | 5 +++ CRM/Contribute/Form/Contribution/Confirm.php | 37 +++++++++++-------- CRM/Contribute/Form/Contribution/ThankYou.php | 23 +++++++----- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 0250cb4339b6..faad8f33518d 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2896,6 +2896,11 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa $pcpDAO->id = $softDAO->pcp_id; if ($pcpDAO->find(TRUE)) { $pcpParams['title'] = $pcpDAO->title; + + // do not display PCP block in receipt if not enabled for the PCP poge + if (empty($pcpDAO->is_honor_roll)) { + $pcpParams['pcpBlock'] = FALSE; + } } } } diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 2ef3a2a863c5..6dd090a72d3f 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1385,22 +1385,27 @@ public static function processOnBehalfOrganization(&$behalfOrganization, &$conta */ public static function processPcp(&$page, $params): array { $params['pcp_made_through_id'] = $page->_pcpId; - $page->assign('pcpBlock', TRUE); - if (!empty($params['pcp_display_in_roll']) && empty($params['pcp_roll_nickname'])) { - $params['pcp_roll_nickname'] = ts('Anonymous'); - $params['pcp_is_anonymous'] = 1; - } - else { - $params['pcp_is_anonymous'] = 0; - } - foreach ([ - 'pcp_display_in_roll', - 'pcp_is_anonymous', - 'pcp_roll_nickname', - 'pcp_personal_note', - ] as $val) { - if (!empty($params[$val])) { - $page->assign($val, $params[$val]); + + $page->assign('pcpBlock', FALSE); + // display honor roll data only if it's enabled for the PCP page + if (!empty($page->_pcpInfo['is_honor_roll'])) { + $page->assign('pcpBlock', TRUE); + if (!empty($params['pcp_display_in_roll']) && empty($params['pcp_roll_nickname'])) { + $params['pcp_roll_nickname'] = ts('Anonymous'); + $params['pcp_is_anonymous'] = 1; + } + else { + $params['pcp_is_anonymous'] = 0; + } + foreach ([ + 'pcp_display_in_roll', + 'pcp_is_anonymous', + 'pcp_roll_nickname', + 'pcp_personal_note', + ] as $val) { + if (!empty($params[$val])) { + $page->assign($val, $params[$val]); + } } } diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index 623c9dd26eed..91a8bcbcc0b8 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -142,15 +142,20 @@ public function buildQuickForm() { //pcp elements if ($this->_pcpId) { $qParams .= "&pcpId={$this->_pcpId}"; - $this->assign('pcpBlock', TRUE); - foreach ([ - 'pcp_display_in_roll', - 'pcp_is_anonymous', - 'pcp_roll_nickname', - 'pcp_personal_note', - ] as $val) { - if (!empty($this->_params[$val])) { - $this->assign($val, $this->_params[$val]); + $this->assign('pcpBlock', FALSE); + + // display honor roll data only if it's enabled for the PCP page + if (!empty($this->_pcpInfo['is_honor_roll'])) { + $this->assign('pcpBlock', TRUE); + foreach ([ + 'pcp_display_in_roll', + 'pcp_is_anonymous', + 'pcp_roll_nickname', + 'pcp_personal_note', + ] as $val) { + if (!empty($this->_params[$val])) { + $this->assign($val, $this->_params[$val]); + } } } }