add comment
[civicrm-core.git] / CRM / Contribute / Form / AbstractEditPayment.php
index b698b30c9cf91c9cc48b673603e3b5e1fb433ee4..d8a99b1925a3aa6b90d151c8c438d868bf28dab9 100644 (file)
@@ -52,13 +52,19 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task {
 
   public $_bltID;
 
-  public $_fields;
+  public $_fields = array();
 
   /**
    * @var array current payment processor including a copy of the object in 'object' key
    */
   public $_paymentProcessor;
-  public $_recurPaymentProcessors;
+
+  /**
+   * Available recurring processors.
+   *
+   * @var array
+   */
+  public $_recurPaymentProcessors = array();
 
   /**
    * Array of processor options in the format id => array($id => $label)
@@ -188,11 +194,6 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task {
 
   protected $_formType;
 
-  /**
-   * @var mystery variable screaming out for documentation
-   */
-  protected $_cdType;
-
   /**
    * Array of fields to display on billingBlock.tpl - this is not fully implemented but basically intent is the panes/fieldsets on this page should
    * be all in this array in order like
@@ -412,22 +413,6 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
 
   }
 
-  /**
-   * Assign billing type id to bltID.
-   *
-   * @throws CRM_Core_Exception
-   * @return void
-   */
-  public function assignBillingType() {
-    $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
-    $this->_bltID = array_search('Billing', $locationTypes);
-    if (!$this->_bltID) {
-      throw new CRM_Core_Exception(ts('Please set a location type of %1', array(1 => 'Billing')));
-    }
-    $this->set('bltID', $this->_bltID);
-    $this->assign('bltID', $this->_bltID);
-  }
-
   /**
    * Assign $this->processors, $this->recurPaymentProcessors, and related Smarty variables
    */
@@ -451,11 +436,10 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
         if (!empty($processor['description'])) {
           $this->_processors[$id] .= ' : ' . ts($processor['description']);
         }
+        if ($processor['is_recur']) {
+          $this->_recurPaymentProcessors[$id] = $this->_processors[$id];
+        }
       }
-      //get the valid recurring processors.
-      $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE;
-      $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1');
-      $this->_recurPaymentProcessors = array_intersect_key($this->_processors, $recurring);
     }
     $this->assign('recurringPaymentProcessorIds',
       empty($this->_recurPaymentProcessors) ? '' : implode(',', array_keys($this->_recurPaymentProcessors))
@@ -593,7 +577,7 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
   }
 
   /**
-   * @param $submittedValues
+   * @param array $submittedValues
    *
    * @return mixed
    */
@@ -640,8 +624,7 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
 
         $this->assignBillingType();
 
-        $this->_fields = array();
-        CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
+        CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor, FALSE, TRUE);
       }
     }
     catch (CRM_Core_Exception $e) {