Index: multiblock.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/multiblock/multiblock.install,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 multiblock.install
--- multiblock.install	28 May 2008 21:31:12 -0000	1.1.2.2
+++ multiblock.install	18 Jan 2009 19:43:02 -0000
@@ -1,5 +1,10 @@
 <?php
 // $Id: multiblock.install,v 1.1.2.2 2008/05/28 21:31:12 andrewlevine Exp $
+/**
+ * @file
+ * The Multiblock module allows and admin to define multiple instances
+ * of blocks provided by other modules.
+ */
 
 function multiblock_install() {
   switch ($GLOBALS['db_type']) {
@@ -29,6 +34,7 @@
 }
 
 function multiblock_uninstall() {
+  variable_del('multiblock_blocked');
   db_query("DROP TABLE {multiblock}");
   if ($GLOBALS['db_type'] == 'pgsql') {
     db_query("DROP SEQUENCE {multiblock}_delta_seq}");
Index: multiblock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/multiblock/multiblock.module,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 multiblock.module
--- multiblock.module	18 Jan 2009 16:25:22 -0000	1.1.2.12
+++ multiblock.module	18 Jan 2009 20:55:50 -0000
@@ -1,5 +1,10 @@
 <?php
 // $Id: multiblock.module,v 1.1.2.12 2009/01/18 16:25:22 nancyw Exp $
+/**
+ * @file
+ * The Multiblock module allows and admin to define multiple instances
+ * of blocks provided by other modules.
+ */
 
 /**
  * Implementation of hook_menu().
@@ -8,14 +13,24 @@
   $items = array();
   if ($may_cache) {
     $items[] = array(
-        'path' => 'admin/build/block/instances',
-        'title' => t('Instances'),
-        'description' => t('Create and delete instances of blocks.'),
-        'callback' =>  'multiblock_general',
-        'access' => user_access('administer blocks'),
-        'type' => MENU_LOCAL_TASK,
-        'weight' => -1,
-    );
+      'path' => 'admin/build/block/instances',
+      'title' => t('Instances'),
+      'description' => t('Create and delete instances of blocks.'),
+      'callback' =>  'multiblock_general',
+      'access' => user_access('administer blocks'),
+      'type' => MENU_LOCAL_TASK,
+      'weight' => -1,
+      );
+    $items[] = array(
+      'path' => 'admin/build/block/blocked_modules',
+      'title' => 'Blocked Modules',
+      'description' => t('Block modules from instance creation.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' =>  array('multiblock_blocked_modules'),
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_LOCAL_TASK,
+      'weight' => 3,
+      );
     $items[] = array(
       'path' => 'admin/build/block/instances/delete',
       'title' => t('Delete Block Instance'),
@@ -23,7 +38,7 @@
       'callback arguments' => array('multiblock_delete_form'),
       'access' => user_access('administer blocks'),
       'type' => MENU_CALLBACK,
-    );
+      );
   }
   return $items;
 }
@@ -32,19 +47,23 @@
  * Implementation of hook_block().
  */
 function multiblock_block($op = 'list', $delta = 0, $edit = array()) {
-  if ($op == 'list') {
-    // Get all of the block instances that exist.
-    $blocks = multiblock_get_block(NULL);
-    $list = array();
-    foreach ($blocks as $block) {
-      $list[$block->delta] = array('info' => $block->title);
-    }
-    return $list;
-  }
-  // Any op besides list we want to dispatch the call to its respective module.
-  else if ($op == 'view' || $op == 'configure' || $op == 'save') {
-    return multiblock_call_block($delta, $op, $edit);
-  }
+  switch ($op) {
+    case 'mb_blocked':
+      return 'multiblock';
+
+    case 'list':
+      // Get all of the block instances that exist.
+      $blocks = multiblock_get_block(NULL);
+      $list = array();
+      foreach ($blocks as $block) {
+        $list[$block->delta] = array('info' => $block->title);
+      }
+      return $list;
+
+    // Any op besides list we want to dispatch the call to its respective module.
+    default:
+      return multiblock_call_block($delta, $op, $edit);
+  }  
 }
 
 /**
@@ -134,26 +153,30 @@
   else {
     // Turn $blocks into form options of block types.
     // Remember we need the module and delta to be able to tell what kind of
-    // blocks we're talking about. 
+    // blocks we're talking about.
+    $blocked_modules = variable_get('multiblock_blocked', array('multiblock'));
+    $auto_blocked = module_invoke_all('block', 'mb_blocked');
+    $blocked_modules = array_unique(array_merge($blocked_modules, $auto_blocked));
+
     $options = array();
     foreach ($blocks as $block) {
       // Don't include multiblock module blocks in the list.
-      if ($block['module'] != 'multiblock') {
+      if (!in_array(strtolower($block['module']), $blocked_modules)) {
         $options[$block['module'] .'***MB***'. $block['delta']] = $block['info'];
       }
     }
-  
+
     $form['block'] = array(
       '#type' => 'select',
       '#title' => t('Block type'),
       '#options' => $options,
       '#required' => TRUE,
-    );
+      );
   }
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save'),
-  );
+    );
   return $form;
 }
 
@@ -316,3 +339,43 @@
   
   return $output;
 }
+
+/**
+ * Build a blocked modules list to prevent instance creation.
+ */
+function multiblock_blocked_modules() {
+  $form = array();
+  $current = variable_get('multiblock_blocked', array('multiblock'));
+  $x = array_keys($current, 'multiblock');
+  unset ($current[$x[0]]);
+
+  $form['blocked'] = array(
+    '#type' => 'textarea',
+    '#rows' => 10,
+    '#description' => t('Add modules, one per line, that will not be shown in the "Add Instance" list.'),
+    '#default_value' => implode("\n", $current),
+    );
+
+  $auto_blocked = module_invoke_all('block', 'mb_blocked');
+  if ($auto_blocked) {
+    $form['blocked']['#description'] .= '<br />'. t('Note: The following modules are automatically blocked: @auto', array('@auto' => implode(', ', $auto_blocked)));
+  }
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+    );
+  return $form;
+}
+
+/**
+ * Process the blocked modules list.
+ */
+function multiblock_blocked_modules_submit($form_id, $form_values) {
+  $blocked = preg_split('/(\r\n?|\n)/', $form_values['blocked']);
+  $blocked[] = 'multiblock';
+  // Remove duplicates, empty lines, and excess spaces.
+  $blocked = array_map('trim', array_filter(array_unique($blocked)));
+  variable_set('multiblock_blocked', $blocked);
+  drupal_set_message(t('Configuration saved'), 'status');
+}

