Merge pull request #2263 from kurund/CRM-12753
[civicrm-core.git] / CRM / Contribute / Form / Contribution / Main.php
index 602615d2d04f5c13a424278de85cbb8c000f453c..68918da67f3ac9f4b627c5f1845fee03545f5c33 100644 (file)
@@ -516,19 +516,24 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
         }
         $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,
-        array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );")
-      );
-      $extraOption = array('onclick' => "return pcpAnonymous( );");
-      $elements    = array();
-      $elements[]  = &$this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
-      $elements[]  = &$this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
-      $this->addGroup($elements, 'pcp_is_anonymous', NULL, '   ');
-      $this->_defaults['pcp_is_anonymous'] = 0;
+      $prms = array('id' => $this->_pcpId);
+      CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
+      if ($pcpInfo['is_honor_roll']) {
+        $this->assign('isHonor', TRUE);
+        $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL,
+          array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );")
+        );
+        $extraOption = array('onclick' => "return pcpAnonymous( );");
+        $elements    = array();
+        $elements[]  = &$this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
+        $elements[]  = &$this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
+        $this->addGroup($elements, 'pcp_is_anonymous', NULL, '   ');
+        $this->setDefaults(array('pcp_display_in_roll' => 1));
+        $this->setDefaults(array('pcp_is_anonymous' => 1));
 
-      $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
-      $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
+        $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
+        $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
+      }
     }
 
     //we have to load confirm contribution button in template
@@ -972,7 +977,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       }
       elseif (CRM_Utils_Array::value('is_pledge', $fields)) {
         if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_installments', $fields)) == FALSE) {
-          $errors['pledge_installments'] = ts('Please enter a valid pledge installment.');
+          $errors['pledge_installments'] = ts('Please enter a valid number of pledge installments.');
         }
         else {
           if (CRM_Utils_Array::value('pledge_installments', $fields) == NULL) {