? LICENSE.txt
Index: content_levels.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_levels/content_levels.info,v
retrieving revision 1.2
diff -u -p -r1.2 content_levels.info
--- content_levels.info	17 Sep 2009 15:19:54 -0000	1.2
+++ content_levels.info	23 Nov 2009 15:15:49 -0000
@@ -5,3 +5,10 @@ package = CCK
 core = 6.x
 dependencies[] = content
 dependencies[] = date_api
+
+; Information added by drupal.org packaging script on 2009-10-08
+version = "6.x-1.0-rc1"
+core = "6.x"
+project = "content_levels"
+datestamp = "1255023033"
+
Index: content_levels.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_levels/content_levels.install,v
retrieving revision 1.2
diff -u -p -r1.2 content_levels.install
--- content_levels.install	17 Sep 2009 15:52:18 -0000	1.2
+++ content_levels.install	23 Nov 2009 15:15:49 -0000
@@ -39,3 +39,74 @@ function content_levels_disable() {
   drupal_load('module', 'content');
   content_notify('disable', 'content_levels');
 }
+
+/**
+ * Implementation of hook_update().
+ */
+function content_levels_update_6101() {
+  $all_fields = content_fields();
+  
+  // Check through all fields for content_level fields.
+  foreach ($all_fields as $name => $field) {
+    if ($field['type'] == 'content_levels') {
+
+      // Increment level IDs in series.
+      foreach ($field['content_series'] as $key => $level) {
+        $field['content_series'][$key]['id']++;
+      }
+      
+      // Increment default level ID.
+      $field['default_level']++;
+      
+      // Update level IDs.
+      $query = "UPDATE {content_node_field} SET global_settings='%s' WHERE field_name='%s'";
+      $settings = serialize(array('content_series' => $field['content_series'], 'default_level' => $field['default_level']));
+      db_query($query, $settings, $name);
+      
+      // Get field visibility settings for the node type that this field is on.
+      $query = "SELECT type_name, widget_settings FROM {content_node_field_instance} WHERE field_name = '%s'";
+      $result = db_query($query, $name);
+      
+      while ($row = db_fetch_object($result)) {
+        $serialised = $row->widget_settings;
+        $widget_settings = unserialize($serialised);
+        
+        // Update level IDs in field visibility settings.
+        if (isset($widget_settings['visibility']) && !is_null($widget_settings['visibility'])) {
+          foreach ($widget_settings['visibility'] as $type_fieldname => $type_field) {
+            $widget_settings['visibility']['type_fieldname'] = _content_levels_update_visibility($type_field);
+          }
+          $widget_settings = serialize($widget_settings);
+          $query = "UPDATE {content_node_field_instance} SET widget_settings = '%s' WHERE field_name = '%s' AND type_name = '%s'";
+          db_query($query, $widget_settings, $name, $row->type_name);
+        }
+      }
+      
+      // Update level IDs of nodes.
+      $db_info = content_database_info($field);
+      $query = "UPDATE {" . $db_info['table'] . "} " .
+               "SET " . $db_info['columns']['value']['column'] . " = " . $db_info['columns']['value']['column'] . " + 1";
+      db_query($query);
+    }
+  }
+  
+  return array();
+}
+
+/**
+ * Increment content level IDs in a widget's field visibility settings array.
+ */
+function _content_levels_update_visibility($settings) {
+  $updated = array();
+  
+  foreach ($settings as $key => $value) {
+    if (!is_numeric($key)) {
+      $updated[$key] = $value;
+    }
+    else {
+      $updated[$key+1] = $value;
+    }
+  }
+  
+  return $updated;
+}
\ No newline at end of file
Index: content_levels_cck.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_levels/content_levels_cck.inc,v
retrieving revision 1.4
diff -u -p -r1.4 content_levels_cck.inc
--- content_levels_cck.inc	25 Sep 2009 15:15:23 -0000	1.4
+++ content_levels_cck.inc	23 Nov 2009 15:15:50 -0000
@@ -45,7 +45,7 @@ function content_levels_field_settings($
 
       // Add the list of currently defined content levels
       $max_weight;
-      $max_id = -1;
+      $max_id = 0;
       foreach ($content_series as $level_id => $level) {
 
         // We want to exit this loop knowing what the maximum weight & id is
@@ -65,6 +65,7 @@ function content_levels_field_settings($
 
         $is_default_options[$level['id']] = '';
       }
+      
       // Add an extra empty fields for new levels
       $new_id = $max_id + 1;
       $new_weight = $max_weight + 1;
