From c0f62075ea04fb95095024b6b275f44304b6c655 Mon Sep 17 00:00:00 2001 From: eileenmcnaughton Date: Wed, 20 Jan 2016 22:21:33 +0000 Subject: [PATCH] Use better function for retrieving payment processor for recurring --- CRM/Contribute/BAO/ContributionRecur.php | 14 ++++++++------ CRM/Contribute/Form/UpdateSubscription.php | 11 ++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index f477d5c5a9..4ddab8cadf 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -113,7 +113,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi * @param array $params * (reference ) an assoc array of name/value pairs. * @param array $duplicates - * (reference ) store ids of duplicate contribs. + * (reference ) store ids of duplicate contributions. * * @return bool * true if duplicate, false otherwise @@ -157,19 +157,21 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi } /** + * Get the payment processor (array) for a recurring processor. + * * @param int $id - * @param $mode + * @param string $mode + * - Test or NULL - all other variants are ignored. * * @return array|null */ - public static function getPaymentProcessor($id, $mode) { - //FIX ME: + public static function getPaymentProcessor($id, $mode = NULL) { $sql = " SELECT r.payment_processor_id FROM civicrm_contribution_recur r WHERE r.id = %1"; $params = array(1 => array($id, 'Integer')); - $paymentProcessorID = &CRM_Core_DAO::singleValueQuery($sql, + $paymentProcessorID = CRM_Core_DAO::singleValueQuery($sql, $params ); if (!$paymentProcessorID) { @@ -180,7 +182,7 @@ SELECT r.payment_processor_id } /** - * Get the number of installment done/completed for each recurring contribution + * Get the number of installment done/completed for each recurring contribution. * * @param array $ids * (reference ) an array of recurring contribution ids. diff --git a/CRM/Contribute/Form/UpdateSubscription.php b/CRM/Contribute/Form/UpdateSubscription.php index e5dbe81dcf..fb61f50c46 100644 --- a/CRM/Contribute/Form/UpdateSubscription.php +++ b/CRM/Contribute/Form/UpdateSubscription.php @@ -32,7 +32,7 @@ */ /** - * This class generates form components generic to recurring contributions + * This class generates form components generic to recurring contributions. * * It delegates the work to lower level subclasses and integrates the changes * back in. It also uses a lot of functionality with the CRM API's, so any change @@ -64,12 +64,17 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Core_Form { */ public $_contactID; + /** + * Pre-processing for the form. + * + * @throws \Exception + */ public function preProcess() { $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); if ($this->_crid) { - $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info'); - $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj'); + $this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->_crid); + $this->_paymentProcessorObj = $this->_paymentProcessor['object']; $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid); } -- 2.25.1