Index: autotagging.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autotagging/autotagging.admin.inc,v
retrieving revision 1.5
diff -u -p -r1.5 autotagging.admin.inc
--- autotagging.admin.inc	24 Jul 2009 17:31:16 -0000	1.5
+++ autotagging.admin.inc	27 Jul 2009 04:17:09 -0000
@@ -20,6 +20,20 @@ function autotagging_settings_form() {
     '#options' => $vocab_options,
     '#default_value' => variable_get('autotagging_global_vocabulary', '')
   );
+  
+  // Option to decide whether nodes are tagged on inserts, updates or both.
+  $actions = array(
+    'both' => 'Both inserts and updates',
+    'insert' => 'Only on node inserts',
+    'update' => 'Only on node updates',
+  );
+  $form['global_settings']['autotagging_action'] = array(
+    '#type' => 'select',
+    '#title' => t('Node Actions'),
+    '#description' => t('Decide whether tagging should happen on node inserts, updates or both (default).'),
+    '#options' => $actions,
+    '#default_value' => variable_get('autotagging_action', 'both'),
+  );
 
   $form['autotagging_settings'] = array(
     '#type' => 'fieldset',
Index: autotagging.inc
===================================================================
RCS file: autotagging.inc
diff -N autotagging.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ autotagging.inc	27 Jul 2009 04:17:09 -0000
@@ -0,0 +1,53 @@
+<?php
+/**
+ * @file
+ * Support functions for the AutoTagging module.
+ */
+
+/**
+ * Run the node through the autotagging provider modules.
+ */
+function autotagging_process_node(&$node) {
+  $terms = array();
+  // check that this node type is allowed for autotagging
+  //
+  $allowed_types = variable_get('autotagging_allowed_types', array());
+
+  if (!in_array($node->type, $allowed_types)) {
+    return NULL;
+  }
+
+  // invoke autotagging api
+  //
+  $text = array();
+  $text[] = $node->title;
+  $text[] = str_replace("\n", ' ', $node->body);
+  $text = implode(' ', $text);
+  $ignore_setting = variable_get('autotagging_error_handling', 'Defer');
+  foreach (module_implements('autotagging_api_' . $op) as $module_name) {
+    $terms = module_invoke($module_name, 'autotagging_api_'. $op, $node, $text);
+    if ($terms === FALSE) {
+      // error occurred processing this node for this service
+      if ($ignore_setting == 'Defer') {
+        // TODO: handle defer logic
+        //
+        break;
+      }
+    }
+    if (isset($terms) && is_array($terms) && !empty($terms)) {
+      // find the vocabulary with which to associate these terms
+      //
+      foreach ($terms as $vid => $termlist) {
+        if (empty($node->taxonomy['tags'][$vid])) {
+          $node->taxonomy['tags'][$vid] = implode(', ', $termlist);
+        } 
+        else {
+          $node->taxonomy['tags'][$vid] .= ', '. implode(', ', $termlist);
+        }
+      }
+    }
+  }
+  // allows modules to act on terms before they're saved.
+  module_invoke_all('autotagging_api_presave', $node, $terms);
+  taxonomy_node_save($node, $node->taxonomy);
+}
Index: autotagging.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autotagging/autotagging.module,v
retrieving revision 1.7
diff -u -p -r1.7 autotagging.module
--- autotagging.module	24 Jul 2009 17:38:20 -0000	1.7
+++ autotagging.module	27 Jul 2009 04:17:09 -0000
@@ -31,52 +31,17 @@ function autotagging_perm() {
 
 function autotagging_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
   // act on the node
-  //
   switch ($op) {
     case 'update':
     case 'insert':
-      $terms = array();
-      // check that this node type is allowed for autotagging
-      //
-      $allowed_types = variable_get('autotagging_allowed_types', array());
-
-      if (!in_array($node->type, $allowed_types)) {
-        return NULL;
-      }
-
-      // invoke autotagging api
-      //
-      $text = array();
-      $text[] = $node->title;
-      $text[] = str_replace("\n", ' ', $node->body);
-      $text = implode(' ', $text);
-      $ignore_setting = variable_get('autotagging_error_handling', 'Defer');
-      foreach (module_implements('autotagging_api_' . $op) as $module_name) {
-        $terms = module_invoke($module_name, 'autotagging_api_'. $op, $node, $text);
-        if ($terms === FALSE) {
-          // error occurred processing this node for this service
-          if ($ignore_setting == 'Defer') {
-            // TODO: handle defer logic
-            //
-            break;
-          }
-        }
-        if (isset($terms) && is_array($terms) && !empty($terms)) {
-          // find the vocabulary with which to associate these terms
-          //
-          foreach ($terms as $vid => $termlist) {
-            if (empty($node->taxonomy['tags'][$vid])) {
-              $node->taxonomy['tags'][$vid] = implode(', ', $termlist);
-            } 
-            else {
-              $node->taxonomy['tags'][$vid] .= ', '. implode(', ', $termlist);
-            }
-          }
-        }
+      // Load the module helpers.
+      module_load_include('inc', 'autotagging');
+      // Work out which node action to work on.
+      $action = variable_get('autotagging_action', 'both');
+      // Only tag the node if the action was requested.
+      if ($action == 'both' || $action == $op) {
+        autotagging_process_node($node);
       }
-      // allows modules to act on terms before they're saved.
-      module_invoke_all('autotagging_api_presave', $node, $terms);
-      taxonomy_node_save($node, $node->taxonomy);
       break;
   }
 }
