/** * combine all the importable fields from the lower levels object * * @return array array of importable Fields * @access public */ function &importableFields($contactType = 'Individual', $status = true, $onlyParticipant = false) { if (!self::$_importableFields) { if (!self::$_importableFields) { self::$_importableFields = array(); } if (!$onlyParticipant) { if (!$status) { $fields = array('' => array('title' => ts('- do not import -'))); } else { $fields = array('' => array('title' => ts('- Participant Fields -'))); } } else { $fields = array(); } require_once 'CRM/Core/DAO/Note.php'; $tmpFields = CRM_Event_DAO_Participant::import(); $note = array('participant_note' => array('title' => 'Participant Note', 'name' => 'participant_note', 'headerPattern' => '/(participant.)?note$/i')); $participantStatus = array('participant_status' => array('title' => 'Participant Status', 'name' => 'participant_status', 'data_type' => CRM_Utils_Type::T_STRING)); $participantRole = array('participant_role' => array('title' => 'Participant Role', 'name' => 'participant_role', 'data_type' => CRM_Utils_Type::T_STRING)); $eventType = array('event_type' => array('title' => 'Event Type', 'name' => 'event_type', 'data_type' => CRM_Utils_Type::T_STRING)); $tmpConatctField = array(); if (!$onlyParticipant) { require_once 'CRM/Contact/BAO/Contact.php'; $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, null); // Using new Dedupe rule. $ruleParams = array('contact_type' => $contactType, 'level' => 'Strict'); require_once 'CRM/Dedupe/BAO/Rule.php'; $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); if (is_array($fieldsArray)) { foreach ($fieldsArray as $value) { $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields); if (!$status) { $title = $tmpContactField[trim($value)]['title'] . " (match to contact)"; } else { $title = $tmpContactField[trim($value)]['title']; } $tmpContactField[trim($value)]['title'] = $title; } } } $tmpContactField['external_identifier'] = CRM_Utils_Array::value('external_identifier', $contactFields); $tmpContactField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " (match to contact)"; $tmpFields['participant_contact_id']['title'] = $tmpFields['participant_contact_id']['title'] . " (match to contact)"; $fields = array_merge($fields, $tmpContactField); $fields = array_merge($fields, $tmpFields); $fields = array_merge($fields, $note, $participantStatus, $participantRole, $eventType); //$fields = array_merge($fields, $optionFields); $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Participant')); self::$_importableFields = $fields; } return self::$_importableFields; }
/** * Combine all the importable fields from the lower levels object. * * @param string $contactType * @param bool $status * @param bool $onlyParticipant * @param bool $checkPermission * Is this a permissioned retrieval? * * @return array * array of importable Fields */ public static function &importableFields($contactType = 'Individual', $status = TRUE, $onlyParticipant = FALSE, $checkPermission = TRUE) { if (!self::$_importableFields) { if (!$onlyParticipant) { if (!$status) { $fields = array('' => array('title' => ts('- do not import -'))); } else { $fields = array('' => array('title' => ts('- Participant Fields -'))); } } else { $fields = array(); } $tmpFields = CRM_Event_DAO_Participant::import(); $note = array('participant_note' => array('title' => ts('Participant Note'), 'name' => 'participant_note', 'headerPattern' => '/(participant.)?note$/i')); // Split status and status id into 2 fields // Fixme: it would be better to leave as 1 field and intelligently handle both during import $participantStatus = array('participant_status' => array('title' => ts('Participant Status'), 'name' => 'participant_status', 'data_type' => CRM_Utils_Type::T_STRING)); $tmpFields['participant_status_id']['title'] = ts('Participant Status Id'); // Split role and role id into 2 fields // Fixme: it would be better to leave as 1 field and intelligently handle both during import $participantRole = array('participant_role' => array('title' => ts('Participant Role'), 'name' => 'participant_role', 'data_type' => CRM_Utils_Type::T_STRING)); $tmpFields['participant_role_id']['title'] = ts('Participant Role Id'); $eventType = array('event_type' => array('title' => ts('Event Type'), 'name' => 'event_type', 'data_type' => CRM_Utils_Type::T_STRING)); $tmpContactField = $contactFields = array(); $contactFields = array(); if (!$onlyParticipant) { $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL); // Using new Dedupe rule. $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised'); $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); if (is_array($fieldsArray)) { foreach ($fieldsArray as $value) { $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name'); $value = $customFieldId ? 'custom_' . $customFieldId : $value; $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields); if (!$status) { $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)'; } else { $title = $tmpContactField[trim($value)]['title']; } $tmpContactField[trim($value)]['title'] = $title; } } } $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields); if ($extIdentifier) { $tmpContactField['external_identifier'] = $extIdentifier; $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)'; } $tmpFields['participant_contact_id']['title'] = $tmpFields['participant_contact_id']['title'] . ' (match to contact)'; $fields = array_merge($fields, $tmpContactField); $fields = array_merge($fields, $tmpFields); $fields = array_merge($fields, $note, $participantStatus, $participantRole, $eventType); $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Participant', FALSE, FALSE, FALSE, $checkPermission)); self::$_importableFields = $fields; } return self::$_importableFields; }
/** * combine all the importable fields from the lower levels object * * @return array array of importable Fields * @access public * @static */ static function &importableFields($contactType = 'Individual', $status = TRUE, $onlyParticipant = FALSE) { if (!self::$_importableFields) { if (!$onlyParticipant) { if (!$status) { $fields = array('' => array('title' => ts('- do not import -'))); } else { $fields = array('' => array('title' => ts('- Participant Fields -'))); } } else { $fields = array(); } $tmpFields = CRM_Event_DAO_Participant::import(); $note = array('participant_note' => array('title' => 'Participant Note', 'name' => 'participant_note', 'headerPattern' => '/(participant.)?note$/i')); $participantStatus = array('participant_status' => array('title' => 'Participant Status', 'name' => 'participant_status', 'data_type' => CRM_Utils_Type::T_STRING)); $participantRole = array('participant_role' => array('title' => 'Participant Role', 'name' => 'participant_role', 'data_type' => CRM_Utils_Type::T_STRING)); $eventType = array('event_type' => array('title' => 'Event Type', 'name' => 'event_type', 'data_type' => CRM_Utils_Type::T_STRING)); $tmpContactField = $contactFields = array(); $contactFields = array(); if (!$onlyParticipant) { $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL); // Using new Dedupe rule. $ruleParams = array('contact_type' => $contactType, 'level' => 'Strict'); $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); if (is_array($fieldsArray)) { foreach ($fieldsArray as $value) { $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name'); $value = $customFieldId ? 'custom_' . $customFieldId : $value; $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields); if (!$status) { $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)'; } else { $title = $tmpContactField[trim($value)]['title']; } $tmpContactField[trim($value)]['title'] = $title; } } } $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields); if ($extIdentifier) { $tmpContactField['external_identifier'] = $extIdentifier; $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)'; } $tmpFields['participant_contact_id']['title'] = $tmpFields['participant_contact_id']['title'] . ' (match to contact)'; //campaign fields. if (isset($tmpFields['participant_campaign_id'])) { $tmpFields['participant_campaign'] = array('title' => ts('Campaign Title')); } $fields = array_merge($fields, $tmpContactField); $fields = array_merge($fields, $tmpFields); $fields = array_merge($fields, $note, $participantStatus, $participantRole, $eventType); //$fields = array_merge($fields, $optionFields); $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Participant')); self::$_importableFields = $fields; } return self::$_importableFields; }