--- rules/modules/taxonomy.rules.inc.orig 2011-01-22 21:33:18.004468246 -0800 +++ rules/modules/taxonomy.rules.inc 2011-01-22 21:33:57.525093691 -0800 @@ -103,6 +103,22 @@ 'module' => 'Taxonomy', ); + $info['rules_action_taxonomy_assign_parent_term'] = array( + 'label' => t('Assign a parent term to a term'), + 'arguments' => array( + 'taxonomy_term_parent' => array( + 'type' => 'taxonomy_term', + 'label' => t('Parent term'), + ), + 'taxonomy_term_child' => array( + 'type' => 'taxonomy_term', + 'label' => t('Child term'), + ), + ), + 'help' => t('Use two terms and make one the parent of the other. The terms must be previously loaded or added.'), + 'module' => 'Taxonomy', + ); + $info['rules_action_taxonomy_term_assign_to_content'] = array( 'label' => t('Assign a term to content'), 'arguments' => array( @@ -188,6 +204,17 @@ } /** + * Action: Assign a term as the parent of another term. + */ +function rules_action_taxonomy_assign_parent_term($taxonomy_term_parent, $taxonomy_term_child, $settings) { + $sql = "DELETE FROM {term_hierarchy} WHERE tid = %d AND parent = 0"; + db_query($sql, $taxonomy_term_child->tid); + $sql = "INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)"; + db_query($sql, $taxonomy_term_child->tid, $taxonomy_term_parent->tid); + return array('taxonomy_term_child' => $taxonomy_term_child); +} + +/** * Action: Assign or remove a term to content. */ function rules_action_taxonomy_term_assign_to_content($node, $taxonomy_term, $settings) {