Index: content_copy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_copy.module,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 content_copy.module
--- content_copy.module	26 Sep 2007 22:45:45 -0000	1.1.2.9
+++ content_copy.module	8 Mar 2008 16:15:51 -0000
@@ -20,6 +20,11 @@
  *
  *  Content type, group and field names will be imported exactly as exported.
  *  If the names are already in use, no import will be performed.
+ *
+ *  Note: The "display fields" information is being handled a little differently than the rest of the
+ *  data that's imported and exported.  Instead of calling through the create and playback macros,
+ *  we get and set the data directly from/into the database.  the reason for this is that the
+ *  playback macro method does not lend itself well to the display fields.
  */
 
 /**
@@ -354,6 +359,7 @@
     fieldgroup_groups('', FALSE, TRUE);
   }
 
+  $should_clear_type_cache = 0;
   // Iterate through the field forms in the import and execute each.
   foreach ($imported_fields as $field) {
 
@@ -424,9 +430,44 @@
                '%type' => $type_label
                )));
         }
+        else {
+            //
+            // If we successfully updated the form, serialize the display_settings info
+            // and insert the display_settings (if it exists) into the database.
+            //
+          if (array_key_exists( 'display_settings', $field)) {
+            $query = 'UPDATE {node_field_instance} SET display_settings = \'%s\' WHERE field_name = \'%s\'';
+            db_query($query, serialize($field['display_settings']), $field['field_name']);
+            if ($db_err = db_error()) {
+              drupal_set_message(t("The field %field_label (%field_name) was added to the content type %type, but an error has occured updating the field's 'display_settings'.<br/>The db error is: '%db_err'.", array(
+                   '%field_label' => $field_label,
+                   '%field_name' => $field_name,
+                   '%type' => $type_label,
+                   '%db_err' => $db_err
+              )));
+            }
+            else {
+                //
+                // Make sure that if any data is successfully inserted into the DB,
+                // we make sure the cache is cleared.
+                //
+              $should_clear_type_cache = 1;
+            }
+          }
+        }
       }
     }
   }
+
+    //
+    // If no errors occured when inserting field data directly into the DB,
+    // clear the type cache (this only needs to be done once per invocation
+    // of this function.
+    //
+  if ($should_clear_type_cache) {
+    content_clear_type_cache();
+  }
+
   if (!form_get_errors()) {
     if (sizeof($imported_fields) > 0 || sizeof($imported_groups) > 0) {
       return 'admin/content/types/'. $content_info['content types'][$type_name]['url_str'] .'/fields';
@@ -529,8 +570,36 @@
     else {
       $field_name = $edit['field_name'];
     }
+      //
+      // The display settings are being fetched directly from the DB. During import,
+      // we'll re-insert the data directly as well.
+      //
+    $query = 'SELECT display_settings FROM {node_field_instance} WHERE field_name = \'%s\'';
+    $row_info = db_fetch_array(db_query($query, $field_name));
+
+      //
+      // If an error occurs, notify the user.
+      //
+    if ($db_err = db_error()) {
+      drupal_set_message(t("An error occurred when exporting the 'display settings' data for the field %field_name.<br/>The db error is: '%db_err'.", array(
+           '%field_name' => $field_name,
+           '%db_err' => $db_err
+      )));
+    }
+    else {
+        //
+        // The db fetch occurred successfully, unserialize the data blob and
+        // insert it into a new "display_settings" field of the data.
+        //
+      $display_settings_str = $row_info['display_settings'];
+      $display_settings = unserialize($display_settings_str);
+      if ($display_settings != FALSE) {
+        $edit['display_settings'] = $display_settings;
+      }
+    }
     $subs['fields'][] = $edit;
     $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
+    break;
   }
 
   $GLOBALS['content_copy']['submissions'] = $subs;
