function taxonomy_manager_move in Taxonomy Manager 6
Same name and namespace in other branches
- 5 taxonomy_manager.module \taxonomy_manager_move()
- 6.2 taxonomy_manager.admin.inc \taxonomy_manager_move()
- 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_move_submit in ./
taxonomy_manager.admin.inc - Submit handler for moving terms
File
- ./
taxonomy_manager.admin.inc, line 1167
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);
}
}
}