Index: content.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.install,v
retrieving revision 1.14.2.2
diff -u -r1.14.2.2 content.install
--- content.install	5 Dec 2006 22:30:33 -0000	1.14.2.2
+++ content.install	1 Jan 2007 20:37:36 -0000
@@ -12,7 +12,7 @@
   switch ($GLOBALS['db_type']) {
     case 'mysql':
     case 'mysqli':
-      db_query("CREATE TABLE {node_field} (
+      db_query("CREATE TABLE {content_fields} (
         field_name varchar(32) NOT NULL default '',
         type varchar(127) NOT NULL default '',
         global_settings mediumtext NOT NULL,
@@ -21,7 +21,7 @@
         db_storage int NOT NULL default '0',
         PRIMARY KEY  (field_name)
       ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      db_query("CREATE TABLE {node_field_instance} (
+      db_query("CREATE TABLE {content_fields_instances} (
         field_name varchar(32) NOT NULL default '',
         type_name varchar(32) NOT NULL default '',
         weight int NOT NULL default '0',
@@ -34,7 +34,7 @@
       break;
 
     case 'pgsql':
-      db_query("CREATE TABLE {node_field} (
+      db_query("CREATE TABLE {content_fields} (
         field_name varchar(32) NOT NULL default '',
         type varchar(127) NOT NULL default '',
         global_settings text NOT NULL,
@@ -43,7 +43,7 @@
         db_storage integer NOT NULL default '0',
         PRIMARY KEY  (field_name)
       )");
-      db_query("CREATE TABLE {node_field_instance} (
+      db_query("CREATE TABLE {content_fields_instances} (
         field_name varchar(32) NOT NULL default '',
         type_name varchar(32) NOT NULL default '',
         weight integer NOT NULL default '0',
@@ -307,4 +307,75 @@
   }
 
   return $ret;
-}
\ No newline at end of file
+}
+
+/**
+ *  Rename data tables to avoid collision with core node_* tables
+ */
+function content_update_1002() {
+  $ret = array();
+
+  // We check the update has not already been done in 4.7 migration path
+  if (!db_table_exists('content_fields')) {
+    include_once('./'. drupal_get_path('module', 'content') .'/content.module');
+    include_once('./'. drupal_get_path('module', 'content') .'/content_admin.inc');
+
+    $rename = array();
+
+    $types = content_types();
+    $fields = content_fields();
+
+    // "per content type" tables
+    foreach ($types as $type) {
+      $old_name = 'node_'.$type['type'];
+      $new_name = _content_tablename($type['type']);
+      if (db_table_exists($old_name)) {
+        if (!in_array($old_name, array('node_access',  'node_comments_statistics', 'node_counter', 'node_field', 'node_field_instance', 'node_group', 'node_group_fields', 'node_revisions', 'node_type'))) {
+          $rename[$old_name] = $new_name;
+        }
+        else {
+          // TODO : what ? create the table ?
+        }
+      }
+    }
+
+    // "per field" tables
+    foreach ($fields as $field) {
+      $old_name = 'node_data_'.$field['field_name'];
+      $new_name = _content_tablename($field['field_name'], 'field');
+      if (db_table_exists($old_name)) {
+        $rename[$old_name] = $new_name;
+      }
+    }
+
+    // general tables
+    $rename['node_field'] = 'content_fields';
+    $rename['node_field_instance'] = 'content_fields_instances';
+
+    // rename
+    foreach ($rename as $old_name => $new_name) {
+      switch ($GLOBALS['db_type']) {
+        case 'mysql':
+        case 'mysqli':
+          $ret[] = update_sql("RENAME TABLE {$old_name} TO {$new_name}");
+          break;
+
+        case 'pgsql':
+          $ret[] = update_sql("ALTER TABLE {$old_name} RENAME TO {$new_name}");
+          break;
+      }
+    }
+
+
+    // regenerate views
+    content_clear_type_cache();
+    if (module_exists('views')) {
+      include_once('./'. drupal_get_path('module', 'content') .'/content_views.inc');
+      _content_views_rebuild_views(array_keys(content_fields()));
+    }
+
+
+  }
+
+  return $ret;
+}
Index: content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v
retrieving revision 1.90.2.13
diff -u -r1.90.2.13 content.module
--- content.module	1 Jan 2007 19:55:18 -0000	1.90.2.13
+++ content.module	1 Jan 2007 20:38:37 -0000
@@ -702,12 +702,12 @@
         }
       }
 
-      $field_result = db_query('SELECT * FROM {node_field} nf');
+      $field_result = db_query('SELECT * FROM {content_fields} nf');
       while ($field = db_fetch_array($field_result)) {
         $global_settings = $field['global_settings'] ? unserialize($field['global_settings']) : array();
         unset($field['global_settings']);
         $field = array_merge($field, $global_settings);
-        $instance_info = db_fetch_array(db_query("SELECT type_name, label FROM {node_field_instance} WHERE field_name = '%s'", $field['field_name']));
+        $instance_info = db_fetch_array(db_query("SELECT type_name, label FROM {content_fields_instances} WHERE field_name = '%s'", $field['field_name']));
         $field['widget']['label'] = $instance_info['label'];
         $field['type_name'] = $instance_info['type_name'];
         $info['fields'][$field['field_name']] = $field;
@@ -718,7 +718,7 @@
         $type['url_str'] = str_replace('_', '-', $type['type']);
         $type['fields'] = array();
         $type['table'] = _content_tablename($type['type']);
-        $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description FROM {node_field_instance} nfi WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type['type']);
+        $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description FROM {content_fields_instances} nfi WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type['type']);
         while ($field = db_fetch_array($field_result)) {
           // Overwrite global field information with specific information
           $field = array_merge($info['fields'][$field['field_name']], $field);
@@ -931,8 +931,8 @@
 function _content_tablename($name, $entity = 'type') {
   switch ($entity) {
     case 'type' :
-      return 'node_'.$name;
+      return 'content_type_'.$name;
     case 'field' :
-      return 'node_data_'.$name;
+      return 'content_'.$name;
   }
 }
Index: content_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_admin.inc,v
retrieving revision 1.28.2.8
diff -u -r1.28.2.8 content_admin.inc
--- content_admin.inc	30 Dec 2006 21:40:10 -0000	1.28.2.8
+++ content_admin.inc	1 Jan 2007 20:40:38 -0000
@@ -20,7 +20,7 @@
     $row[] = $field['type'];
 
     $types = array();
-    $result = db_query("SELECT nt.name, nt.type FROM {node_field_instance} nfi LEFT JOIN {node_type} nt ON nt.type = nfi.type_name WHERE nfi.field_name = '%s' ORDER BY nt.name ASC", $field['field_name']);
+    $result = db_query("SELECT nt.name, nt.type FROM {content_fields_instances} nfi LEFT JOIN {node_type} nt ON nt.type = nfi.type_name WHERE nfi.field_name = '%s' ORDER BY nt.name ASC", $field['field_name']);
     while ($type = db_fetch_array($result)) {
       $content_type = content_types($type['type']);
       $types[] = l($type['name'], 'admin/content/types/'. $content_type['url_str'] .'/fields');
@@ -35,10 +35,9 @@
   return $output;
 }
 
-
 /**
  * Menu callback; presents a listing of fields for a content type.
- * 
+ *
  * Form includes form widgets to set weight and group for each item
  * and displays other form elements and their weights to make it
  * easier to place CCK fields in the form and see where they will appear.
@@ -315,9 +314,9 @@
   $msg = FALSE;
   foreach ((array) $form_values['group-weights'] as $key => $value) {
     if ($key && !in_array($key, unserialize($form_values['disabled']))) {
-      db_query("UPDATE {node_group} SET weight = %d WHERE type_name = '%s' AND group_name = '%s'",
+      db_query("UPDATE {content_groups} SET weight = %d WHERE type_name = '%s' AND group_name = '%s'",
         $value, $form_values['type_name'], $key);
-      $msg = TRUE;  
+      $msg = TRUE;
     }
   }
   if ($msg) {
@@ -326,7 +325,7 @@
   $msg = FALSE;
   foreach ((array) $form_values['field-weights'] as $key => $value) {
     if ($key && !in_array($key, unserialize($form_values['disabled']))) {
-      db_query("UPDATE {node_field_instance} SET weight = %d WHERE type_name = '%s' AND field_name = '%s'", 
+      db_query("UPDATE {content_fields_instances} SET weight = %d WHERE type_name = '%s' AND field_name = '%s'",
         $value, $form_values['type_name'], $key);
       $msg = TRUE;
     }
@@ -471,12 +470,12 @@
     if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_CONTENT_TYPE) {
       $new_field = $field;
       $new_field['db_storage'] = CONTENT_DB_STORAGE_PER_FIELD;
-      db_query("UPDATE {node_field} SET db_storage = %d WHERE field_name = '%s'", CONTENT_DB_STORAGE_PER_FIELD, $form_values['field_name']);
+      db_query("UPDATE {content_fields} SET db_storage = %d WHERE field_name = '%s'", CONTENT_DB_STORAGE_PER_FIELD, $form_values['field_name']);
       content_alter_db_field($field, $columns, $new_field, $columns);
     }
   }
 
-  $prior_instance = db_fetch_array(db_query("SELECT weight, label, widget_type, widget_settings, description FROM {node_field_instance} WHERE field_name = '%s'", $form_values['field_name']));
+  $prior_instance = db_fetch_array(db_query("SELECT weight, label, widget_type, widget_settings, description FROM {content_fields_instances} WHERE field_name = '%s'", $form_values['field_name']));
   if (!$prior_instance) {
     $prior_instance = array();
     $prior_instance['weight'] = 0;
@@ -485,7 +484,7 @@
     $prior_instance['widget_settings'] = '';
     $prior_instance['description'] = '';
   }
-  db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings, description) VALUES ('%s', '%s', %d, '%s', '%s', '%s', '%s')", $form_values['field_name'], $form_values['type_name'], $prior_instance['weight'], $prior_instance['label'], $prior_instance['widget_type'], $prior_instance['widget_settings'], $prior_instance['description']);
+  db_query("INSERT INTO {content_fields_instances} (field_name, type_name, weight, label, widget_type, widget_settings, description) VALUES ('%s', '%s', %d, '%s', '%s', '%s', '%s')", $form_values['field_name'], $form_values['type_name'], $prior_instance['weight'], $prior_instance['label'], $prior_instance['widget_type'], $prior_instance['widget_settings'], $prior_instance['description']);
 
   drupal_set_message(t('Added field %label.', array('%label' => $prior_instance['label'])));
   content_clear_type_cache();
@@ -539,8 +538,8 @@
   }
 
   $field_widget_type = explode('-', $form_values['field_widget_type']);
-  db_query("INSERT INTO {node_field} (field_name, type, global_settings, required, multiple, db_storage) VALUES ('%s', '%s', '%s', %d, %d, %d)", $field_name, $field_widget_type[0], serialize(array()), 0, 0, CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
-  db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings, description) VALUES ('%s', '%s', %d, '%s', '%s', '%s', '%s')", $field_name, $form_values['type_name'], 0, $form_values['label'], $field_widget_type[1], serialize(array()), '');
+  db_query("INSERT INTO {content_fields} (field_name, type, global_settings, required, multiple, db_storage) VALUES ('%s', '%s', '%s', %d, %d, %d)", $field_name, $field_widget_type[0], serialize(array()), 0, 0, CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
+  db_query("INSERT INTO {content_fields_instances} (field_name, type_name, weight, label, widget_type, widget_settings, description) VALUES ('%s', '%s', %d, '%s', '%s', '%s', '%s')", $field_name, $form_values['type_name'], 0, $form_values['label'], $field_widget_type[1], serialize(array()), '');
 
   content_clear_type_cache();
 
@@ -751,18 +749,18 @@
   $prev_field = $field;
   $prev_columns = module_invoke($field_type['module'], 'field_settings', 'database columns', $field);
 
-  db_query("UPDATE {node_field_instance} SET weight = %d, label = '%s', widget_type = '%s', widget_settings = '%s', description = '%s' WHERE type_name = '%s' AND field_name = '%s'", $form_values['weight'], $form_values['label'], $form_values['widget_type'], serialize($widget_settings), $form_values['description'], $form_values['type_name'], $form_values['field_name']);
+  db_query("UPDATE {content_fields_instances} SET weight = %d, label = '%s', widget_type = '%s', widget_settings = '%s', description = '%s' WHERE type_name = '%s' AND field_name = '%s'", $form_values['weight'], $form_values['label'], $form_values['widget_type'], serialize($widget_settings), $form_values['description'], $form_values['type_name'], $form_values['field_name']);
 
   if ($form_values['multiple']) {
     $field['db_storage'] = CONTENT_DB_STORAGE_PER_FIELD;
   }
   else {
-    $instances = db_result(db_query("SELECT COUNT(*) FROM {node_field_instance} WHERE field_name = '%s'", $form_values['field_name']));
+    $instances = db_result(db_query("SELECT COUNT(*) FROM {content_fields_instances} WHERE field_name = '%s'", $form_values['field_name']));
     if ($instances == 1) {
       $field['db_storage'] = CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
     }
   }
-  db_query("UPDATE {node_field} SET required = %d, multiple = %d, global_settings = '%s', db_storage = %d WHERE field_name = '%s'", $form_values['required'], $form_values['multiple'], serialize($field_settings), $field['db_storage'], $form_values['field_name']);
+  db_query("UPDATE {content_fields} SET required = %d, multiple = %d, global_settings = '%s', db_storage = %d WHERE field_name = '%s'", $form_values['required'], $form_values['multiple'], serialize($field_settings), $field['db_storage'], $form_values['field_name']);
 
   drupal_set_message(t('Saved field %field.', array('%field' => $form_values['label'])));
   content_clear_type_cache();
@@ -797,12 +795,12 @@
   // When adding and removing columns, we need to know what content type has an instance of the field.
   if (count($previous_columns)) {
     if (!isset($previous_field['type_name'])) {
-      $previous_field['type_name'] = db_result(db_query("SELECT type_name FROM {node_field_instance} WHERE field_name = '%s'", $previous_field['field_name']));
+      $previous_field['type_name'] = db_result(db_query("SELECT type_name FROM {content_fields_instances} WHERE field_name = '%s'", $previous_field['field_name']));
     }
     $previous_db_info = content_database_info($previous_field);
   }
   if (count($new_columns)) {
-    $new_field['type_name'] = db_result(db_query("SELECT type_name FROM {node_field_instance} WHERE field_name = '%s'", $new_field['field_name']));
+    $new_field['type_name'] = db_result(db_query("SELECT type_name FROM {content_fields_instances} WHERE field_name = '%s'", $new_field['field_name']));
     $new_db_info = content_database_info($new_field);
   }
 
Index: content_crud.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_crud.inc,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 content_crud.inc
--- content_crud.inc	30 Dec 2006 22:07:32 -0000	1.4.2.3
+++ content_crud.inc	1 Jan 2007 20:41:25 -0000
@@ -7,15 +7,15 @@
  */
 
 /**
- * Rebuild content type information from node tables. 
- * 
+ * Rebuild content type information from node tables.
+ *
  *  Used to update CCK tables that might have missed changes made when CCK was disabled.
  *  Called by hook_form_alter() on system modules page whenever CCK is enabled.
  */
 function content_types_rebuild() {
   $db_types = content_types();
-    
-  $result = db_query("SELECT type_name FROM {node_field_instance}");
+
+  $result = db_query("SELECT type_name FROM {content_fields_instances}");
   while ($type = db_fetch_array($result)) {
     $field_types[] = $type['type_name'];
   }
@@ -68,10 +68,9 @@
  *   value supplied by hook_node_type()
  */
 function content_type_update($info) {
-
   if (!empty($info->old_type) && $info->old_type != $info->type) {
     // rename the content type in all fields that use changed content type.
-    db_query("UPDATE {node_field_instance} SET type_name='%s' WHERE type_name='%s'", array($info->type, $info->old_type));
+    db_query("UPDATE {content_fields_instances} SET type_name='%s' WHERE type_name='%s'", array($info->type, $info->old_type));
 
     // Rename the content fields table to match new content type name.
     $old_type = content_types($info->old_type);
@@ -171,7 +170,7 @@
  *   The number of fields deleted.
  */
 function content_field_delete($properties) {
-  $result = db_query("SELECT type_name FROM {node_field_instance} WHERE field_name = '%s'", $properties['field_name']);
+  $result = db_query("SELECT type_name FROM {content_fields_instances} WHERE field_name = '%s'", $properties['field_name']);
   $type_names = array();
   while ($type = db_fetch_array($result)) {
     $type_names[] = $type['type_name'];
@@ -234,15 +233,15 @@
  *   The number of field instances deleted.
  */
 function content_field_instance_delete($properties) {
-  $number_deleted = db_query("DELETE FROM {node_field_instance} WHERE type_name = '%s' AND field_name = '%s'", $properties['type_name'], $properties['field_name']);
-  
+  $number_deleted = db_query("DELETE FROM {content_fields_instances} WHERE type_name = '%s' AND field_name = '%s'", $properties['type_name'], $properties['field_name']);
+
   $type = content_types($properties['type_name']);
   $field = $type['fields'][$properties['field_name']];
   $field_types = _content_field_types();
   $field_type = $field_types[$field['type']];
   $columns = module_invoke($field_type['module'], 'field_settings', 'database columns', $field);
   
-  $instances = db_result(db_query("SELECT COUNT(*) FROM {node_field_instance} WHERE field_name = '%s'", $properties['field_name']));
+  $instances = db_result(db_query("SELECT COUNT(*) FROM {content_fields_instances} WHERE field_name = '%s'", $properties['field_name']));
 
   // If only one instance remains, we may need to change the database
   // representation for this field.
@@ -252,7 +251,7 @@
       if (is_array($columns) && count($columns)) {
         $new_field = $field;
         $new_field['db_storage'] = CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
-        db_query("UPDATE {node_field} SET db_storage = %d WHERE field_name = '%s'", CONTENT_DB_STORAGE_PER_CONTENT_TYPE, $properties['field_name']);
+        db_query("UPDATE {content_fields} SET db_storage = %d WHERE field_name = '%s'", CONTENT_DB_STORAGE_PER_CONTENT_TYPE, $properties['field_name']);
         content_alter_db_field($field, $columns, $new_field, $columns);
       }
     }
@@ -263,7 +262,7 @@
     if (is_array($columns) && count($columns)) {
       content_alter_db_field($field, $columns, array(), array());
     }
-    db_query("DELETE FROM {node_field} WHERE field_name = '%s'", $properties['field_name']);
+    db_query("DELETE FROM {content_fields} WHERE field_name = '%s'", $properties['field_name']);
   }
 
   content_clear_type_cache();
Index: content_views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_views.inc,v
retrieving revision 1.2.2.4
diff -u -r1.2.2.4 content_views.inc
--- content_views.inc	30 Dec 2006 22:37:00 -0000	1.2.2.4
+++ content_views.inc	1 Jan 2007 20:43:09 -0000
@@ -19,7 +19,7 @@
   foreach (content_fields() as $field) {
     $db_info = content_database_info($field);
     $module = $field_types[$field['type']]['module'];
-    
+
     $formatters = array();
     if (is_array($field_types[$field['type']]['formatters'])) {
       foreach ($field_types[$field['type']]['formatters'] as $name => $info) {
@@ -66,6 +66,9 @@
         $table['sorts'][$main_column['column']] = array(
           'name' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .')',
           'field' => $main_column['column'],
+          'content_db_info' => $db_info,
+          'content_field' => $field,
+          'content_field_module' => $module,
         );
       }
 
@@ -82,6 +85,9 @@
           $init = array(
             'name' => $name,
             'field' => $main_column['column'],
+            'content_db_info' => $db_info,
+            'content_field' => $field,
+            'content_field_module' => $module,
           );
           $table['filters'][$main_column['column'] .'_'. $key] = array_merge($filter, $init);
         }
@@ -250,30 +256,50 @@
 }
 
 /**
- * Rebuild the cached queries for the views using a given field
- * used when a field changes its 'multiple' status
- * plus helper function for updates
+ * Rebuild the cached queries for the views using a given field.
+ * Called when a field changes its 'multiple' status.
+ * Can also be useful for updates.
  *
  * @param unknown_type $update_fields
  */
+
 function _content_views_rebuild_views($update_fields) {
   views_load_cache();
-  $tables = _views_get_tables();
+  $tables = _views_get_tables(true);
   $result = db_query("SELECT name, query FROM {view_view} ORDER BY name");
+  // TODO : do we have to do that for default views as well ?
   while ($row = db_fetch_array($result)) {
     // if a query has been stored for the view
     if (!empty($row['query'])) {
       $view = views_get_view($row['name']);
-      // TODO : check for arguments / sorts / filters as well ?
+      $view_content_fields = array();
+
       foreach ($view->field as $field) {
-        // if the view contains one of the fields that require updating
-        $field_info = $tables[$field['tablename']]['fields'][$field['field']];
-        if (isset($field_info['content_field']) && in_array($field_info['content_field']['field_name'], $update_fields)) {
-          // re-save the view (forces the query to be updated)
-          _views_save_view($view);
-          break;
+        $info = $tables['fields']['base'][$field['fullname']];
+        if (isset($info['content_field'])) {
+          $view_content_fields[] = $info['content_field']['field_name'];
+        }
+      }
+
+      foreach ($view->filter as $filter) {
+        $info = $tables['filters']['base'][$filter['field']];
+        if (isset($info['content_field'])) {
+          $view_content_fields[] = $info['content_field']['field_name'];
         }
       }
+
+      foreach ($view->sort as $sort) {
+        $info = $tables['sorts']['base'][$sort['field']];
+        if (isset($info['content_field'])) {
+          $view_content_fields[] = $info['content_field']['field_name'];
+        }
+      }
+
+      // no need to check arguments : a view with arguments is not cacheable
+
+      if (count(array_intersect($view_content_fields, $update_fields))) {
+        _views_save_view($view);
+      }
     }
   }
 }
Index: fieldgroup.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/fieldgroup.install,v
retrieving revision 1.1.4.4
diff -u -r1.1.4.4 fieldgroup.install
--- fieldgroup.install	1 Jan 2007 16:45:40 -0000	1.1.4.4
+++ fieldgroup.install	1 Jan 2007 20:45:24 -0000
@@ -5,7 +5,7 @@
   switch ($GLOBALS['db_type']) {
     case 'mysql':
     case 'mysqli':
-      db_query("CREATE TABLE {node_group} (
+      db_query("CREATE TABLE {content_groups} (
                 `type_name` varchar(32) NOT NULL default '',
                 `group_name` varchar(32) NOT NULL default '',
                 `label` varchar(255) NOT NULL default '',
@@ -14,7 +14,7 @@
                 `weight` tinyint(4) NOT NULL,
                  PRIMARY KEY(`type_name`, `group_name`)
               ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      db_query("CREATE TABLE {node_group_fields} (
+      db_query("CREATE TABLE {content_groups_fields} (
                 `type_name` varchar(32) NOT NULL default '',
                 `group_name` varchar(32) NOT NULL default '',
                 `field_name` varchar(32) NOT NULL default '',
@@ -22,7 +22,7 @@
               ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
       break;
     case 'pgsql':
-      db_query("CREATE TABLE {node_group} (
+      db_query("CREATE TABLE {content_groups} (
                 type_name varchar(32) NOT NULL default '',
                 group_name varchar(32) NOT NULL default '',
                 label varchar(255) NOT NULL default '',
@@ -31,7 +31,7 @@
                 weight smallint NOT NULL,
                 PRIMARY KEY(type_name, group_name)
       )");
-      db_query("CREATE TABLE {node_group_fields} (
+      db_query("CREATE TABLE {content_groups_fields} (
                 type_name varchar(32) NOT NULL default '',
                 group_name varchar(32) NOT NULL default '',
                 field_name varchar(32) NOT NULL default '',
@@ -41,6 +41,9 @@
   }
 }
 
+/**
+ *  rename groups form "group-*" to "group_*"
+ */
 function fieldgroup_update_1() {
   $ret = array();
   switch ($GLOBALS['db_type']) {
@@ -58,3 +61,24 @@
   cache_clear_all('fieldgroup_data', 'cache');
   return $ret;
 }
+
+/**
+ *  rename db tables to content_groups and content_groups_fields
+ */
+function fieldgroup_update_2() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("RENAME TABLE {node_group} TO {content_groups}");
+      $ret[] = update_sql("RENAME TABLE {node_group_fields} TO {content_groups_fields}");
+      break;
+
+    case 'pgsql':
+      $ret[] = update_sql("ALTER TABLE {node_group} RENAME TO {content_groups}");
+      $ret[] = update_sql("ALTER TABLE {node_group_fields} RENAME TO {content_groups_fields}");
+      break;
+  }
+
+  return $ret;
+}
Index: fieldgroup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/fieldgroup.module,v
retrieving revision 1.1.4.5
diff -u -r1.1.4.5 fieldgroup.module
--- fieldgroup.module	30 Dec 2006 21:40:10 -0000	1.1.4.5
+++ fieldgroup.module	1 Jan 2007 20:47:09 -0000
@@ -72,7 +72,6 @@
 }
 
 function fieldgroup_edit_group_form($content_type, $group_name, $action) {
-  
   $groups = fieldgroup_groups($content_type['type']);
   $group = $groups[$group_name];
 
@@ -140,9 +139,8 @@
  *  Group name validation for programmatic group addition.
  */
 function fieldgroup_edit_group_validate($form_id, $form_values, $content_type, $action) {
-
   if (!empty($form_values['group_name']) && $action == 'add') {
-    
+
     $groups = fieldgroup_groups($content_type['type']);
     $group = $groups[$form_values['group_name']];
 
@@ -182,16 +180,15 @@
         }
       }
     }
-    db_query("INSERT INTO {node_group} (type_name, group_name, label, settings, description, weight)
+    db_query("INSERT INTO {content_groups} (type_name, group_name, label, settings, description, weight)
               VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $content_type['type'], $group_name, $form_values['label'], serialize($form_values['settings']), $form_values['description'], $form_values['weight']);
   }
   else {
-    db_query("UPDATE {node_group} SET label = '%s', settings = '%s', description = '%s', weight = %d ".
+    db_query("UPDATE {content_groups} SET label = '%s', settings = '%s', description = '%s', weight = %d ".
              "WHERE type_name = '%s' AND group_name = '%s'",
              $form_values['label'], serialize($form_values['settings']), $form_values['description'], $form_values['weight'], $content_type['type'], $form_values['group_name']);
   }
   cache_clear_all('fieldgroup_data', 'cache');
-  
   return 'admin/content/types/'. $content_type['url_str'] .'/fields';
 }
 
@@ -213,8 +210,8 @@
 }
 
 function fieldgroup_remove_group_submit($form_id, &$form_values, $content_type, $group_name) {
-  db_query("DELETE FROM {node_group} WHERE  type_name = '%s' AND group_name = '%s'", $content_type['type'], $group_name);
-  db_query("DELETE FROM {node_group_fields} WHERE  type_name = '%s' AND group_name = '%s'", $content_type['type'], $group_name);
+  db_query("DELETE FROM {content_groups} WHERE  type_name = '%s' AND group_name = '%s'", $content_type['type'], $group_name);
+  db_query("DELETE FROM {content_groups_fields} WHERE  type_name = '%s' AND group_name = '%s'", $content_type['type'], $group_name);
   cache_clear_all('fieldgroup_data', 'cache');
 
   drupal_set_message('The group has been removed.');
@@ -237,7 +234,7 @@
       $groups_sorted = &$data['groups_sorted'];
     }
     else {
-      $result = db_query("SELECT g.* FROM {node_group} g ORDER BY g.weight, g.group_name");
+      $result = db_query("SELECT g.* FROM {content_groups} g ORDER BY g.weight, g.group_name");
 
       while ($group = db_fetch_array($result)) {
         $group['settings'] = unserialize($group['settings']);
@@ -246,9 +243,9 @@
         $groups_sorted[$group['type_name']][] = &$groups[$group['type_name']][$group['group_name']];
       }
       //load fields
-      $result = db_query("SELECT fi.*, g.group_name FROM {node_group} g ".
-                         "JOIN {node_group_fields} f USING(type_name, group_name) ".
-                         "JOIN {node_field_instance} fi USING(field_name, type_name) ".
+      $result = db_query("SELECT fi.*, g.group_name FROM {content_groups} g ".
+                         "JOIN {content_groups_fields} f USING(type_name, group_name) ".
+                         "JOIN {content_fields_instances} fi USING(field_name, type_name) ".
                          "ORDER BY fi.weight");
       while ($field = db_fetch_array($result)) {
         $groups[$field['type_name']][$field['group_name']]['fields'][$field['field_name']] = $field;
@@ -278,7 +275,7 @@
 }
 
 function _fieldgroup_field_get_group($content_type, $field_name) {
-  return db_result(db_query("SELECT group_name FROM {node_group_fields} WHERE type_name = '%s' AND field_name = '%s'", $content_type, $field_name));
+  return db_result(db_query("SELECT group_name FROM {content_groups_fields} WHERE type_name = '%s' AND field_name = '%s'", $content_type, $field_name));
 }
 
 /*
@@ -331,22 +328,22 @@
 function fieldgroup_content_admin_form_submit($form_id, &$form_values, $default) {
   if ($default != $form_values['group']) {
     if ($form_values['group'] && !$default) {
-      db_query("INSERT INTO {node_group_fields} (type_name, group_name, field_name) VALUES ('%s', '%s', '%s')",
+      db_query("INSERT INTO {content_groups_fields} (type_name, group_name, field_name) VALUES ('%s', '%s', '%s')",
                 $form_values['type_name'], $form_values['group'], $form_values['field_name']);
     }
     else if ($form_values['group']) {
-      db_query("UPDATE {node_group_fields} SET group_name = '%s' WHERE type_name = '%s' AND field_name = '%s'",
+      db_query("UPDATE {content_groups_fields} SET group_name = '%s' WHERE type_name = '%s' AND field_name = '%s'",
                 $form_values['group'], $form_values['type_name'], $form_values['field_name']);
     }
     else {
-      db_query("DELETE FROM {node_group_fields} WHERE type_name = '%s' AND field_name = '%s'", $form_values['type_name'], $form_values['field_name']);
+      db_query("DELETE FROM {content_groups_fields} WHERE type_name = '%s' AND field_name = '%s'", $form_values['type_name'], $form_values['field_name']);
     }
     cache_clear_all('fieldgroup_data', 'cache');
   }
 }
 
 function fieldgroup_content_admin_field_remove_submit($form_id, &$form_values) {
-  db_query("DELETE FROM {node_group_fields} WHERE type_name = '%s' AND field_name = '%s'", $form_values['type_name'], $form_values['field_name']);
+  db_query("DELETE FROM {content_groups_fields} WHERE type_name = '%s' AND field_name = '%s'", $form_values['type_name'], $form_values['field_name']);
 }
 
 
@@ -371,12 +368,12 @@
 function fieldgroup_node_type($op, $info) {
   if ($op == 'update' && $info->type != $info->old_type) {
     // update the tables
-    db_query("UPDATE {node_group} SET type_name='%s' WHERE type_name='%s'", array($info->type, $info->old_type));
-    db_query("UPDATE {node_group_fields} SET type_name='%s' WHERE type_name='%s'", array($info->type, $info->old_type));
+    db_query("UPDATE {content_groups} SET type_name='%s' WHERE type_name='%s'", array($info->type, $info->old_type));
+    db_query("UPDATE {content_groups_fields} SET type_name='%s' WHERE type_name='%s'", array($info->type, $info->old_type));
     cache_clear_all('fieldgroup_data', 'cache');
   }
   else if ($op == 'delete') {
-    db_query("DELETE FROM {node_group_fields} WHERE type_name = '%s'", $info->type);
-    db_query("DELETE FROM {node_group} WHERE type_name = '%s'", $info->type);
+    db_query("DELETE FROM {content_groups_fields} WHERE type_name = '%s'", $info->type);
+    db_query("DELETE FROM {content_groups} WHERE type_name = '%s'", $info->type);
   }
 }
\ No newline at end of file
