You are here

function taxonomy_manager_move in Taxonomy Manager 6.2

Same name and namespace in other branches
  1. 5 taxonomy_manager.module \taxonomy_manager_move()
  2. 6 taxonomy_manager.admin.inc \taxonomy_manager_move()
  3. 7 taxonomy_manager.admin.inc \taxonomy_manager_move()

moves terms in hierarchies to other parents

Parameters

$parents: array of parent term ids to where children can be moved array should only contain more parents if multi hiearchy enabled if array contains 0, terms get placed to first (root) level

$children: array of term ids to move

$options: array of additional options for moving 'keep_old_parents': if true, exisiting parents doesn't get deleted (only possible with multi hierarchies)

3 calls to taxonomy_manager_move()
taxonomy_manager_double_tree_edit_move in ./taxonomy_manager.admin.inc
taxonomy_manager_form_move_submit in ./taxonomy_manager.admin.inc
Submit handler for moving terms
taxonomy_manager_switch in ./taxonomy_manager.admin.inc
Changes vocabulary of given terms and its children conflicts might be possible with multi-parent terms!

File

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

Code

function taxonomy_manager_move($parents, $children, $options = array()) {
  if (!is_array($parents)) {
    array(
      $parents,
    );
  }
  foreach ($children as $child) {
    if (!$options['keep_old_parents']) {
      db_query("DELETE FROM {term_hierarchy} WHERE tid = %d", $child);
    }
    foreach ($parents as $parent) {
      db_query("DELETE FROM {term_hierarchy} WHERE parent = %d AND tid = %d", $parent, $child);

      //prevent duplicated sql errors
      db_query("INSERT INTO {term_hierarchy} (parent, tid) VALUES (%d, %d)", $parent, $child);
    }
  }
}