You are here

function taxonomy_manager_form_term_merge_submit in Taxonomy Manager 7

Submit handler for term merge

1 string reference to 'taxonomy_manager_form_term_merge_submit'
taxonomy_manager_term_merge_form in ./taxonomy_manager.admin.inc
Form for the Term merge module

File

./taxonomy_manager.admin.inc, line 1667

Code

function taxonomy_manager_form_term_merge_submit($form, $form_state) {
  $selected_tids = array();
  $selected_tids = $form_state['values']['taxonomy']['manager']['tree']['selected_terms'];
  $dest_term_ids = taxonomy_manager_autocomplete_tags_get_tids($form_state['values']['term_merge']['dest_term'], $form_state['values']['voc']->vid, TRUE);
  $dest_term_id = array_shift($dest_term_ids);
  $dest_term = taxonomy_term_load($dest_term_id['tid']);
  $term_names_array = array();
  foreach ($selected_tids as $selected_tid) {
    $term = taxonomy_term_load($selected_tid);
    $term_names_array[] = $term->name;
  }
  $term_names = implode(', ', $term_names_array);
  if (module_exists('term_merge')) {
    term_merge($selected_tids, $dest_term->tid, $form_state['values']['term_merge']['options']['keep_merged']);
    drupal_set_message(t("Terms %term_names merged into %dest_term", array(
      '%term_names' => $term_names,
      '%dest_term' => $dest_term->name,
    )));
  }
  else {
    drupal_set_message(t('Term merge module not found'));
  }
}