function crm_core_default_matching_engine_form in CRM Core 7
Creates a form for customizing the matching rules per contact type.
1 string reference to 'crm_core_default_matching_engine_form'
- crm_core_default_matching_engine_menu in modules/
crm_core_default_matching_engine/ crm_core_default_matching_engine.module - Implements hook_menu().
File
- modules/
crm_core_default_matching_engine/ crm_core_default_matching_engine.admin.inc, line 11 - Administrative screens.
Code
function crm_core_default_matching_engine_form($form, &$form_state, $contact_type) {
$config = crm_core_default_matching_engine_load_contact_type_config($contact_type);
$form['contact_type'] = array(
'#type' => 'value',
'#value' => $contact_type,
);
$form['status'] = array(
'#type' => 'checkbox',
'#title' => t('Enable matching for this contact type'),
'#description' => t('Check this box to allow CRM Core to check for duplicate contact records for this contact type.'),
'#default_value' => $config['status'],
);
$form['threshold'] = array(
'#type' => 'textfield',
'#title' => t('Threshold'),
'#description' => t('Defines the score at which a contact is considered a match.'),
'#maxlength' => 28,
'#size' => 28,
'#required' => TRUE,
'#default_value' => $config['threshold'],
);
$return_description = 'If two or more contact records result in matches with identical scores, CRM Core will give' . ' preference to one over the other base on selected option.';
$form['return_order'] = array(
'#type' => 'select',
'#title' => t('Return Order'),
'#description' => t($return_description),
'#default_value' => $config['return_order'],
'#options' => array(
'created' => t('Most recently created'),
'updated' => t('Most recently updated'),
'associated' => t('Associated with user'),
),
);
$strict_description = 'Check this box to return a match for this contact type the first time one is identified that' . ' meets the threshold. Stops redundant processing.';
$form['strict'] = array(
'#type' => 'checkbox',
'#title' => t('Strict matching'),
'#description' => t($strict_description),
'#default_value' => $config['strict'],
);
$form['fields'] = array(
'#type' => 'item',
'#title' => t('Field Matching'),
);
$form['field_matching'] = array(
'#type' => 'container',
'#tree' => TRUE,
);
foreach (field_info_instances('crm_core_contact', $contact_type) as $field_name => $field) {
$field_info = field_info_field($field_name);
$field_type = $field_info['type'];
$field_handler = $field_type . 'MatchField';
if (class_exists($field_handler)) {
$obj = new $field_handler();
$obj
->fieldRender($field, $field_info, $form);
}
else {
$obj = new UnsupportedFieldMatchField();
$obj
->fieldRender($field, $field_info, $form);
}
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}