本文整理汇总了PHP中CRM_Contact_BAO_Contact::importableFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::importableFields方法的具体用法?PHP CRM_Contact_BAO_Contact::importableFields怎么用?PHP CRM_Contact_BAO_Contact::importableFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::importableFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* 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
*
* @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)
* @param boolean $isProfile if its profile mode
* @param boolean $checkPermission if false, do not include permissioning clause (for custom data)
*
* @return array array of importable Fields
* @access public
* @static
*/
static function &importableFields($contactType = 'Individual', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
{
$contactType = 'Individual';
$fields = CRM_Hrjobcontract_DAO_HRJobContract::import();
$tmpContactField = $contactFields = array();
$contactFields = array();
$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)';
}
$fields = array_merge($fields, $tmpContactField);
self::$_importableFields = $fields;
return self::$_importableFields;
//$fields;
}
示例2: buildCiviCRMFieldList
public static function buildCiviCRMFieldList()
{
$fields = CRM_Contact_BAO_Contact::importableFields('Individual', FALSE, TRUE);
foreach ($fields as $field_name => $field) {
if (!empty($field['custom_field_id'])) {
$custom_field = civicrm_api3('CustomField', 'getsingle', array('id' => $field['custom_field_id']));
if (!empty($custom_field['option_group_id'])) {
$fields[$field_name]['pseudoconstant'] = array('optionGroupName' => civicrm_api3('OptionGroup', 'getvalue', array('return' => 'name', 'id' => $custom_field['option_group_id'])));
}
}
}
return $fields;
}
示例3: array
/**
* Return a structure holding the supported tables, fields and their titles
*
* @param string $requestedType the requested contact type
*
* @return array a table-keyed array of field-keyed arrays holding supported fields' titles
*/
function &supportedFields($requestedType)
{
static $fields = null;
if (!$fields) {
// this is needed, as we're piggy-backing importableFields() below
$replacements = array('civicrm_country.name' => 'civicrm_address.country_id', 'civicrm_county.name' => 'civicrm_address.county_id', 'civicrm_state_province.name' => 'civicrm_address.state_province_id', 'gender.label' => 'civicrm_contact.gender_id', 'individual_prefix.label' => 'civicrm_contact.prefix_id', 'individual_suffix.label' => 'civicrm_contact.suffix_id', 'addressee.label' => 'civicrm_contact.addressee_id', 'email_greeting.label' => 'civicrm_contact.email_greeting_id', 'postal_greeting.label' => 'civicrm_contact.postal_greeting_id');
// the table names we support in dedupe rules - a filter for importableFields()
$supportedTables = array('civicrm_address', 'civicrm_contact', 'civicrm_email', 'civicrm_im', 'civicrm_note', 'civicrm_openid', 'civicrm_phone');
require_once 'CRM/Contact/BAO/Contact.php';
require_once 'CRM/Core/BAO/CustomGroup.php';
foreach (array('Individual', 'Organization', 'Household') as $ctype) {
// take the table.field pairs and their titles from importableFields() if the table is supported
foreach (CRM_Contact_BAO_Contact::importableFields($ctype) as $iField) {
if (isset($iField['where'])) {
$where = $iField['where'];
if (isset($replacements[$where])) {
$where = $replacements[$where];
}
list($table, $field) = explode('.', $where);
if (!in_array($table, $supportedTables)) {
continue;
}
$fields[$ctype][$table][$field] = $iField['title'];
}
}
// add custom data fields
foreach (CRM_Core_BAO_CustomGroup::getTree($ctype, CRM_Core_DAO::$_nullObject, null, -1) as $key => $cg) {
if (!is_int($key)) {
continue;
}
foreach ($cg['fields'] as $cf) {
$fields[$ctype][$cg['table_name']][$cf['column_name']] = $cf['label'];
}
}
}
}
return $fields[$requestedType];
}
示例4: addField
/**
* @param string $name
* @param $title
* @param int $type
* @param string $headerPattern
* @param string $dataPattern
*/
public function addField($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//')
{
if (empty($name)) {
$this->_fields['doNotImport'] = new CRM_Member_Import_Field($name, $title, $type, $headerPattern, $dataPattern);
} else {
//$tempField = CRM_Contact_BAO_Contact::importableFields('Individual', null );
$tempField = CRM_Contact_BAO_Contact::importableFields('All', NULL);
if (!array_key_exists($name, $tempField)) {
$this->_fields[$name] = new CRM_Member_Import_Field($name, $title, $type, $headerPattern, $dataPattern);
} else {
$this->_fields[$name] = new CRM_Contact_Import_Field($name, $title, $type, $headerPattern, $dataPattern, CRM_Utils_Array::value('hasLocationType', $tempField[$name]));
}
}
}
示例5: array
/**
* 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.
*
* @return array array of importable Fields
* @access public
*/
function &importableFields($contacType = 'Individual', $status = true)
{
if (!self::$_importableFields) {
if (!self::$_importableFields) {
self::$_importableFields = array();
}
if (!$status) {
$fields = array('' => array('title' => ts('- do not import -')));
} else {
$fields = array('' => array('title' => ts('- Contribution Fields -')));
}
require_once 'CRM/Core/DAO/Note.php';
$note = CRM_Core_DAO_Note::import();
$tmpFields = CRM_Contribute_DAO_Contribution::import();
unset($tmpFields['option_value']);
require_once 'CRM/Core/OptionValue.php';
$optionFields = CRM_Core_OptionValue::getFields($mode = 'contribute');
require_once 'CRM/Contact/BAO/Contact.php';
$contactFields = CRM_Contact_BAO_Contact::importableFields($contacType, null);
// Using new Dedupe rule.
$ruleParams = array('contact_type' => $contacType, 'level' => 'Strict');
require_once 'CRM/Dedupe/BAO/Rule.php';
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
$tmpConatctField = array();
if (is_array($fieldsArray)) {
foreach ($fieldsArray as $value) {
//skip if there is no dupe rule
if ($value == 'none') {
continue;
}
$tmpConatctField[trim($value)] = $contactFields[trim($value)];
if (!$status) {
$title = $tmpConatctField[trim($value)]['title'] . " (match to contact)";
} else {
$title = $tmpConatctField[trim($value)]['title'];
}
$tmpConatctField[trim($value)]['title'] = $title;
}
}
$tmpConatctField['external_identifier'] = $contactFields['external_identifier'];
$tmpConatctField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " (match to contact)";
$tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['title'] . " (match to contact)";
$fields = array_merge($fields, $tmpConatctField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, $note);
$fields = array_merge($fields, $optionFields);
require_once 'CRM/Contribute/DAO/ContributionType.php';
$fields = array_merge($fields, CRM_Contribute_DAO_ContributionType::export());
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
self::$_importableFields = $fields;
}
return self::$_importableFields;
}
示例6: init
/**
* the initializer code, called before the processing
*
* @return void
* @access public
*/
function init()
{
require_once 'CRM/Contact/BAO/Contact.php';
$fields =& CRM_Contact_BAO_Contact::importableFields($this->_contactType);
//CRM-5125
//supporting import for contact subtypes
if (!empty($this->_contactSubType)) {
//custom fields for sub type
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($this->_contactSubType);
if (!empty($subTypeFields)) {
foreach ($subTypeFields as $customSubTypeField => $details) {
$fields[$customSubTypeField] = $details;
}
}
}
//Relationship importables
$this->_relationships = $relations = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, null, null, $this->_contactType, false, 'label', true, $this->_contactSubType);
asort($relations);
foreach ($relations as $key => $var) {
list($type) = explode('_', $key);
$relationshipType[$key]['title'] = $var;
$relationshipType[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
$relationshipType[$key]['import'] = true;
$relationshipType[$key]['relationship_type_id'] = $type;
$relationshipType[$key]['related'] = true;
}
if (!empty($relationshipType)) {
$fields = array_merge($fields, array('related' => array('title' => ts('- related contact info -'))), $relationshipType);
}
foreach ($fields as $name => $field) {
$this->addField($name, $field['title'], CRM_Utils_Array::value('type', $field), CRM_Utils_Array::value('headerPattern', $field), CRM_Utils_Array::value('dataPattern', $field), CRM_Utils_Array::value('hasLocationType', $field));
}
$this->_newContacts = array();
$this->setActiveFields($this->_mapperKeys);
$this->setActiveFieldLocationTypes($this->_mapperLocType);
$this->setActiveFieldPhoneTypes($this->_mapperPhoneType);
//set active fields of IM provider of contact
$this->setActiveFieldImProviders($this->_mapperImProvider);
//related info
$this->setActiveFieldRelated($this->_mapperRelated);
$this->setActiveFieldRelatedContactType($this->_mapperRelatedContactType);
$this->setActiveFieldRelatedContactDetails($this->_mapperRelatedContactDetails);
$this->setActiveFieldRelatedContactLocType($this->_mapperRelatedContactLocType);
$this->setActiveFieldRelatedContactPhoneType($this->_mapperRelatedContactPhoneType);
//set active fields of IM provider of related contact
$this->setActiveFieldRelatedContactImProvider($this->_mapperRelatedContactImProvider);
$this->_phoneIndex = -1;
$this->_emailIndex = -1;
$this->_firstNameIndex = -1;
$this->_lastNameIndex = -1;
$this->_householdNameIndex = -1;
$this->_organizationNameIndex = -1;
$this->_externalIdentifierIndex = -1;
$index = 0;
foreach ($this->_mapperKeys as $key) {
if (substr($key, 0, 5) == 'email' && substr($key, 0, 14) != 'email_greeting') {
$this->_emailIndex = $index;
$this->_allEmails = array();
}
if (substr($key, 0, 5) == 'phone') {
$this->_phoneIndex = $index;
}
if ($key == 'first_name') {
$this->_firstNameIndex = $index;
}
if ($key == 'last_name') {
$this->_lastNameIndex = $index;
}
if ($key == 'household_name') {
$this->_householdNameIndex = $index;
}
if ($key == 'organization_name') {
$this->_organizationNameIndex = $index;
}
if ($key == 'external_identifier') {
$this->_externalIdentifierIndex = $index;
$this->_allExternalIdentifiers = array();
}
$index++;
}
$this->_updateWithId = false;
if (in_array('id', $this->_mapperKeys) || $this->_externalIdentifierIndex >= 0 && in_array($this->_onDuplicate, array(CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::DUPLICATE_FILL))) {
$this->_updateWithId = true;
}
require_once 'CRM/Core/BAO/Preferences.php';
$this->_parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Preferences::valueOptions('address_options'), false);
}
示例7: array
/**
* 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 bool $status
*
* @return array
* array of importable Fields
*/
public static function &importableFields($status = FALSE)
{
if (!self::$_importableFields) {
if (!self::$_importableFields) {
self::$_importableFields = array();
}
if (!$status) {
$fields = array('' => array('title' => ts('- do not import -')));
} else {
$fields = array('' => array('title' => ts('- Activity Fields -')));
}
$tmpFields = CRM_Activity_DAO_Activity::import();
$contactFields = CRM_Contact_BAO_Contact::importableFields('Individual', NULL);
// Using new Dedupe rule.
$ruleParams = array('contact_type' => 'Individual', 'used' => 'Unsupervised');
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
$tmpConatctField = array();
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;
$tmpConatctField[trim($value)] = $contactFields[trim($value)];
$tmpConatctField[trim($value)]['title'] = $tmpConatctField[trim($value)]['title'] . " (match to contact)";
}
}
$tmpConatctField['external_identifier'] = $contactFields['external_identifier'];
$tmpConatctField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " (match to contact)";
$fields = array_merge($fields, $tmpConatctField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Activity'));
self::$_importableFields = $fields;
}
return self::$_importableFields;
}
示例8: array
/**
* 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 string $contactType
* @param bool $status
*
* @return array
* array of importable Fields
*/
public static function &importableFields($contactType = 'Individual', $status = TRUE)
{
if (!self::$_importableFields) {
if (!self::$_importableFields) {
self::$_importableFields = array();
}
if (!$status) {
$fields = array('' => array('title' => ts('- do not import -')));
} else {
$fields = array('' => array('title' => ts('- Contribution Fields -')));
}
$note = CRM_Core_DAO_Note::import();
$tmpFields = CRM_Contribute_DAO_Contribution::import();
unset($tmpFields['option_value']);
$optionFields = CRM_Core_OptionValue::getFields($mode = 'contribute');
$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);
$tmpContactField = array();
if (is_array($fieldsArray)) {
foreach ($fieldsArray as $value) {
//skip if there is no dupe rule
if ($value == 'none') {
continue;
}
$customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
$value = $customFieldId ? 'custom_' . $customFieldId : $value;
$tmpContactField[trim($value)] = $contactFields[trim($value)];
if (!$status) {
$title = $tmpContactField[trim($value)]['title'] . ' ' . ts('(match to contact)');
} else {
$title = $tmpContactField[trim($value)]['title'];
}
$tmpContactField[trim($value)]['title'] = $title;
}
}
$tmpContactField['external_identifier'] = $contactFields['external_identifier'];
$tmpContactField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . ' ' . ts('(match to contact)');
$tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['title'] . ' ' . ts('(match to contact)');
$fields = array_merge($fields, $tmpContactField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, $note);
$fields = array_merge($fields, $optionFields);
$fields = array_merge($fields, CRM_Financial_DAO_FinancialType::export());
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
self::$_importableFields = $fields;
}
return self::$_importableFields;
}
示例9: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
//to save the current mappings
if (!$this->get('savedMapping')) {
$saveDetailsName = ts('Save this field mapping');
$this->applyFilter('saveMappingName', 'trim');
$this->add('text', 'saveMappingName', ts('Name'));
$this->add('text', 'saveMappingDesc', ts('Description'));
} else {
$savedMapping = $this->get('savedMapping');
list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingRelation) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping);
$mappingName = $mappingName[1];
$mappingContactType = $mappingContactType[1];
$mappingLocation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingLocation));
$mappingPhoneType = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingPhoneType));
$mappingRelation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingRelation));
//mapping is to be loaded from database
$params = array('id' => $savedMapping);
$temp = array();
$mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
$this->assign('loadedMapping', $mappingDetails->name);
$this->set('loadedMapping', $savedMapping);
$getMappingName = new CRM_Core_DAO_Mapping();
$getMappingName->id = $savedMapping;
$getMappingName->mapping_type = 'Import Contributions';
$getMappingName->find();
while ($getMappingName->fetch()) {
$mapperName = $getMappingName->name;
}
$this->assign('savedName', $mapperName);
$this->add('hidden', 'mappingId', $savedMapping);
$this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
$saveDetailsName = ts('Save as a new field mapping');
$this->add('text', 'saveMappingName', ts('Name'));
$this->add('text', 'saveMappingDesc', ts('Description'));
}
$this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
$this->addFormRule(array('CRM_Contribute_Import_Form_MapField', 'formRule'), $this);
//-------- end of saved mapping stuff ---------
$defaults = array();
$mapperKeys = array_keys($this->_mapperFields);
$hasHeaders = !empty($this->_columnHeaders);
$headerPatterns = $this->get('headerPatterns');
$dataPatterns = $this->get('dataPatterns');
$hasLocationTypes = $this->get('fieldTypes');
$mapperKeysValues = $this->controller->exportValue($this->_name, 'mapper');
/* Initialize all field usages to false */
foreach ($mapperKeys as $key) {
$this->_fieldUsed[$key] = FALSE;
}
$this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$sel1 = $this->_mapperFields;
if (!$this->get('onDuplicate')) {
unset($sel1['id']);
unset($sel1['contribution_id']);
}
// start of soft credit section
// get contact type for this import
$contactTypeId = $this->get('contactType');
$contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
$contactType = isset($contactTypes[$contactTypeId]) ? $contactTypes[$contactTypeId] : '';
// get importable fields for contact type
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
// get the Dedupe rule for this contact type and build soft credit array
$ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
$softCreditFields['contact_id'] = ts('Contact ID');
$softCreditFields['external_identifier'] = ts('External ID');
$softCreditFields['email'] = ts('Email');
$sel2['soft_credit'] = $softCreditFields;
$sel3['soft_credit']['contact_id'] = $sel3['soft_credit']['external_identifier'] = $sel3['soft_credit']['email'] = CRM_Core_OptionGroup::values('soft_credit_type');
$sel4 = NULL;
// end of soft credit section
$js = "<script type='text/javascript'>\n";
$formName = 'document.forms.' . $this->_name;
//used to warn for mismatch column count or mismatch mapping
$warning = 0;
for ($i = 0; $i < $this->_columnCount; $i++) {
$sel =& $this->addElement('hierselect', "mapper[{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
$jsSet = FALSE;
if ($this->get('savedMapping')) {
if (isset($mappingName[$i])) {
if ($mappingName[$i] != ts('- do not import -')) {
$mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);
// reusing contact_type field array for soft credit
$softField = isset($mappingContactType[$i]) ? $mappingContactType[$i] : 0;
if (!$softField) {
$js .= "{$formName}['mapper[{$i}][1]'].style.display = 'none';\n";
}
$js .= "{$formName}['mapper[{$i}][2]'].style.display = 'none';\n";
$js .= "{$formName}['mapper[{$i}][3]'].style.display = 'none';\n";
$defaults["mapper[{$i}]"] = array(CRM_Utils_Array::value(0, $mappingHeader), $softField ? $softField : "", isset($locationId) ? $locationId : "", isset($phoneType) ? $phoneType : "");
$jsSet = TRUE;
} else {
$defaults["mapper[{$i}]"] = array();
}
if (!$jsSet) {
//.........这里部分代码省略.........
示例10: getWhereClause
/**
* function to get match clasue for dupe checking
*
* @param array $params the list of values to be used in the where clause
* @param array $tables (reference ) add the tables that are needed for the select clause
*
* @return string the where clause to include in a sql query
* @static
* @access public
*
*/
function getWhereClause($params, &$tables)
{
require_once 'CRM/Core/DAO/DupeMatch.php';
if (is_array($params)) {
if (is_array($params['location'])) {
$params['email'] = array();
$params['phone'] = array();
$params['im'] = array();
foreach ($params['location'] as $loc) {
foreach (array('email', 'phone', 'im') as $key) {
if (is_array($loc[$key])) {
foreach ($loc[$key] as $value) {
if (!empty($value[$key])) {
$value[$key] = strtolower($value[$key]);
$params[$key][] = '"' . addslashes($value[$key]) . '"';
}
}
}
}
}
}
foreach (array('email', 'phone', 'im') as $key) {
if (count($params[$key]) == 0) {
unset($params[$key]);
}
}
foreach (array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'state_province_id', 'postal_code', 'country_id') as $fld) {
if (!empty($params['location'][1]['address'][$fld])) {
$params[$fld] = $params['location'][1]['address'][$fld];
}
}
if (is_array($params['custom'])) {
foreach ($params['custom'] as $key => $value) {
$params['custom_' . $value['custom_field_id']] = $value['value'];
}
}
}
$importableFields = CRM_Contact_BAO_Contact::importableFields();
$dupeMatchDAO =& new CRM_Core_DAO_DupeMatch();
$dupeMatchDAO->find();
while ($dupeMatchDAO->fetch()) {
$rule = explode('AND', $dupeMatchDAO->rule);
foreach ($rule as $name) {
$name = trim($name);
$fields[$name] = array('name' => $name, 'title' => $importableFields[$name]['title'], 'where' => $importableFields[$name]['where']);
}
}
require_once 'CRM/Contact/BAO/Query.php';
//this is the fix to ignore the groups/ tags for dupe checking CRM-664, since we never use them for dupe checking
$params['group'] = array();
$params['tag'] = array();
$whereTables = array();
return CRM_Contact_BAO_Query::getWhereClause($params, $fields, $tables, $whereTables, true);
}
示例11: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
function preProcess()
{
$this->_gid = CRM_Utils_Request::retrieve('gid', $this);
$this->_id = CRM_Utils_Request::retrieve('id', $this);
if ($this->_action & CRM_CORE_ACTION_UPDATE) {
$this->_fields =& CRM_Contact_BAO_Contact::importableFields('All', true, true);
} else {
$this->_fields =& CRM_Contact_BAO_Contact::importableFields('All', true);
}
$this->_fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $this->_fields);
$this->_selectFields = array();
foreach ($this->_fields as $name => $field) {
// lets skip note for now since we dont support it
if ($name == 'note') {
continue;
}
$this->_selectFields[$name] = $field['title'];
$this->_hasLocationTypes[$name] = $field['hasLocationType'];
}
// lets add group and tag to this list
$this->_selectFields['group'] = ts('Group(s)');
$this->_selectFields['tag'] = ts('Tag(s)');
}
示例12: array
/**
* 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;
}
示例13: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if ($this->_gid) {
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'title');
$this->setPageTitle(ts('Profile Field'));
$url = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
$breadCrumb = array(array('title' => ts('CiviCRM Profile Fields'), 'url' => $url));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
$showBestResult = CRM_Utils_Request::retrieve('sbr', 'Positive', CRM_Core_DAO::$_nullArray);
if ($showBestResult) {
$this->assign('showBestResult', $showBestResult);
}
$this->_fields = CRM_Contact_BAO_Contact::importableFields('All', TRUE, TRUE, TRUE, TRUE, TRUE);
$this->_fields = array_merge(CRM_Activity_BAO_Activity::exportableFields('Activity'), $this->_fields);
//unset campaign related fields.
if (isset($this->_fields['activity_campaign_id'])) {
$this->_fields['activity_campaign_id']['title'] = ts('Campaign');
if (isset($this->_fields['activity_campaign'])) {
unset($this->_fields['activity_campaign']);
}
}
if (CRM_Core_Permission::access('CiviContribute')) {
$this->_fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(FALSE), $this->_fields);
$this->_fields = array_merge(CRM_Core_BAO_UFField::getContribBatchEntryFields(), $this->_fields);
}
if (CRM_Core_Permission::access('CiviMember')) {
$this->_fields = array_merge(CRM_Member_BAO_Membership::getMembershipFields(), $this->_fields);
}
if (CRM_Core_Permission::access('CiviEvent')) {
$this->_fields = array_merge(CRM_Event_BAO_Query::getParticipantFields(), $this->_fields);
}
if (CRM_Core_Permission::access('CiviCase')) {
$this->_fields = array_merge(CRM_Case_BAO_Query::getFields(), $this->_fields);
}
$this->_fields = array_merge($this->_fields, CRM_Contact_BAO_Query_Hook::singleton()->getFields());
$this->_selectFields = array();
foreach ($this->_fields as $name => $field) {
// lets skip note for now since we dont support it
if ($name == 'note') {
continue;
}
$this->_selectFields[$name] = $field['title'];
$this->_hasLocationTypes[$name] = CRM_Utils_Array::value('hasLocationType', $field);
}
// lets add group, tag and current_employer to this list
$this->_selectFields['group'] = ts('Group(s)');
$this->_selectFields['tag'] = ts('Tag(s)');
$this->_selectFields['current_employer'] = ts('Current Employer');
$this->_selectFields['phone_and_ext'] = ts('Phone and Extension');
//CRM-4363 check for in selector or searchable fields.
$this->_hasSearchableORInSelector = CRM_Core_BAO_UFField::checkSearchableORInSelector($this->_gid);
$this->assign('fieldId', $this->_id);
if ($this->_id) {
$fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $this->_id, 'label');
$this->assign('fieldTitle', $fieldTitle);
}
}
示例14: array
/**
* 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.
*
* @return array array of importable Fields
* @access public
*/
function &importableFields()
{
if (!$GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['_importableFields']) {
if (!$GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['_importableFields']) {
$GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['_importableFields'] = array();
}
if (!$status) {
$fields = array('' => array('title' => ts('- do not import -')));
} else {
$fields = array('' => array('title' => ts('- Contribution Fields -')));
}
$tmpFields = CRM_Contribute_DAO_Contribution::import();
$contactFields = CRM_Contact_BAO_Contact::importableFields('Individual', null);
require_once 'CRM/Core/DAO/DupeMatch.php';
$dao =& new CRM_Core_DAO_DupeMatch();
$dao->find(true);
$fieldsArray = explode('AND', $dao->rule);
$tmpConatctField = array();
if (is_array($fieldsArray)) {
foreach ($fieldsArray as $value) {
$tmpConatctField[trim($value)] = $contactFields[trim($value)];
$tmpConatctField[trim($value)]['title'] = $tmpConatctField[trim($value)]['title'] . " (match to contact)";
}
}
$fields = array_merge($fields, $tmpConatctField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
$GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['_importableFields'] = $fields;
}
return $GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['_importableFields'];
}
示例15: array_merge
/**
* Replace all the org-level tokens in $str
*
* @param string $str The string with tokens to be replaced
* @param object $org Associative array of org properties
* @param boolean $html Replace tokens with HTML or plain text
* @return string The processed string
* @access public
* @static
*/
public static function &replaceOrgTokens($str, &$org, $html = false)
{
self::$_tokens['org'] = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields('Organization')), array('address', 'display_name', 'checksum', 'contact_id'));
/*
print "org tokens: <pre>";
print_r( $_tokens['org'] );
print "</pre>";
*/
$cv = null;
foreach (self::$_tokens['org'] as $token) {
// print "Getting token value for $token<br/><br/>";
if ($token == '') {
continue;
}
/* If the string doesn't contain this token, skip it. */
if (!self::token_match('org', $token, $str)) {
continue;
}
/* Construct value from $token and $contact */
$value = null;
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($token)) {
// only generate cv if we need it
if ($cv === null) {
$cv =& CRM_Core_BAO_CustomValue::getContactValues($org['contact_id']);
}
foreach ($cv as $cvFieldID => $value) {
if ($cvFieldID == $cfID) {
$value = CRM_Core_BAO_CustomOption::getOptionLabel($cfID, $value);
break;
}
}
} else {
if ($token == 'checksum') {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($org['contact_id']);
$value = "cs={$cs}";
} else {
if ($token == 'address') {
/* Build the location values array */
$loc = array();
$loc['display_name'] = CRM_Utils_Array::retrieveValueRecursive($org, 'display_name');
$loc['street_address'] = CRM_Utils_Array::retrieveValueRecursive($org, 'street_address');
$loc['city'] = CRM_Utils_Array::retrieveValueRecursive($org, 'city');
$loc['state_province'] = CRM_Utils_Array::retrieveValueRecursive($org, 'state_province');
$loc['postal_code'] = CRM_Utils_Array::retrieveValueRecursive($org, 'postal_code');
/* Construct the address token */
$value = CRM_Utils_Address::format($loc);
if ($html) {
$value = str_replace("\n", '<br />', $value);
}
} else {
/*
print "\$org: <pre>";
print_r( $org );
print "</pre>";
*/
$value = CRM_Utils_Array::retrieveValueRecursive($org, $token);
/*
print "\$value: <pre>";
print_r( $value );
print "</pre>";
*/
}
}
}
self::token_replace('org', $token, $value, $str);
}
return $str;
}