Index: related_block.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/related_block/related_block.module,v
retrieving revision 1.3
diff -u -p -r1.3 related_block.module
--- related_block.module	28 Oct 2007 21:29:23 -0000	1.3
+++ related_block.module	15 Nov 2007 14:42:10 -0000
@@ -6,7 +6,10 @@
  *
  * Generates a block with links for the current node.
  */
-function related_block_block($op = 'list', $delta = 0) {
+function related_block_block($op = 'list', $delta = 0,  $edit = array()) {
+  $node_types = node_get_types('names');
+  $related_types = variable_get("related_block_types", array());
+
   switch ($op) {
     case 'list':
       $blocks[0]['info'] = t('Similar Block');
@@ -14,8 +17,8 @@ function related_block_block($op = 'list
     case 'view':
       if ((arg(0) == 'node') && is_numeric(arg(1))) {
         $node = node_load(arg(1));
-        $types = variable_get("related_block_types", node_get_types('names') );
-        if (array_key_exists($node->type, $types)) {
+
+        if (array_key_exists($node->type, $related_types)) {
           // Here's where we generate the similar articles
           
           $nodes = _related_block_search( $node->title, $node->body, $node->nid );
@@ -23,20 +26,17 @@ function related_block_block($op = 'list
           if (!empty($nodes)) {
             $block['subject'] = t('Related Nodes');
             $block['content'] = theme( 'related_block_block', $node, $nodes );
-            
             return $block;
           }
         }
       }
       break;
     case 'configure':
-      $types = node_get_types('names');
-      
       $form['related_block_types'] = array(
         '#type'          => 'checkboxes',
         '#title'         => t('Display On'),
-        '#default_value' => variable_get('related_block_types', $types),
-        '#options'       => $types,
+        '#default_value' => array_keys($related_types),
+        '#options'       => $node_types,
         '#description'   => t('Select to which content type the block will be displayed.')
       );
 
@@ -49,16 +49,20 @@ function related_block_block($op = 'list
       );
 
       return $form;
+      break;
     case 'save':
-        $types = array_keys($_POST['related_block_types']);
-        variable_set('related_block_types', $types);
 
-        $count = $_POST['related_block_count'];
-        if (is_numeric($count)) 
-          variable_set('related_block_count', $count);
+      $save_types = array();
+      foreach (array_filter(array_values($edit['related_block_types'])) as $key) { $save_types[$key] = $node_types[$key]; }
+      variable_set('related_block_types', $save_types);
+
+      $count = $edit['related_block_count'];
+      if (is_numeric($count)) {
+        variable_set('related_block_count', $count);
+      }
       break;
-  }
-}
+  } // switch
+} // hook_block
 
 function theme_related_block_block( $node, $nodes ) {
   $output = "<div class='similar-block'>";
