From 0b05b9a92bde39f960c42ed47e656c02aa9a32a4 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Fri, 16 Oct 2015 01:29:51 +1300 Subject: [PATCH] CRM-17256 fix e-notices on country & state --- CRM/Contribute/Form/Contribution/Confirm.php | 6 ---- CRM/Core/Payment/Form.php | 34 +++++++++++--------- CRM/Event/Form/Registration/Confirm.php | 13 ++------ 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 1b68cbca31..d61e469a4e 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -215,12 +215,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // We may have fetched some billing details from the getPreApprovalDetails function so we // want to ensure we set this after that function has been called. CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $this->_params, FALSE); - if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) { - $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]); - } - if (!empty($this->_params["billing_country_id-{$this->_bltID}"])) { - $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]); - } $this->_params['is_pay_later'] = $this->get('is_pay_later'); $this->assign('is_pay_later', $this->_params['is_pay_later']); diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php index 3ac8637c5c..ae03e8fa78 100644 --- a/CRM/Core/Payment/Form.php +++ b/CRM/Core/Payment/Form.php @@ -344,22 +344,26 @@ class CRM_Core_Payment_Form { * @param bool $reverse */ public static function mapParams($id, $src, &$dst, $reverse = FALSE) { - static $map = NULL; - if (!$map) { - $map = array( - 'first_name' => 'billing_first_name', - 'middle_name' => 'billing_middle_name', - 'last_name' => 'billing_last_name', - 'email' => "email-$id", - 'street_address' => "billing_street_address-$id", - 'supplemental_address_1' => "billing_supplemental_address_1-$id", - 'city' => "billing_city-$id", - 'state_province' => "billing_state_province-$id", - 'postal_code' => "billing_postal_code-$id", - 'country' => "billing_country-$id", - 'contactID' => 'contact_id', - ); + // Set text version of state & country if present. + if (isset($src["billing_state_province_id-{$id}"])) { + $src["billing_state_province-{$id}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation ($src["billing_state_province_id-{$id}"]); } + if (isset($src["billing_country_id-{$id}"])) { + $src["billing_country-{$id}"] = CRM_Core_PseudoConstant::countryIsoCode($src["billing_country_id-{$id}"]);; + }; + $map = array( + 'first_name' => 'billing_first_name', + 'middle_name' => 'billing_middle_name', + 'last_name' => 'billing_last_name', + 'email' => "email-$id", + 'street_address' => "billing_street_address-$id", + 'supplemental_address_1' => "billing_supplemental_address_1-$id", + 'city' => "billing_city-$id", + 'state_province' => "billing_state_province-$id", + 'postal_code' => "billing_postal_code-$id", + 'country' => "billing_country-$id", + 'contactID' => 'contact_id', + ); foreach ($map as $n => $v) { if (!$reverse) { diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index b7348b067c..cdce54fcb0 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -95,18 +95,8 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters')); $params = array_merge($this->_params, $preApprovalParams); } - CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, FALSE); - // fix state and country id if present - // @todo - this is duplicated further down. - if (isset($params["billing_state_province_id-{$this->_bltID}"])) { - $params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["billing_state_province_id-{$this->_bltID}"]); - } - if (isset($params['billing_country_id'])) { - $params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["billing_country_id-{$this->_bltID}"]); - } - // set a few other parameters that are not really specific to this method because we don't know what // will break if we change this. $params['amount'] = $this->_params[0]['amount']; @@ -499,6 +489,9 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { CRM_Event_Form_Registration_Confirm::fixLocationFields($value, $fields, $this); //unset the billing parameters if it is pay later mode //to avoid creation of billing location + // @todo - the reasoning for this is unclear - elsewhere we check what fields are provided by + // the form & if billing fields exist we create the address, relying on the form to collect + // only information we intend to store. if ($this->_allowWaitlist || $this->_requireApproval || (!empty($value['is_pay_later']) && !$this->_isBillingAddressRequiredForPayLater) -- 2.25.1