--- auto_nodetitle.module	2009-02-10 11:31:34.000000000 +0100
+++ auto_nodetitle_new.module	2009-03-16 20:38:19.634000000 +0100
@@ -9,6 +9,7 @@
 define('AUTO_NODETITLE_DISABLED', 0);
 define('AUTO_NODETITLE_ENABLED', 1);
 define('AUTO_NODETITLE_OPTIONAL', 2);
+define('AUTO_NODETITLE_ENABLED_PRESERVE', 3);
 
 /**
  * Implementation of hook_perm()
@@ -27,15 +28,31 @@ function auto_nodetitle_form_alter($form
   }
   else if (isset($form['#node']) && isset($form['#post']) && $form['#node']->type .'_node_form' == $form_id) {
     //this is a node form
-    if (auto_nodetitle_get_setting($form['#node']->type) == AUTO_NODETITLE_ENABLED) {
-      // we will autogenerate the title later, just hide the title field in the meanwhile
-      $form['title']['#value'] = 'ant';
-      $form['title']['#type'] = 'value';
-      $form['title']['#required'] = FALSE;
-    }
-    else if (auto_nodetitle_get_setting($form['#node']->type) == AUTO_NODETITLE_OPTIONAL) {
-      // we will make the title optional
-      $form['title']['#required'] = FALSE;
+    $ant_mode = auto_nodetitle_get_setting($form['#node']->type);
+    $form['title']['#required'] = FALSE;
+    switch ($ant_mode) {
+      case AUTO_NODETITLE_ENABLED:
+        // we will autogenerate the title later, just disable the title field in the meanwhile
+        $form['title']['#value'] = 'ant';
+        $form['title']['#disabled'] = TRUE;
+        $form['title']['#description'] = t('Title for this node will be set automatically bij ANT module');
+        break;
+     case AUTO_NODETITLE_OPTIONAL:
+        // we will make the title optional
+        $form['title']['#description'] = t("If you don't enter a title it will be generated automatically");
+        break;
+     case AUTO_NODETITLE_ENABLED_PRESERVE:
+       if (empty($form['title']['#default_value'])) {
+         $form['title']['#value'] = 'ant';
+       } 
+       else {
+         $form['title']['#value'] = $form['title']['#default_value'];
+       }
+       $form['title']['#disabled'] = TRUE;
+       $form['title']['#description'] = t('Title for this node will be set automatically bij ANT module, however once created it will be preserved and not changed on update');
+       break;
+    default:
+      break;
     }
   }
 }
@@ -61,7 +78,7 @@ function auto_nodetitle_nodeapi(&$node, 
  * Returns whether the auto nodetitle has to be set.
  */
 function auto_nodetitle_is_needed($node) {
-  return empty($node->auto_nodetitle_applied) && ($setting = auto_nodetitle_get_setting($node->type)) && !($setting == AUTO_NODETITLE_OPTIONAL && !empty($node->title));
+  return empty($node->auto_nodetitle_applied) && ($setting = auto_nodetitle_get_setting($node->type)) && !($setting == AUTO_NODETITLE_OPTIONAL && !empty($node->title))&& !($setting == AUTO_NODETITLE_ENABLED_PRESERVE && !empty($node-> title));
 }
 
 /*
@@ -152,6 +169,7 @@ function auto_nodetitle_node_settings_fo
       t('Disabled'),
       t('Automatically generate the title and hide the title field'),
       t('Automatically generate the title if the title field is left empty'),
+			t('Always automatically generate the title but preserve the first generated title on update'),
     )
   );
 
