CRM-15962
authorjoannechester <joannechester@users.noreply.github.com>
Sun, 15 Feb 2015 23:49:10 +0000 (10:49 +1100)
committerjoannechester <joannechester@users.noreply.github.com>
Sun, 15 Feb 2015 23:49:10 +0000 (10:49 +1100)
CRM/Member/Form/MembershipRenewal.php

index 2a52f6934a4d7eb1e3a844deffd9020cafec90b7..9e136093228bd4620c85117fe6191d3e67935e68 100644 (file)
@@ -221,47 +221,20 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     $this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
 
     if ($this->_mode) {
-      $fields = array();
-
-      foreach ($this->_fields as $name => $dontCare) {
-        $fields[$name] = 1;
+      // set default country from config if no country set
+      $config = CRM_Core_Config::singleton();
+      if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
+        $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
       }
 
-      $names = array(
-        'first_name',
-        'middle_name',
-        'last_name',
-        "street_address-{$this->_bltID}",
-        "city-{$this->_bltID}",
-        "postal_code-{$this->_bltID}",
-        "country_id-{$this->_bltID}",
-        "state_province_id-{$this->_bltID}",
-      );
-      foreach ($names as $name) {
-        $fields[$name] = 1;
+      if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
+        $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
       }
 
-      $fields["state_province-{$this->_bltID}"] = 1;
-      $fields["country-{$this->_bltID}"] = 1;
-      $fields["email-{$this->_bltID}"] = 1;
-      $fields['email-Primary'] = 1;
-
-      CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $this->_defaults);
-
-      // use primary email address if billing email address is empty
-      if (empty($this->_defaults["email-{$this->_bltID}"]) &&
-        !empty($this->_defaults['email-Primary'])
-      ) {
-        $defaults["email-{$this->_bltID}"] = $this->_defaults['email-Primary'];
-      }
+      $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
+      $defaults = array_merge($defaults, $billingDefaults);
 
-      foreach ($names as $name) {
-        if (!empty($this->_defaults[$name])) {
-          $defaults['billing_' . $name] = $this->_defaults[$name];
-        }
-      }
     }
-
     return $defaults;
   }