/** * combine all the importable fields from the lower levels object * * The ordering is important, since currently we do not have a weight * scheme. Adding weight is super important and should be done in the * next week or so, before this can be called complete. * * @param int $contactType contact Type * @param boolean $status status is used to manipulate first title * @param boolean $showAll if true returns all fields (includes disabled fields) * * @return array array of importable Fields * @access public */ function &importableFields($contactType = 'Individual', $status = false, $showAll = false) { if (empty($contactType)) { $contactType = 'All'; } if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'] || !CRM_Utils_Array::value($contactType, $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'])) { if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields']) { $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'] = array(); } if (!$status) { $fields = array('do_not_import' => array('title' => ts('- do not import -'))); } else { $fields = array('' => array('title' => ts('- Contact Fields -'))); } if ($contactType != 'All') { require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $contactType) . ".php"; eval('$tmpFields = array_merge($fields, CRM_Contact_DAO_' . $contactType . '::import( ));'); $fields = array_merge($fields, $tmpFields); } else { foreach (array('Individual', 'Household', 'Organization') as $type) { require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $type) . ".php"; eval('$tmpFields = array_merge($fields, CRM_Contact_DAO_' . $type . '::import( ));'); $fields = array_merge($fields, $tmpFields); } } // the fields are only meant for Individual contact type if ($contactType == 'Individual' || $contactType == 'All') { $fields = array_merge($fields, CRM_Core_DAO_IndividualPrefix::import(true), CRM_Core_DAO_IndividualSuffix::import(true), CRM_Core_DAO_Gender::import(true)); } $locationFields = array_merge(CRM_Core_DAO_Location::import(), CRM_Core_DAO_Address::import(), CRM_Core_DAO_Phone::import(), CRM_Core_DAO_Email::import(), CRM_Core_DAO_IM::import(true)); foreach ($locationFields as $key => $field) { $locationFields[$key]['hasLocationType'] = true; } $fields = array_merge($fields, $locationFields); $fields = array_merge($fields, CRM_Contact_DAO_Contact::import()); $fields = array_merge($fields, CRM_Core_DAO_Note::import()); if ($contactType != 'All') { $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $showAll)); } else { foreach (array('Individual', 'Household', 'Organization') as $type) { $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, $showAll)); } } $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'][$contactType] = $fields; } return $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_importableFields'][$contactType]; }