You are here

function taxonomy_manager_form_move_submit in Taxonomy Manager 6.2

Same name and namespace in other branches
  1. 6 taxonomy_manager.admin.inc \taxonomy_manager_form_move_submit()
  2. 7 taxonomy_manager.admin.inc \taxonomy_manager_form_move_submit()

Submit handler for moving terms

1 string reference to 'taxonomy_manager_form_move_submit'
taxonomy_manager_move_form in ./taxonomy_manager.admin.inc
form for moving terms in hierarchies

File

./taxonomy_manager.admin.inc, line 1384
Taxonomy Manager Admin

Code

function taxonomy_manager_form_move_submit($form, $form_state) {
  $selected_tids = array();
  $selected_tids = $form_state['values']['taxonomy']['manager']['tree']['selected_terms'];
  $typed_parents = taxonomy_manager_autocomplete_tags_get_tids($form_state['values']['move']['parents'], $form_state['values']['vid'], TRUE, $form_state['values']['taxonomy']['manager']['top']['language']);
  $parents = array();
  foreach ($typed_parents as $parent_info) {
    $parents[] = $parent_info['tid'];
  }
  if (count($parents) == 0) {
    $parents[0] = 0;
  }

  //if empty, delete all parents
  taxonomy_manager_move($parents, $selected_tids, $form_state['values']['move']['options']);
  if ($form_state['values']['move']['options']['keep_old_parents']) {
    $parents[] = 1;

    //++ parent count for hierarchy update (-> multi hierarchy)
  }
  taxonomy_manager_update_voc($form_state['values']['vid'], $parents);
  $term_names_array = array();
  foreach ($selected_tids as $selected_tid) {
    $term = taxonomy_get_term($selected_tid);
    $term_names_array[] = $term->name;
  }
  $term_names = implode(', ', $term_names_array);
  $parent_names = "";
  if (count($typed_parents) == 0) {
    $parent_names = t("root level");
  }
  else {
    $parent_names = $form_state['values']['move']['parents'];
  }
  drupal_set_message(t("Terms %term_names moved to %parent_names", array(
    '%term_names' => $term_names,
    '%parent_names' => $parent_names,
  )));
}