CRM-11316 Fix online contrib, event reg, PCP account, petition signature and mailing...
[civicrm-core.git] / CRM / Contribute / Form / ContributionBase.php
index c316601bb79cb9dcc24a52af79431c4aa45e019a..df47a2b74b252b66ca87de4e128662cfec894c3c 100644 (file)
@@ -269,7 +269,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
       // also check for billing informatin
       // get the billing location type
-      $locationTypes = CRM_Core_PseudoConstant::locationType();
+      $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
       // CRM-8108 remove ts around Billing location type
       //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
       $this->_bltID = array_search('Billing', $locationTypes);
@@ -330,7 +330,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
       // get price info
       // CRM-5095
-      CRM_Price_BAO_Set::initSet($this, $this->_id, 'civicrm_contribution_page');
+      CRM_Price_BAO_PriceSet::initSet($this, $this->_id, 'civicrm_contribution_page');
 
       // this avoids getting E_NOTICE errors in php
       $setNullFields = array(
@@ -510,7 +510,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
     $config = CRM_Core_Config::singleton();
     if (isset($this->_values['is_recur']) &&
-      $this->_paymentProcessor['is_recur']
+      CRM_Utils_Array::value('is_recur', $this->_paymentProcessor)
     ) {
       $this->assign('is_recur_enabled', 1);
       $vars = array_merge($vars, array(
@@ -537,13 +537,16 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
     }
 
     foreach ($vars as $v) {
-      if (CRM_Utils_Array::value($v, $this->_params)) {
+      if (isset($this->_params[$v])) {
         if ($v == 'frequency_unit' || $v == 'pledge_frequency_unit') {
           $frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
           if (array_key_exists($this->_params[$v], $frequencyUnits)) {
             $this->_params[$v] = $frequencyUnits[$this->_params[$v]];
           }
         }
+        if ($v == "amount") {
+          $this->_params[$v] = CRM_Utils_Money::format($this->_params[$v], ' ');
+        }
         $this->assign($v, $this->_params[$v]);
       }
     }
@@ -584,7 +587,9 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
     }
 
     if ($this->_contributeMode == 'direct' && $assignCCInfo) {
-      if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
+      if ($this->_paymentProcessor &&
+        $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT
+      ) {
         $this->assign('payment_type', $this->_paymentProcessor['payment_type']);
         $this->assign('account_holder', $this->_params['account_holder']);
         $this->assign('bank_identification_number', $this->_params['bank_identification_number']);
@@ -711,7 +716,8 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
             );
             $this->_fields[$key] = $field;
           }
-          if ($field['add_captcha']) {
+          // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
+          if ($field['add_captcha'] && !$this->_userID) {
             $addCaptcha = TRUE;
           }
         }