Merge branch 'master' of https://github.com/civicrm/civicrm-core into labels
[civicrm-core.git] / api / v3 / Profile.php
index 7c41d54d96d70f2c5776aa475ccde60764450d0b..73b0c83310b39877b667c66de6a47aaab0d1fe77 100644 (file)
@@ -364,21 +364,28 @@ function civicrm_api3_profile_apply($params) {
  *  interim solution is just to return an empty array
  */
 function _civicrm_api3_profile_getbillingpseudoprofile(&$params) {
-  $addressFields = array('street_address', 'city', 'state_province_id', 'country_id', 'postal_code');
+
   $locations = civicrm_api3('address', 'getoptions', array('field' => 'location_type_id'));
   $locationTypeID = array_search('Billing', $locations['values']);
 
   if(empty($params['contact_id'])) {
+    $config = CRM_Core_Config::singleton();
     $blanks =  array(
       'billing_first_name' => '',
       'billing_middle_name' => '',
       'billing_last_name' => '',
+      'email-' . $locationTypeID => '',
+      'billing_email-' . $locationTypeID => '',
+      'billing_city-' . $locationTypeID => '',
+      'billing_postal_code-' . $locationTypeID => '',
+      'billing_street_address-' . $locationTypeID => '',
+      'billing_country_id-' . $locationTypeID => $config->defaultContactCountry,
+      'billing_state_province_id-' . $locationTypeID => $config->defaultContactStateProvince,
     );
-    foreach ($addressFields as $field) {
-      $blanks['billing_' . $field . '_' . $locationTypeID] = '';
-    }
     return $blanks;
   }
+
+  $addressFields = array('street_address', 'city', 'state_province_id', 'country_id', 'postal_code');
   $result = civicrm_api3('contact', 'getsingle', array(
     'id' => $params['contact_id'],
     'api.address.get.1' => array('location_type_id' => 'Billing',  'return' => $addressFields),
@@ -386,7 +393,7 @@ function _civicrm_api3_profile_getbillingpseudoprofile(&$params) {
     'api.address.get.2' => array('is_billing' => True, 'return' => $addressFields),
     'api.email.get.1' => array('location_type_id' => 'Billing',),
     'api.email.get.2' => array('is_billing' => True,),
-    'return' => 'api.email.get, api.address.get, api.address.getoptions, state_province, email, first_name, last_name, middle_name, ' . implode($addressFields, ','),
+    'return' => 'api.email.get, api.address.get, api.address.getoptions, country, state_province, email, first_name, last_name, middle_name, ' . implode($addressFields, ','),
    )
   );