CRM-17256 fix e-notices on country & state
authoreileenmcnaugton <eileen@fuzion.co.nz>
Thu, 15 Oct 2015 12:29:51 +0000 (01:29 +1300)
committereileenmcnaugton <eileen@fuzion.co.nz>
Thu, 15 Oct 2015 12:29:51 +0000 (01:29 +1300)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Core/Payment/Form.php
CRM/Event/Form/Registration/Confirm.php

index 1b68cbca3164a1e717d00547ed3f44d723ed285d..d61e469a4e39dd1ea501d359a5ce786bff06a63d 100644 (file)
@@ -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']);
index 3ac8637c5cb09c9f39ac12e29ac9cfe8794b5ee1..ae03e8fa7890a769a28ab039bde58115a22fbf45 100644 (file)
@@ -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) {
index b7348b067c3b5b5e87c889b21d4fd2e4b720425e..cdce54fcb05b15ae5fca043a21fa8d98eacf819a 100644 (file)
@@ -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)