Index: rules/modules/taxonomy.rules.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/rules/rules/modules/Attic/taxonomy.rules.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 taxonomy.rules.inc --- rules/modules/taxonomy.rules.inc 19 Apr 2009 18:19:06 -0000 1.1.2.5 +++ rules/modules/taxonomy.rules.inc 15 May 2009 14:00:52 -0000 @@ -73,6 +73,35 @@ function taxonomy_rules_action_info() { '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_add_term'] = array( + 'label' => t('Add a new term to vocabulary'), + 'arguments' => array( + 'taxonomy_vocab' => array( + 'type' => 'taxonomy_vocab', + 'label' => t('Taxonomy vocabulary'), + ), + ), + 'new variables' => array( + 'taxonomy_term' => array( + 'type' => 'taxonomy_term', + 'label' => t('Taxonomy term'), + ), + ), + 'eval input' => array('name', 'description'), + 'module' => 'Taxonomy', + ); + + $info['rules_action_taxonomy_delete_term'] = array( + 'label' => t('Delete a term'), + 'arguments' => array( + 'taxonomy_term' => array( + 'type' => 'taxonomy_term', + 'label' => t('Taxonomy term'), + ), + ), + 'module' => 'Taxonomy', + ); + $info['rules_action_taxonomy_term_assign_to_content'] = array( 'label' => t('Assign a term to content'), 'arguments' => array( @@ -137,6 +166,27 @@ function rules_action_taxonomy_load_term } /** + * Action: Add a new term to vocabulary. + */ +function rules_action_taxonomy_add_term($taxonomy_vocab, $settings) { + // Prepare the values to pass to taxonomy_save_term(); + $settings['vid'] = $taxonomy_vocab->vid; + $form_state = $settings; + taxonomy_save_term($form_state); + // Get the newly created term. + $term = taxonomy_get_term($form_state['tid']); + return array('taxonomy_term' => $term); +} + +/** + * Action: Delete a term. + */ +function rules_action_taxonomy_delete_term($taxonomy_term) { + taxonomy_del_term($taxonomy_term->tid); + return array('taxonomy_term' => $taxonomy_term); +} + +/** * Action: Assign or remove a term to content. */ function rules_action_taxonomy_term_assign_to_content($node, $taxonomy_term, $settings) { Index: rules/modules/taxonomy.rules_forms.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/rules/rules/modules/Attic/taxonomy.rules_forms.inc,v retrieving revision 1.1.2.6 diff -u -p -r1.1.2.6 taxonomy.rules_forms.inc --- rules/modules/taxonomy.rules_forms.inc 19 Apr 2009 18:19:06 -0000 1.1.2.6 +++ rules/modules/taxonomy.rules_forms.inc 15 May 2009 14:00:52 -0000 @@ -74,6 +74,37 @@ function rules_taxonomy_form($vid, $valu } /** + * Action: Add a new term to vocabulary configuration form. + * + * As we allow adding terms to vocabularies that are created on the fly, we + * can't present the term's advanced settings. + */ +function rules_action_taxonomy_add_term_form($settings, &$form, $form_state) { + // Fields definition taken from taxonomy_form_term(). + $form['settings']['term'] = array( + '#type' => 'fieldset', + '#title' => t('Term Identification'), + '#collapsible' => TRUE, + '#tree' => FALSE, + ); + $form['settings']['term']['name'] = array( + '#type' => 'textfield', + '#title' => t('Term name'), + '#default_value' => !empty($settings['name']) ? $settings['name'] : '', + '#maxlength' => 255, + '#description' => t('The name of this term.'), + '#required' => TRUE, + ); + + $form['settings']['term']['description'] = array( + '#type' => 'textarea', + '#title' => t('Description'), + '#default_value' => !empty($settings['description']) ? $settings['description'] : '', + '#description' => t('A description of the term. To be displayed on taxonomy/term pages and RSS feeds.'), + ); +} + +/** * Action: Load a vocabulary configuration form. */ function rules_action_taxonomy_load_vocab_form($settings, &$form, $form_state) {