? 571238-cck_blocks-followup.patch
Index: cck_blocks.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck_blocks/Attic/cck_blocks.install,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 cck_blocks.install
--- cck_blocks.install	17 Mar 2010 20:17:51 -0000	1.1.2.7
+++ cck_blocks.install	17 Mar 2010 23:09:34 -0000
@@ -22,11 +22,18 @@ function cck_blocks_update_6101() {
   $ret = array();
   $fields = module_invoke('content', 'fields');
 
-	if (count($fields)) {
-	  foreach($fields as $field_name => $field_info) {
-	    variable_set('cck_blocks_' . $field_info['field_name'] . '_block_availability', '2');
-	  }
+  if (count($fields)) {
+    foreach($fields as $field_name => $field_info) {
+      variable_set('cck_blocks_' . $field_info['field_name'] . '_block_availability', 2);
+    }
   }
 
   return $ret;
 }
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function cck_blocks_uninstall() {
+  db_query("DELETE FROM {variable} WHERE name LIKE 'cck_blocks%'");
+}
Index: cck_blocks.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck_blocks/cck_blocks.module,v
retrieving revision 1.2.2.11
diff -u -p -r1.2.2.11 cck_blocks.module
--- cck_blocks.module	17 Mar 2010 20:17:51 -0000	1.2.2.11
+++ cck_blocks.module	17 Mar 2010 23:09:35 -0000
@@ -10,7 +10,7 @@ define('CCK_BLOCKS_FIELD_BLOCK_ENABLED',
 /**
  * Implementation of hook_content_build_modes().
  */
- function cck_blocks_content_build_modes() {
+function cck_blocks_content_build_modes() {
   return array(
     'cck_blocks' => array(
       'title' => t('CCK Blocks'),
@@ -40,7 +40,7 @@ function cck_blocks_block($op = 'list', 
         foreach($fields as $field_name => $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),
+              'info' => t('CCK: @field', array('@field' => t($field_info['widget']['label']))),
               'cache' => BLOCK_NO_CACHE,
             );
           }
@@ -51,52 +51,32 @@ function cck_blocks_block($op = 'list', 
   case 'configure':
     // add token help, if token module is installed
     if (module_exists('token')) {
-    $form = array();
-    $form['view']['token_help'] = array(
-      '#title' => t('Replacement patterns'),
-      '#type' => 'fieldset',
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'),
-    );
-
-    $form['view']['token_help']['help'] = array(
-      '#value' => theme('token_help', 'node'),
-    );
-    return $form;
+      $form = array();
+      $form['view']['token_help'] = array(
+        '#title' => t('Replacement patterns'),
+        '#type' => 'fieldset',
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'),
+      );
+
+      $form['view']['token_help']['help'] = array(
+        '#value' => theme('token_help', 'node'),
+      );
+      return $form;
     }
 
   case 'view':
     $block = array();
 
-    if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2) && $fields[$delta]) {
-      $nid = arg(1);
+    // Get viewed node.
+    $node = menu_get_object();
+    if (isset($node->nid) && !arg(2) && $fields[$delta]) {
+      $nid = $node->nid;
       if (!isset($built_nodes[$nid])) {
-        // Build the node in the cck_blocks mode. This is based on node_build_content().
-        $node = node_load($nid);
-
-        // check the users permissions for this node
-        if(!node_access("view", $node)){
-          //return an empty array, if access to the node is not permitted
-          return array();
-        }
-                
         $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);
+        // This is a node page.
+        $node = node_build_content($node, FALSE, TRUE);
         $built_nodes[$nid] = $node;
       }
 
@@ -119,13 +99,14 @@ function cck_blocks_block($op = 'list', 
       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',$built_nodes[$nid]);
+          $title = db_result(db_query("SELECT title FROM {blocks} WHERE delta = '%s'", $delta));
+          if ($title) {
+            $block['title'] = token_replace($title, 'node', $built_nodes[$nid]);
           }
         }
-        $block['subject'] = t($fields[$delta]['widget']['label'] ? $fields[$delta]['widget']['label'] : $delta);
+        if (isset($fields[$delta]['widget']['label'])) {
+          $block['subject'] = t($fields[$delta]['widget']['label']);
+        }
         $block['content'] = drupal_render($cck_field_data);
       }
     }
@@ -142,6 +123,10 @@ function cck_blocks_block($op = 'list', 
 function cck_blocks_form_alter(&$form, $form_state, $form_id) {
   switch ($form_id) {
     case 'content_field_edit_form':
+      if (isset($form_state['change_basic'])) {
+        // Break if this is a basic information page.
+        break;
+      }
       $field_name = $form['#field']['field_name'];
 
       // Global settings form
@@ -169,6 +154,6 @@ function cck_blocks_form_alter(&$form, $
  */
 function cck_blocks_field_settings_submit($form, $form_state) {
   $field_name = $form['#field']['field_name'];
-  $global_value = $form_state ['values']['global_cck_blocks_settings'];
+  $global_value = $form_state['values']['global_cck_blocks_settings'];
   variable_set('cck_blocks_' . $field_name . '_block_availability', $global_value);
-}
\ No newline at end of file
+}
