From eea141c0d4b4c1276b3138cedd956d8c11ce6023 Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Tue, 12 Nov 2013 16:50:45 -0800 Subject: [PATCH] CRM-13742 conditional display of invite to create your own PCP after completing a contribution or event registration as a supporter. ---------------------------------------- * CRM-13742: PCP message should not always promise ability to create your own PCP http://issues.civicrm.org/jira/browse/CRM-13742 --- CRM/Contribute/Form/Contribution/Main.php | 8 ++++++- CRM/Event/Form/Registration.php | 3 --- CRM/PCP/BAO/PCP.php | 22 ++++++++++++++----- .../Contribute/Form/ContributionPage/PCP.hlp | 2 +- templates/CRM/PCP/Form/Contribute.hlp | 2 +- templates/CRM/PCP/Form/Event.hlp | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index f7eb14cfec..602615d2d0 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -508,7 +508,13 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } if ($this->_pcpId) { if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) { - $this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of %1, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter))); + $pcp_supporter_text = ts('This contribution is being made thanks to effort of %1, who supports our campaign. ', array(1 => $pcpSupporter)); + // Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field. + $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute'); + if(!empty($text)) { + $pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!"; + } + $this->assign('pcpSupporterText', $pcp_supporter_text); } $this->assign('pcp', TRUE); $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index e52c837fba..de0c307eda 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -456,9 +456,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { $this->assign('bltID', $this->_bltID); $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']); $this->assign('isShowLocation', $isShowLocation); - if ($pcpId && $pcpSupporter = CRM_PCP_BAO_PCP::displayName($pcpId)) { - $this->assign('pcpSupporterText', ts('This event registration is being made thanks to effort of %1, who supports our campaign. You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter))); - } //CRM-6907 $config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index b9a58cc7c5..985c0cb184 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -418,14 +418,23 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $prms = array('id' => $pcpId); CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo); - if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($pcpId)) { if ($pcpInfo['page_type'] == 'event') { - $page->assign('pcpSupporterText', ts('This event registration is being made thanks to effort of %1, who supports our campaign. You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter))); + $pcp_supporter_text = ts('This event registration is being made thanks to effort of %1, who supports our campaign. ', array(1 => $pcpSupporter)); + $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event'); + if(!empty($text)) { + $pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!"; + } } else { - $page->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of %1, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter))); + $pcp_supporter_text = ts('This contribution is being made thanks to effort of %1, who supports our campaign. ', array(1 => $pcpSupporter)); + $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute'); + if(!empty($text)) { + $pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!"; + } } + + $page->assign('pcpSupporterText', $pcp_supporter_text); } $page->assign('pcp', TRUE); @@ -735,9 +744,10 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; static function getPcpBlockStatus($pageId, $component) { $query = " SELECT pb.link_text as linkText - FROM civicrm_contribution_page cp - LEFT JOIN civicrm_pcp_block pb ON ( cp.id = pb.entity_id AND pb.entity_table = %2 ) - WHERE pb.is_active = 1 AND cp.id = %1"; + FROM civicrm_pcp_block pb + WHERE pb.is_active = 1 AND + pb.entity_id = %1 AND + pb.entity_table = %2"; $entity_table = self::getPcpEntityTable($component); diff --git a/templates/CRM/Contribute/Form/ContributionPage/PCP.hlp b/templates/CRM/Contribute/Form/ContributionPage/PCP.hlp index 050dad579e..815c9b1216 100644 --- a/templates/CRM/Contribute/Form/ContributionPage/PCP.hlp +++ b/templates/CRM/Contribute/Form/ContributionPage/PCP.hlp @@ -72,5 +72,5 @@ {ts}Personal Contribution Link{/ts} {/htxt} {htxt id="id-link_text"} -{ts}Text for the link inviting constituents to create a Personal Contribution Page. This link will appear on the Contribution Thank-you page as well as on each Personal Campaign Page.{/ts} +{ts}Text for the link inviting constituents to create a Personal Contribution Page. This link will appear on the Contribution Thank-you page as well as on each Personal Campaign Page. Leave blank if you do not want constituents to be prompted to create their own Personal Campaign Pages.{/ts} {/htxt} diff --git a/templates/CRM/PCP/Form/Contribute.hlp b/templates/CRM/PCP/Form/Contribute.hlp index 9a030d8057..5425d17633 100644 --- a/templates/CRM/PCP/Form/Contribute.hlp +++ b/templates/CRM/PCP/Form/Contribute.hlp @@ -72,5 +72,5 @@ {ts}Personal Contribution Link{/ts} {/htxt} {htxt id="id-link_text"} -{ts}Text for the link inviting constituents to create a Personal Contribution Page. This link will appear on the Contribution Thank-you page as well as on each Personal Campaign Page.{/ts} +{ts}Text for the link inviting constituents to create a Personal Contribution Page. This link will appear on the Contribution Thank-you page as well as on each Personal Campaign Page. Leave blank if you do not want constituents to be prompted to create their own Personal Campaign Pages.{/ts} {/htxt} diff --git a/templates/CRM/PCP/Form/Event.hlp b/templates/CRM/PCP/Form/Event.hlp index 0e4e72bf75..466cfb6044 100644 --- a/templates/CRM/PCP/Form/Event.hlp +++ b/templates/CRM/PCP/Form/Event.hlp @@ -72,7 +72,7 @@ {ts}Link Text{/ts} {/htxt} {htxt id="id-link_text"} -{ts}Text for the link inviting constituents to create a Personal Campaign Page. This link will appear on the Event registration Thank-you page as well as on each Personal Campaign Page.{/ts} +{ts}Text for the link inviting constituents to create a Personal Campaign Page. This link will appear on the Event registration Thank-you page as well as on each Personal Campaign Page. Leave blank if you do not want constituents to be prompted to create their own Personal Campaign Pages.{/ts} {/htxt} {htxt id="id-target_entity_type-title"} -- 2.25.1