diff --git a/taxonomy_manager.admin.inc b/taxonomy_manager.admin.inc index d768cc9..30ca36c 100644 --- a/taxonomy_manager.admin.inc +++ b/taxonomy_manager.admin.inc @@ -1752,16 +1752,17 @@ function taxonomy_manager_term_data_form_submit_parents_add($form, &$form_state) $term->parent = array(); } + // get the current parents first + $current_parents = taxonomy_get_parents($term->tid); + foreach ($current_parents as $key => $value) { + $term->parent[] = $key; + } + + // add on the new parent foreach ($typed_terms as $parent_info) { $term->parent[] = $parent_info['tid']; } - //remove root level entry - db_delete('taxonomy_term_hierarchy') - ->condition('tid', $term->tid) - ->condition('parent', 0) - ->execute(); - taxonomy_term_save($term); //executes hooks and clears caches taxonomy_manager_update_voc($term->vid, taxonomy_get_parents($term->tid)); // update hierarchy settings, if necessary drupal_set_message(t('Updated hierarchy')); @@ -1793,13 +1794,16 @@ function taxonomy_manager_term_data_form_submit_parents_remove($form, &$form_sta $term->parent = array(); } - // Ensure that a term has a least parent 0. - if (count($parents) == 1) { + if (count($parents) <= 1) { + // ensure that a term has a least parent 0 $term->parent[] = 0; + } else { + unset($parents[$parent]); + foreach($parents as $key => $value) { + $term->parent[] = $key; + } } - $term->parent = array_diff($term->parent, array($parent)); - taxonomy_term_save($term); //executes hooks and clears caches drupal_set_message(t("Removed parent")); $form_state['rebuild'] = TRUE; @@ -2575,7 +2579,7 @@ function taxonomy_manager_export_csv($tree, $delimiter = ";") { $array[] = '"' . $term->tid . '"'; $array[] = '"' . $term->name . '"'; $array[] = '"' . $term->description . '"'; - foreach ($term->parents as $parent) { + foreach ($term->parent as $parent) { $array[] = '"' . $parent . '"'; } $output .= implode($delimiter, $array) . "\n";