function _profile2_usermerge_build_review_form_elements_by_bundle in User Merge 7.2
Pass in review elements per bundle.
Parameters
array $properties: Entity properties.
object $user_to_delete: User entity to delete.
object $user_to_keep: User entity to keep.
Return value
array The form array to render.
1 call to _profile2_usermerge_build_review_form_elements_by_bundle()
- profile2_usermerge_build_review_form_elements in includes/
profile2.usermerge.inc - Implements hook_usermerge_build_review_form_elements().
File
- includes/
profile2.usermerge.inc, line 80 - Adds support for Profile 2. Supplemental include loaded via usermerge_load_includes().
Code
function _profile2_usermerge_build_review_form_elements_by_bundle($properties, $user_to_delete, $user_to_keep) {
$review = array();
// Set up profile tree..
$review = array(
'#tree' => TRUE,
'#theme' => 'usermerge_data_review_form_table',
'#title' => $properties['title'],
'#weight' => -10,
);
// Load the profile for the user to delete and keep.
$profile_delete = profile2_load_by_user($user_to_delete, $properties['type']);
$profile_keep = profile2_load_by_user($user_to_keep, $properties['type']);
// Do nothing if both of the profiles don't exist.
if (empty($profile_delete) && empty($profile_keep)) {
$review['no_info']['property_name'] = array(
'#type' => 'markup',
'#markup' => t('Profile'),
);
$review['no_info']['options']['user_to_delete'] = array(
'#type' => 'markup',
'#markup' => t('No Profiles Found - profile information will not be imported'),
);
return $review;
}
foreach ($properties['items'] as $name => $info) {
$review[$name]['property_name'] = array(
'#type' => 'markup',
'#markup' => $info['label'],
);
// Init the values we will be displaying.
$values = array(
'delete' => _profile2_usermerge_process_field($profile_delete, $name),
'keep' => _profile2_usermerge_process_field($profile_keep, $name),
);
$review[$name]['options'] = array(
'#type' => 'radios',
'#options' => array(
'user_to_delete' => implode('<br />', $values['delete']),
'user_to_keep' => implode('<br />', $values['keep']),
'merge' => $info['cardinality'] != 1 && $values['delete'] != $values['keep'] ? 'merge' : 'no_merge',
),
'#default_value' => 'user_to_keep',
);
$review[$name]['cardinality'] = array(
'#type' => 'hidden',
'#value' => $info['cardinality'],
);
if (isset($info['criterion'])) {
unset($review[$name]['options']['#options']);
$review[$name]['options']['#options']['merge'] = 'merge';
$review[$name]['options']['#default_value'] = 'merge';
}
}
return $review;
}