Example #1
0
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  */
 function &export($prefix = false)
 {
     if (!$GLOBALS['_CRM_CORE_DAO_GENDER']['_export']) {
         $GLOBALS['_CRM_CORE_DAO_GENDER']['_export'] = array();
         $fields =& CRM_Core_DAO_Gender::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     $GLOBALS['_CRM_CORE_DAO_GENDER']['_export']['gender'] =& $fields[$name];
                 } else {
                     $GLOBALS['_CRM_CORE_DAO_GENDER']['_export'][$name] =& $fields[$name];
                 }
             }
         }
     }
     return $GLOBALS['_CRM_CORE_DAO_GENDER']['_export'];
 }
Example #2
0
 /**
  * class constructor
  */
 function CRM_Core_BAO_Gender()
 {
     parent::CRM_Core_DAO_Gender();
 }
Example #3
0
 /**
  * combine all the exportable fields from the lower levels object
  * 
  * currentlty we are using importable fields as exportable fields
  *
  * @param int     $contactType contact Type
  * $param boolean $status true while exporting primary contacts
  * $param boolean $export true when used during export
  *
  * @return array array of exportable Fields
  * @access public
  */
 function &exportableFields($contactType = 'Individual', $status = false, $export = false)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'] || !CRM_Utils_Array::value($contactType, $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'])) {
         if (!$GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields']) {
             $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'] = array();
         }
         if (!$status) {
             $fields = array();
         } else {
             $fields = array('' => array('title' => ts('- Contact Fields -')));
         }
         if ($contactType != 'All') {
             require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $contactType) . ".php";
             eval('$fields = array_merge($fields, CRM_Contact_DAO_' . $contactType . '::export( ));');
         } else {
             foreach (array('Individual', 'Household', 'Organization') as $type) {
                 require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $type) . ".php";
                 eval('$fields = array_merge($fields, CRM_Contact_DAO_' . $type . '::export( ));');
                 if ($type == 'Individual') {
                     $fields = array_merge($fields, CRM_Core_DAO_IndividualPrefix::export(true), CRM_Core_DAO_IndividualSuffix::export(true), CRM_Core_DAO_Gender::export(true));
                 }
             }
         }
         // the fields are only meant for Individual contact type
         if ($contactType == 'Individual') {
             $fields = array_merge($fields, CRM_Core_DAO_IndividualPrefix::export(true), CRM_Core_DAO_IndividualSuffix::export(true), CRM_Core_DAO_Gender::export(true));
         }
         $locationType = array();
         if ($status) {
             $locationType['location_type'] = array('name' => 'location_type', 'where' => 'civicrm_location_type.name', 'title' => 'Location Type');
         }
         $IMProvider = array();
         if ($status) {
             $IMProvider['im_provider'] = array('name' => 'im_provider', 'where' => 'civicrm_im_provider.name', 'title' => 'IM Provider');
         }
         $locationFields = array_merge($locationType, CRM_Core_DAO_Location::export(), CRM_Core_DAO_Address::export(), CRM_Core_DAO_Phone::export(), CRM_Core_DAO_Email::export(), $IMProvider, CRM_Core_DAO_IM::export(true));
         foreach ($locationFields as $key => $field) {
             $locationFields[$key]['hasLocationType'] = true;
         }
         $fields = array_merge($fields, $locationFields);
         $fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
         $fields = array_merge($fields, CRM_Core_DAO_Note::export());
         if ($contactType != 'All') {
             $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $status));
         } else {
             foreach (array('Individual', 'Household', 'Organization') as $type) {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type));
             }
         }
         //fix for CRM-791
         if ($export) {
             $fields = array_merge($fields, array('groups' => array('title' => ts('Group(s)'))));
             $fields = array_merge($fields, array('tags' => array('title' => ts('Tag(s)'))));
         } else {
             $fields = array_merge($fields, array('group' => array('title' => ts('Group(s)'))));
             $fields = array_merge($fields, array('tag' => array('title' => ts('Tag(s)'))));
         }
         $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'][$contactType] = $fields;
     }
     return $GLOBALS['_CRM_CONTACT_BAO_CONTACT']['_exportableFields'][$contactType];
 }