From: Eileen McNaughton Date: Mon, 4 May 2015 12:14:17 +0000 (+1200) Subject: CRM-16357 Contribution form - moving towards extracting form variables earlier in... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9fc4e1d9b70e189825276947c7084ab3dd700876;p=civicrm-core.git CRM-16357 Contribution form - moving towards extracting form variables earlier in the process --- diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index b487eda352..0d84798531 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -120,7 +120,8 @@ class CRM_Contribute_BAO_Contribution_Utils { $contributionType, TRUE, TRUE, $isTest, - $lineItems + $lineItems, + $form->_bltID ); if ($contribution) { @@ -240,7 +241,8 @@ class CRM_Contribute_BAO_Contribution_Utils { $contributionType, TRUE, TRUE, $isTest, - $lineItems + $lineItems, + $form->_bltID ); // restore cached values (part of fix for CRM-14354) @@ -320,7 +322,8 @@ class CRM_Contribute_BAO_Contribution_Utils { $contactID, $contributionType, $pending, TRUE, $isTest, - $lineItems + $lineItems, + $form->_bltID ); } $form->postProcessPremium($premiumParams, $contribution); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 12cc85a6b8..24e91e9925 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1188,7 +1188,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP TRUE, FALSE, $isTest, - $this->_lineItem + $this->_lineItem, + $this->_bltID ); $paymentParams['contributionID'] = $contribution->id; $paymentParams['contributionTypeID'] = $contribution->financial_type_id; @@ -1266,7 +1267,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $financialType, FALSE, FALSE, $isTest, - $lineItem + $lineItem, + $form->_bltID ); } diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 90ee08f4af..ed30082f44 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1274,8 +1274,11 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr * @param bool $isTest * @param array $lineItems * - * @throws Exception - * @return CRM_Contribute_DAO_Contribution + * @param int $billingLocationID + * ID of billing location type. + * + * @return \CRM_Contribute_DAO_Contribution + * @throws \Exception */ public static function processContribution( &$form, @@ -1286,17 +1289,21 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $pending, $online, $isTest, - $lineItems + $lineItems, + $billingLocationID ) { $transaction = new CRM_Core_Transaction(); $contribSoftContactId = $addressID = NULL; + $contributeMode = $form->_contributeMode; + $isMonetary = !empty($form->_values['is_monetary']); + $isEmailReceipt = !empty($form->_values['is_email_receipt']); // add these values for the recurringContrib function ,CRM-10188 $params['financial_type_id'] = $financialType->id; //create an contribution address - if ($form->_contributeMode != 'notify' && empty($params['is_pay_later']) && !empty($form->_values['is_monetary'])) { - $addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID); + if ($contributeMode != 'notify' && empty($params['is_pay_later']) && $isMonetary) { + $addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID); } //@todo - this is being set from the form to resolve CRM-10188 - an @@ -1305,8 +1312,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // a better fix would be to set the values in the respective forms rather than require // a function being shared by two forms to deal with their respective values // moving it to the BAO & not taking the $form as a param would make sense here. - if (!isset($params['is_email_receipt']) && !empty($form->_values['is_email_receipt'])) { - $params['is_email_receipt'] = CRM_Utils_Array::value('is_email_receipt', $form->_values); + if (!isset($params['is_email_receipt']) && $isEmailReceipt) { + $params['is_email_receipt'] = $isEmailReceipt; } $recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType, $online); $nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online); @@ -1314,7 +1321,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $now = date('YmdHis'); $receiptDate = CRM_Utils_Array::value('receipt_date', $params); - if (!empty($form->_values['is_email_receipt'])) { + if ($isEmailReceipt) { $receiptDate = $now; } @@ -1353,10 +1360,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } if (isset($params['amount'])) { - $isMonetary = NULL; - if (!empty($form->_values['is_monetary'])) { - $isMonetary = $form->_values['is_monetary']; - } $contribParams = self::getContributionParams( $params, $contactID, $financialType->id, $online, $contributionPageId, $nonDeductibleAmount, $campaignId, $isMonetary, $pending, $result, $receiptDate, $recurringContributionID, $isTest, $addressID, $contribSoftContactId, $lineItems @@ -1536,7 +1539,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // is not appropriate to delete a valid contribution if a user create problem occurs CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, - 'email-' . $form->_bltID + 'email-' . $billingLocationID ); return $contribution; } diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 05c3433776..30770fa331 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -2260,7 +2260,8 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND $pending, TRUE, $isTest, - $lineItems + $lineItems, + $form->_bltID ); return $membershipContribution; } diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 3e65fbe17f..56343ada36 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1375,7 +1375,8 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; TRUE, FALSE, $isTest, - $lineItems + $lineItems, + $this->_bltID ); //create new soft-credit record, CRM-13981