function taxonomy_manager_double_tree_move_submit in Taxonomy Manager 7
1 string reference to 'taxonomy_manager_double_tree_move_submit'
File
- ./
taxonomy_manager.admin.inc, line 2104
Code
function taxonomy_manager_double_tree_move_submit($form, &$form_state) {
$selected_terms = $form_state['values']['double_tree_values']['selected_terms'];
$selected_parents = $form_state['values']['double_tree_values']['selected_parents'];
$selected_terms_direct_parents = $form_state['values']['double_tree_values']['selected_terms_direct_parents'];
$selected_terms_names = array();
foreach ($selected_terms as $tid) {
$selected_term = taxonomy_term_load($tid);
$selected_terms_names[] = $selected_term->name;
//reset all parents, except the direct parent in the tree
$term_parents = taxonomy_get_parents($tid);
$term_parents_array = array();
$direct_parent = isset($selected_terms_direct_parents[$tid]) ? $selected_terms_direct_parents[$tid] : 0;
foreach ($term_parents as $term_parent) {
if ($direct_parent != $term_parent->tid) {
$term_parents_array[$term_parent->tid] = $term_parent->tid;
}
}
$selected_parent_names = array();
if (count($selected_parents)) {
foreach ($selected_parents as $parent) {
$term = taxonomy_term_load($parent);
$selected_parent_names[] = $term->name;
$term_parents_array[$term->tid] = $term->tid;
}
}
if (count($term_parents_array) == 0) {
$term_parents_array[0] = 0;
}
taxonomy_manager_move($term_parents_array, array(
$tid,
), array(
'keep_old_parents' => FALSE,
));
taxonomy_manager_update_voc($form_state['values']['voc']->vid, $term_parents_array);
}
$term_names = implode(', ', $selected_terms_names);
if (count($selected_parents) == 0) {
drupal_set_message(t("Removed current parent form terms %terms.", array(
'%terms' => $term_names,
)));
}
else {
drupal_set_message(t("Terms %terms moved to parents %parents.", array(
'%terms' => $term_names,
'%parents' => implode(', ', $selected_parent_names),
)));
}
$form_state['rebuild'] = TRUE;
}