--- rules.orig/rules/modules/taxonomy.rules.inc 2009-05-28 03:51:35.000000000 -0700 +++ rules/rules/modules/taxonomy.rules.inc 2009-06-13 23:29:04.000000000 -0700 @@ -74,6 +74,21 @@ 'help' => t('Loading a taxonomy term will allow you to act on this term, for example you will be able to assign this term to a content.'), '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( @@ -138,6 +153,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) {