--- nodeblock.module	2009-04-01 05:12:10.000000000 +0200
+++ nodeblock-patched.module	2009-09-29 19:21:00.000000000 +0200
@@ -26,30 +26,66 @@ function nodeblock_form_alter(&$form, $f
       '#type' => 'radios',
       '#title' => t('Available as block'),
       '#default_value' => variable_get('nodeblock_'. $form['#node_type']->type, 0),
-      '#options' => array(0 => t('Disabled'), 1 => t('Enabled')),
+      '#options' => array(0 => t('Disabled'), 1 => t('Enabled'), 2 => t('Per node setting')),
       '#description' => t('Should these nodes be made available as blocks?'),
     );
+    $form['#submit'][] = 'nodeblock_node_type_submit';
   }
   // node add/edit form
   elseif (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
     $node = $form['#node'];
     // Add translation fallback field for nodeblock and translation enabled source nodes only
-    if (nodeblock_type_enabled($node->type) && module_exists('translation') && translation_supported_type($node->type) && empty($node->translation_source)) {
-      $form['nodeblock'] = array(
+    if (nodeblock_type_enabled($node->type)) {
+      $form_nodeblock = array(
         '#type' => 'fieldset',
-        '#title' => t('Block translation options'),
-        '#tree' => true,
+        '#title' => t('Node block'),
+        '#collapsible' => TRUE,
+        '#tree' => TRUE,
       );
-      $form['nodeblock']['translation_fallback'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Enable translation fallback?'),
-        '#description' => t('If checked, the source translation node will be used when a translation for the current language does not exist.  If unchecked, the block will not be displayed if a matching translation does not exist.'),
-        '#default_value' => $node->nodeblock_translation_fallback,
-      );
-    }
+      if (variable_get('nodeblock_'. $node->type, 0) == 2) {
+      	$nodeblock_nodes = variable_get('nodeblock_nodes', array());
+      	if (!$form['nodeblock']) {
+      		$form['nodeblock'] = $form_nodeblock;
+      	}
+	      $form['nodeblock']['settings'] = array(
+	        '#type' => 'checkbox',
+	        '#title' => t('Available as block'),
+	      );
+	      if ($node->nid) {
+	      	$form['nodeblock']['settings']['#default_value'] = $nodeblock_nodes[$node->nid];
+	      }
+	      $form['#submit'][] = 'nodeblock_node_submit';
+      }
+	    if (module_exists('translation') && translation_supported_type($node->type) && empty($node->translation_source)) {
+      	if (!$form['nodeblock']) {
+      		$form['nodeblock'] = $form_nodeblock;
+      	}
+	      $form['nodeblock']['translation_fallback'] = array(
+	        '#type' => 'checkbox',
+	        '#title' => t('Enable translation fallback?'),
+	        '#description' => t('If checked, the source translation node will be used when a translation for the current language does not exist.  If unchecked, the block will not be displayed if a matching translation does not exist.'),
+	        '#default_value' => $node->nodeblock_translation_fallback,
+	      );
+	    }
+		}
   }
 }
 
+function nodeblock_node_type_submit($form, &$form_state) {
+	if ($form_state['nodeblock']) {
+		_block_rehash();
+	}
+}
+
+function nodeblock_node_submit($form, &$form_state) {
+	if ($form_state['values']['nodeblock']['settings']) {		
+		$nodeblock_nodes = variable_get('nodeblock_nodes', array());
+		$nodeblock_nodes[$form_state['values']['nid']] = $form_state['values']['nodeblock']['settings'];
+		variable_set('nodeblock_nodes', $nodeblock_nodes);
+		_block_rehash();
+	}
+}
+
 /**
  * Implementation of hook_nodeapi().
  */
@@ -87,9 +123,12 @@ function nodeblock_nodeapi(&$node, $op, 
  */
 function nodeblock_block($op = 'list', $delta = 0, $edit = array()) {
   $types = node_get_types();
+  $nodeblock_nodes = variable_get('nodeblock_nodes', array());
+  $nodeblock_types = array();
+  
   if ($op == 'list') {
     foreach ($types as $type) {
-      if (nodeblock_type_enabled($type)) {
+      if (variable_get('nodeblock_'. $type->type, 0) == 1) {
         // Fetch all nodes of this type, excluding translations.
         $result = db_query('SELECT nid, title FROM {node} WHERE type = "%s" AND status = 1 AND (nid = tnid OR tnid = 0)', $type->type);
         while ($node = db_fetch_object($result)) {
@@ -97,8 +136,46 @@ function nodeblock_block($op = 'list', $
         }
       }
     }
+    if (!empty($nodeblock_nodes)) {
+    	$nodes = array();
+    	foreach ($nodeblock_nodes as $nid => $type) {
+    		if ($type) {
+    			$nodes[] = (int)$nid;
+    		}
+    	}
+    	if ($nodes) {
+    		$result = db_query('SELECT nid, title, type FROM {node} WHERE status = 1 AND nid IN (%s)', check_plain(implode(',', $nodes)));
+    	}
+      while ($node = db_fetch_object($result)) {
+        if (variable_get('nodeblock_'. $node->type, 0) == 2) {
+        	$blocks[$node->nid] = array('info' => $node->title .' (nodeblock)');
+        }
+      }
+    }
     return $blocks;
   }
+  
+  else if ($op == 'configure') {
+  	$form = array();
+    $form['nodeblock_type_'.$delta] = array(
+      '#type' => 'radios',
+      '#title' => t('Node display mode'),
+      '#default_value' => variable_get('nodeblock_type_'.$delta, 0),
+      '#options' => array(0 => t('Page'), 1 => t('Teaser')),
+    );
+    $form['nodeblock_links_'.$delta] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Show node links'),
+      '#default_value' => variable_get('nodeblock_links_'.$delta, 0),
+    );
+    return $form;
+  }
+  
+  else if ($op == 'save') {
+    variable_set('nodeblock_type_'.$delta, $edit['nodeblock_type_'.$delta]);
+    variable_set('nodeblock_links_'.$delta, $edit['nodeblock_links_'.$delta]);
+  }
+  
   elseif ($op == 'view') {
     $node = node_load($delta);
 
@@ -117,12 +194,15 @@ function nodeblock_block($op = 'list', $
       }
       // otherwise we just use the main node
     }
-
+    
+    $teaser = variable_get('nodeblock_type_'.$delta, 0);
+    $links = variable_get('nodeblock_links_'.$delta, 0);
+    
     // Set a flag so that themes have more context.
     $node->nodeblock = TRUE;
     
-    $block['subject'] = $node->title;
-    $block['content'] = node_view($node, FALSE, FALSE, TRUE);
+    $block['subject'] = l($node->title, 'node/'.$node->nid);
+    $block['content'] = node_view($node, $teaser, FALSE, $links);
 
     return $block;
   }
