Index: cck_blocks.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck_blocks/Attic/cck_blocks.install,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 cck_blocks.install
--- cck_blocks.install	25 Jan 2010 18:16:31 -0000	1.1.2.6
+++ cck_blocks.install	31 Jan 2010 19:43:59 -0000
@@ -14,9 +14,9 @@ function cck_blocks_update_6000() {
  * Implementation of hook_update_N().
  *
  * In previous versions, all fields were exposed as blocks. In this version, fields
- * are not exposed by default, but can be added manually in the field configuration 
+ * are not exposed by default, but can be added manually in the field configuration
  * page. This update sets globabl preferences to retain the availability of all
- * custom fields as blocks.
+ * custom fields as blocks, to avoid confusing existing users.
  */
 function cck_blocks_update_6101() {
   $ret = array();
@@ -27,8 +27,6 @@ function cck_blocks_update_6101() {
 	    variable_set('cck_blocks_' . $field_info['field_name'] . '_block_availability', '2');
 	  }
   }
-  
+
   return $ret;
 }
-
-
Index: cck_blocks.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck_blocks/cck_blocks.module,v
retrieving revision 1.2.2.10
diff -u -p -r1.2.2.10 cck_blocks.module
--- cck_blocks.module	25 Jan 2010 18:16:31 -0000	1.2.2.10
+++ cck_blocks.module	31 Jan 2010 19:44:00 -0000
@@ -1,24 +1,26 @@
 <?php
 // $Id: cck_blocks.module,v 1.2.2.10 2010/01/25 18:16:31 forschi Exp $
 
+/**
+ * CCK blocks can either be enabled or disabled per field.
+ */
 define('CCK_BLOCKS_FIELD_BLOCK_DISABLED', 1);
 define('CCK_BLOCKS_FIELD_BLOCK_ENABLED', 2);
-define('CCK_BLOCKS_FIELD_BLOCK_INHERIT', 3);
 
 /**
  * Implementation of hook_content_build_modes().
  */
  function cck_blocks_content_build_modes() {
   return array(
-  'cck_blocks' => array(
-    'title' => t('CCK Blocks'),
-    'build modes' => array(
     'cck_blocks' => array(
       'title' => t('CCK Blocks'),
-      'views style' => FALSE,
-    ),
+      'build modes' => array(
+        'cck_blocks' => array(
+          'title' => t('CCK Blocks'),
+          'views style' => FALSE,
+        ),
+      ),
     ),
-  ),
   );
 }
 
@@ -27,7 +29,7 @@ define('CCK_BLOCKS_FIELD_BLOCK_INHERIT',
  */
 function cck_blocks_block($op = 'list', $delta = 0, $edit = array()) {
   static $built_nodes = NULL;
-  
+
   $fields = module_invoke('content', 'fields');
 
   switch ($op) {
@@ -36,7 +38,7 @@ function cck_blocks_block($op = 'list', 
     $blocks = array();
       if (count($fields)) {
         foreach($fields as $field_name => $field_info) {
-          if (_cck_blocks_check_field_settings($field_info)) {
+          if (variable_get('cck_blocks_' . $field_info['field_name'] . '_block_availability', CCK_BLOCKS_FIELD_BLOCK_DISABLED) == CCK_BLOCKS_FIELD_BLOCK_ENABLED) {
             $blocks[$field_name] = array(
               'info' => 'CCK: '.($field_info['widget']['label'] ? $field_info['widget']['label'] : $field_name),
               'cache' => BLOCK_NO_CACHE,
@@ -45,7 +47,7 @@ function cck_blocks_block($op = 'list', 
         }
       }
     return $blocks;
-  
+
   case 'configure':
     // add token help, if token module is installed
     if (module_exists('token')) {
@@ -66,64 +68,59 @@ function cck_blocks_block($op = 'list', 
 
   case 'view':
     $block = array();
-  
+
     if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2) && $fields[$delta]) {
-    $nid = arg(1);
-    if (!isset($built_nodes[$nid])) {
-      // Build the node in the cck_blocks mode. This is based on node_build_content().
-      $node = node_load($nid);
-      $node->build_mode = 'cck_blocks';
-
-      // Remove the delimiter (if any) that separates the teaser from the body.
-      $node->body = isset($node->body) ? str_replace('<!--break-->', '', $node->body) : '';
-
-      // The 'view' hook can be implemented to overwrite the default function
-      // to display nodes.
-      if (node_hook($node, 'view')) {
-      $node = node_invoke($node, 'view', $teaser, $page);
-      }
-      else {
-      $node = node_prepare($node, $teaser);
+      $nid = arg(1);
+      if (!isset($built_nodes[$nid])) {
+        // Build the node in the cck_blocks mode. This is based on node_build_content().
+        $node = node_load($nid);
+        $node->build_mode = 'cck_blocks';
+
+        // Remove the delimiter (if any) that separates the teaser from the body.
+        $node->body = isset($node->body) ? str_replace('<!--break-->', '', $node->body) : '';
+
+        // The 'view' hook can be implemented to overwrite the default function
+        // to display nodes.
+        if (node_hook($node, 'view')) {
+          $node = node_invoke($node, 'view', $teaser, $page);
+        }
+        else {
+          $node = node_prepare($node, $teaser);
+        }
+
+        // Allow modules to make their own additions to the node.
+        node_invoke_nodeapi($node, 'view', $teaser, $page);
+        $built_nodes[$nid] = $node;
       }
 
-      // Allow modules to make their own additions to the node.
-      node_invoke_nodeapi($node, 'view', $teaser, $page);
-      $built_nodes[$nid] = $node;
-    }
-    
-    // If the block is disabled globally or specifically for this content type, return (don't display)
-    if (_cck_blocks_display_test($built_nodes[$nid]->type, $delta)) {
-      return;
-    }
-    
-    // look directly for the cck_field in the content array
-    $cck_field_data = false;
-    if (isset($built_nodes[$nid]->content[$delta])) {
-      $cck_field_data = $built_nodes[$nid]->content[$delta];
-    }
-    else {
-      // cycle through all content data arrays looking for cck groups
-      // the cck_field may be within a group
-      foreach ($built_nodes[$nid]->content as $key => $data) {
-	      if ((strpos($key, 'group_') == 0) && isset($data['group'][$delta])) {
-	        // yay it's a group
-	        $cck_field_data = $data['group'][$delta];
-	      }
+      // look directly for the cck_field in the content array
+      $cck_field_data = false;
+      if (isset($built_nodes[$nid]->content[$delta])) {
+        $cck_field_data = $built_nodes[$nid]->content[$delta];
+      }
+      else {
+        // cycle through all content data arrays looking for cck groups
+        // the cck_field may be within a group
+        foreach ($built_nodes[$nid]->content as $key => $data) {
+          if ((strpos($key, 'group_') == 0) && isset($data['group'][$delta])) {
+            // yay it's a group
+            $cck_field_data = $data['group'][$delta];
+          }
+        }
       }
-    }
 
-    if ($cck_field_data) {
-      // evaluate tokens, if token module is installed
-      if (module_exists('token')) {
-      $result = db_query("SELECT title FROM {blocks} WHERE delta = '".$delta."' ");
-      $object = db_fetch_object($result);
-      if($object->title){
-        $block['title'] = token_replace($object->title,'node',$node);
+      if ($cck_field_data) {
+        // evaluate tokens, if token module is installed
+        if (module_exists('token')) {
+          $result = db_query("SELECT title FROM {blocks} WHERE delta = '".$delta."' ");
+          $object = db_fetch_object($result);
+          if ($object->title){
+            $block['title'] = token_replace($object->title,'node',$node);
+          }
+        }
+        $block['subject'] = t($fields[$delta]['widget']['label'] ? $fields[$delta]['widget']['label'] : $delta);
+        $block['content'] = drupal_render($cck_field_data);
       }
-      }      
-      $block['subject'] = t($fields[$delta]['widget']['label'] ? $fields[$delta]['widget']['label'] : $delta);
-      $block['content'] = drupal_render($cck_field_data);
-    }
     }
   }
   return $block;
@@ -132,93 +129,39 @@ function cck_blocks_block($op = 'list', 
 /**
  * Implementation of hook_form_alter().
  *
- * Adds options to the field configuration page for making the field available as a
- * block for this specific content type or for every content type that uses it.
+ * Adds options to the field configuration page for making the field available
+ * as a block for every content type that uses it.
  */
 function cck_blocks_form_alter(&$form, $form_state, $form_id) {
   switch ($form_id) {
     case 'content_field_edit_form':
-      // Instance specific settings form
-      $type_name = $form['#field']['type_name'];
       $field_name = $form['#field']['field_name'];
-      $form['widget']['block_settings'] = array(
-        '#type' => 'fieldset',
-        '#title' => 'CCK Block settings',
-        '#collapsible' => 'TRUE',
-        '#collapsed' => 'TRUE',
-        '#weight' => 12,
-        'instance_block_settings' => array(
-          '#type' => 'radios',
-          '#description' => t('When enabled, this provides a block for this field, on this content type'),
-          '#default_value' => variable_get('cck_blocks_' . $field_name . '_block_availability_' . $type_name, CCK_BLOCKS_FIELD_BLOCK_INHERIT),
-          '#options' => array(
-            CCK_BLOCKS_FIELD_BLOCK_INHERIT => t('Use global field settings'),
-            CCK_BLOCKS_FIELD_BLOCK_DISABLED => t('Disable block'),
-            CCK_BLOCKS_FIELD_BLOCK_ENABLED => t('Enable block'),            
-          ),
-        ),
-      );
+
       // Global settings form
-      $form['field']['global_block_settings'] = array(
+      $form['field']['global_cck_blocks_settings'] = array(
         '#type' => 'radios',
         '#title' => t('Provide block for this field'),
         '#default_value' => variable_get('cck_blocks_' . $field_name . '_block_availability', CCK_BLOCKS_FIELD_BLOCK_DISABLED),
-        '#description' => t('When enabled, this field becomes available as a block in the block admin page. Overridden by content-type-specific settings'),
+        '#description' => t('When enabled, this field becomes available as a block in the block admin page.'),
         '#options' => array(
           CCK_BLOCKS_FIELD_BLOCK_DISABLED => t('Disabled'),
-          CCK_BLOCKS_FIELD_BLOCK_ENABLED => t('Enabled'), 
+          CCK_BLOCKS_FIELD_BLOCK_ENABLED => t('Enabled'),
         ),
       );
-      // Add custom form handler to the submit function
+
+      // Add custom submit handler for the form:
       $form['#submit'][] = 'cck_blocks_field_settings_submit';
       break;
   }
 }
 
-/**  
- * Cck_blocks custom form submission handler.
+/**
+ * Custom submit handler for the content field edit form.
+ *
+ * @see cck_blocks_form_alter().
  */
 function cck_blocks_field_settings_submit($form, $form_state) {
-  $type_name = $form['#field']['type_name'];
   $field_name = $form['#field']['field_name'];
-  // Retrieve user input
-  $instance_value = $form_state ['values']['instance_block_settings'];
-  $global_value = $form_state ['values']['global_block_settings'];
-  // Set persistent variables
-  variable_set('cck_blocks_' . $field_name . '_block_availability_' . $type_name, $instance_value);  
+  $global_value = $form_state ['values']['global_cck_blocks_settings'];
   variable_set('cck_blocks_' . $field_name . '_block_availability', $global_value);
 }
-
-// Function to check prefs for listing fields in block admin page (called in case: list)
-function _cck_blocks_check_field_settings($field_info) {
-  // Create array of content types ($types) that use this field
-  module_load_include('inc', 'content', 'includes/content.crud');
-  $instances = content_field_instance_read(array('field_name' => $field_info['field_name']));
-  foreach($instances as $instance) {
-    $types[] = $instance['type_name'];
-  }
-  
-  // Check specific then global prefs for this field within this content type
-  foreach ($types as $type) {
-    switch (variable_get('cck_blocks_' . $field_info['field_name'] . '_block_availability_' . $field_info['type_name'], CCK_BLOCKS_FIELD_BLOCK_INHERIT)) {
-      case CCK_BLOCKS_FIELD_BLOCK_INHERIT:
-        if (variable_get('cck_blocks_' . $field_info['field_name'] . '_block_availability', CCK_BLOCKS_FIELD_BLOCK_DISABLED) == CCK_BLOCKS_FIELD_BLOCK_ENABLED) {
-          return TRUE;
-        }
-        break;
-      case CCK_BLOCKS_FIELD_BLOCK_ENABLED:
-        return TRUE;
-      case CCK_BLOCKS_FIELD_BLOCK_DISABLED:
-        break;
-    }
-  };
-  return FALSE;
-}
-
-// Function to check pref for displaying blocks in page (called in case: veiw)
-function _cck_blocks_display_test($type, $delta) {
-	$prefix = 'cck_blocks_' . $delta . '_block_availability';
-  return (variable_get($prefix . '_' . $type, CCK_BLOCKS_FIELD_BLOCK_INHERIT) == CCK_BLOCKS_FIELD_BLOCK_DISABLED)
-  || ((variable_get($prefix . '_' . $type, CCK_BLOCKS_FIELD_BLOCK_INHERIT) == CCK_BLOCKS_FIELD_BLOCK_INHERIT)
-  && (variable_get($prefix, CCK_BLOCKS_FIELD_BLOCK_DISABLED) == CCK_BLOCKS_FIELD_BLOCK_DISABLED));
-}
\ No newline at end of file
