CRM-13742 conditional display of invite to create your own PCP after completing a...
authorDave Greenberg <dave@civicrm.org>
Wed, 13 Nov 2013 00:50:45 +0000 (16:50 -0800)
committerDave Greenberg <dave@civicrm.org>
Wed, 13 Nov 2013 00:50:45 +0000 (16:50 -0800)
----------------------------------------
* 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
CRM/Event/Form/Registration.php
CRM/PCP/BAO/PCP.php
templates/CRM/Contribute/Form/ContributionPage/PCP.hlp
templates/CRM/PCP/Form/Contribute.hlp
templates/CRM/PCP/Form/Event.hlp

index f7eb14cfec34ec2ec548b248b0089dfa5061c78a..602615d2d04f5c13a424278de85cbb8c000f453c 100644 (file)
@@ -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 <strong>%1</strong>, 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 <strong>%1</strong>, 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,
index e52c837fba4fbf0cb5f9971752845ed7bbcf7c90..de0c307eda7fda7da677610f485b4a782dd79a8f 100644 (file)
@@ -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 <strong>%1</strong>, 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
index b9a58cc7c5e24ad74182b2bc94bf92476edddd40..985c0cb184a14e800b102ec81461e2cec7f27417 100644 (file)
@@ -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 <strong>%1</strong>, 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 <strong>%1</strong>, 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 <strong>%1</strong>, 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 <strong>%1</strong>, 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);
 
index 050dad579ece344eff84c5c19669cef04bd8a6a2..815c9b1216a97de08a40173cafe8fefa7da43ffd 100644 (file)
@@ -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}
index 9a030d80570a3967b5b7746f5ee4c71c82d835bf..5425d176338f5b6cdd1a26f7b7385fefb13b285a 100644 (file)
@@ -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}
index 0e4e72bf750c2d9ae2df79e4842538fb85786bc2..466cfb604410f469e7d8617587dcdb32de2cf93b 100644 (file)
@@ -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"}