Skip to content

Commit

Permalink
show honor roll only if it's enabled for the PCP page for contribution
Browse files Browse the repository at this point in the history
confirm, thank you and email receipt
  • Loading branch information
kurund committed May 25, 2022
1 parent 51ae64d commit 5743040
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down
37 changes: 21 additions & 16 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}

Expand Down
23 changes: 14 additions & 9 deletions CRM/Contribute/Form/Contribution/ThankYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
}
Expand Down

0 comments on commit 5743040

Please sign in to comment.