? 871770_content_access_features.patch
? 871770_content_access_features_v2.patch
Index: content_access.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_access/Attic/content_access.install,v
retrieving revision 1.1.4.3
diff -u -p -r1.1.4.3 content_access.install
--- content_access.install	28 Oct 2008 13:36:17 -0000	1.1.4.3
+++ content_access.install	21 Sep 2010 21:00:39 -0000
@@ -14,6 +14,9 @@ function content_access_install() {
  */
 function content_access_uninstall() {
   variable_del('content_access_settings');
+    foreach (node_get_types() as $type_name => $type) {
+      variable_del('content_access_settings_'. $type_name);
+    }
   // Remove tables.
   drupal_uninstall_schema('content_access');
 }
@@ -41,6 +44,16 @@ function content_access_schema() {
   return $schema;
 }
 
+/**
+ * Upgrade from old- to new-style variables
+ */
+function content_access_update_6002() {
+  drupal_load('module', 'content_access');
+  $settings = variable_get('content_access_settings', array());
+  content_access_set_settings($settings);
+  variable_del('content_access_settings');
+  return array();
+}
 
 /**
  * Upgrade from d5 to d6
Index: content_access.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_access/Attic/content_access.module,v
retrieving revision 1.1.2.9.2.22
diff -u -p -r1.1.2.9.2.22 content_access.module
--- content_access.module	2 Sep 2010 13:13:33 -0000	1.1.2.9.2.22
+++ content_access.module	21 Sep 2010 21:00:39 -0000
@@ -175,7 +175,14 @@ function content_access_disabling($set =
  */
 function content_access_get_settings($return = 'all', $type = NULL) {
   if ($return == 'all') {
-    return variable_get('content_access_settings', array());
+    $settings = array();
+    foreach (node_get_types() as $type_name => $type) {
+      if ($setting = variable_get('content_access_settings_'. $type_name, array())) {
+        $settings['content_access_settings_'. $type_name] = $setting;
+      }
+    }
+    $settings = content_access_convert_settings($settings);
+    return $settings;
   }
   if (isset($type)) {
     $settings = content_access_get_settings($return);
@@ -202,7 +209,53 @@ function content_access_set_settings($se
       }
     }
   }
-  variable_set('content_access_settings', $settings);
+  $settings = content_access_convert_settings($settings);
+  foreach ($settings as $type_var => $setting) {
+    variable_set($type_var, $setting);
+  }
+}
+
+/**
+ * Converts old-style settings to new-style settings, and vice versa.
+ *
+ * @param array $settings Either new or old-style settings array.  Will auto-detect.
+ * @return array $settings Converted settings either old to new or new to old.
+ */
+function content_access_convert_settings($settings) {
+  $types = node_get_types();
+  $switch = array('old' => 'new');
+  $settings_new = array();
+
+  // Detect whether $settings is new-style or old-style
+  foreach ($types as $name => $type) {
+    if (array_key_exists('content_access_settings_'. $name, $settings)) {
+      $switch = array('new' => 'old');
+    }
+  }
+  
+  if (array_key_exists('new', $switch)) {
+    // Convert from new to old
+    foreach ($settings as $type_var => $setting) {
+      $type = str_replace('content_access_settings_', '', $type_var);
+      foreach (content_access_available_settings() as $setting) {
+        if (isset($settings[$type_var][$setting])) {
+          $settings_new[$setting][$type] = $settings[$type_var][$setting];
+        }
+      }
+    }
+  }
+  else {
+    // Convert from old to new
+    foreach (content_access_available_settings() as $setting) {
+      if (isset($settings[$setting])) {
+        foreach ($settings[$setting] as $type => $value) {
+          $settings_new['content_access_settings_'. $type][$setting] = $value;
+        }
+      }
+    }
+  }
+  
+  return $settings_new;
 }
 
 /*
