You are here

function taxonomy_manager_move in Taxonomy Manager 5

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.admin.inc \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)

1 call to taxonomy_manager_move()
taxonomy_manager_form_submit in ./taxonomy_manager.module
submits the taxonomy manager form

File

./taxonomy_manager.module, line 1201
Taxonomy Manager

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("INSERT INTO {term_hierarchy} (parent, tid) VALUES (%d, %d)", $parent, $child);
    }
  }
}