/** * * Get the values for pseudoconstants for name->value and reverse. * * @param array $defaults (reference) the default values, some of which need to be resolved. * @param boolean $reverse true if we want to resolve the values in the reverse direction (value -> name) * * @return none * @access public * @static */ function resolveDefaults(&$defaults, $reverse = false) { // hack for birth_date if (CRM_Utils_Array::value('birth_date', $defaults)) { if (is_array($defaults['birth_date'])) { $defaults['birth_date'] = CRM_Utils_Date::format($defaults['birth_date'], '-'); } } if (CRM_Utils_Array::value('prefix', $defaults)) { CRM_Contact_BAO_Contact::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::individualPrefix(), $reverse); } if (CRM_Utils_Array::value('suffix', $defaults)) { CRM_Contact_BAO_Contact::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::individualSuffix(), $reverse); } if (CRM_Utils_Array::value('gender', $defaults)) { CRM_Contact_BAO_Contact::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::gender(), $reverse); } if (array_key_exists('location', $defaults)) { $locations =& $defaults['location']; foreach ($locations as $index => $location) { $location =& $locations[$index]; CRM_Contact_BAO_Contact::lookupValue($location, 'location_type', CRM_Core_PseudoConstant::locationType(), $reverse); // FIXME: lookupValue doesn't work for vcard_name $vcardNames =& CRM_Core_PseudoConstant::locationVcardName(); $location['vcard_name'] = $vcardNames[$location['location_type_id']]; if (array_key_exists('address', $location)) { if (!CRM_Contact_BAO_Contact::lookupValue($location['address'], 'state_province', CRM_Core_PseudoConstant::stateProvince(), $reverse) && $reverse) { CRM_Contact_BAO_Contact::lookupValue($location['address'], 'state_province', CRM_Core_PseudoConstant::stateProvinceAbbreviation(), $reverse); } if (!CRM_Contact_BAO_Contact::lookupValue($location['address'], 'country', CRM_Core_PseudoConstant::country(), $reverse) && $reverse) { CRM_Contact_BAO_Contact::lookupValue($location['address'], 'country', CRM_Core_PseudoConstant::countryIsoCode(), $reverse); } CRM_Contact_BAO_Contact::lookupValue($location['address'], 'county', CRM_Core_SelectValues::county(), $reverse); } if (array_key_exists('im', $location)) { $ims =& $location['im']; foreach ($ims as $innerIndex => $im) { $im =& $ims[$innerIndex]; CRM_Contact_BAO_Contact::lookupValue($im, 'provider', CRM_Core_PseudoConstant::IMProvider(), $reverse); unset($im); } } unset($location); } } }