function term_merge_duplicates_form_submit in Term Merge 7
Submit handler for 'term_merge_duplicates_form'.
Actually merge duplicate terms.
File
- ./
term_merge.pages.inc, line 626 - Menu page callbacks for Term Merge module.
Code
function term_merge_duplicates_form_submit($form, &$form_state) {
$batch = array(
'title' => t('Merging terms'),
'operations' => array(),
'finished' => 'term_merge_batch_finished',
'file' => drupal_get_path('module', 'term_merge') . '/term_merge.batch.inc',
);
// Processing general options for merging.
$merge_settings = term_merge_merge_options_submit($form, $form_state, $form);
if (isset($form_state['values']['group'])) {
foreach ($form_state['values']['group'] as $values) {
// Filtering out only the selected duplicate terms.
$term_branches = array_filter($values['duplicates']);
// We also do not want to have trunk term to be among the branch terms.
unset($term_branches[$values['trunk_tid']]);
if (!empty($term_branches)) {
// If something has been selected in this group we schedule its merging.
$batch['operations'][] = array(
'_term_merge_batch_process',
array(
$term_branches,
$values['trunk_tid'],
$merge_settings,
),
);
}
}
}
if (empty($batch['operations'])) {
drupal_set_message(t('No merging has been made, because you have not selected any duplicate term to merge.'));
}
else {
batch_set($batch);
}
}