#P block_assign
Index: block_assign.info
===================================================================
RCS file: /cvs/drupal/contributions/modules/block_assign/block_assign.info,v
retrieving revision 1.1
diff -u -r1.1 block_assign.info
--- block_assign.info	4 Jul 2007 17:37:56 -0000	1.1
+++ block_assign.info	6 Jan 2009 10:57:10 -0000
@@ -1,3 +1,4 @@
-; $Id: block_assign.info,v 1.1 2007/07/04 17:37:56 daryl Exp $
+; $Id: block_assign.info,v 1.2 2007/07/04 17:37:56 daryl Exp $
 name = Block Assign
 description = "Provides a more flexible way of managing what blocks are displayed on what pages"
+core = 6.x
\ No newline at end of file
Index: block_assign.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/block_assign/block_assign.module,v
retrieving revision 1.5
diff -u -r1.5 block_assign.module
--- block_assign.module	5 Feb 2008 13:00:45 -0000	1.5
+++ block_assign.module	6 Jan 2009 10:57:10 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: block_assign.module,v 1.5 2008/02/05 13:00:45 daryl Exp $
+// $Id: block_assign.module,v 1.6 2008/02/05 13:00:45 daryl Exp $
 
 /**
  * @file
@@ -13,11 +13,9 @@
  * @param section which section of the site we're displaying help
  * @return help text for section
  */
-function block_assign_help($section='') {
-
+function block_assign_help($path, $arg) {
   $output = '';
-
-  switch ($section = '') {
+  switch ($path) {
     case "admin/help#block_assign":
       $output = '<p>'. t("") .'</p>';
       break;
@@ -29,59 +27,53 @@
   return $output;
 }
 
-function block_assign_block_admin_submit($form_id, $form_values) {
-    if (function_exists('block_assign_show')) {
-      $sql = 'UPDATE blocks SET visibility = 2, pages = CONCAT("<", "?", "php ", "if (function_exists(\'block_assign_show\')) { return block_assign_show(\'", module, "\',\'", delta, "\'); }", "?", ">") WHERE status=1 AND theme=\'%s\'';
-      db_query($sql, variable_get('theme_default', 'garland'));
-  }
-}
-
-function block_assign_form_alter($form_id, &$form) {
-  if ($form_id == 'block_admin_display') {
-    $form['#submit']['block_assign_block_admin_submit'] = array();
-  }
-  elseif ($form_id == 'block_admin_configure') {
-    $module = arg(4);
-    $delta = arg(5);
-    $form['page_vis_settings']['visibility']['#disabled'] = TRUE;
-    $form['page_vis_settings']['pages']['#disabled'] = TRUE;
-    $form['page_vis_settings']['#description'] = t('Page specific visibility is being handled by your <strong>block_assign_show()</strong> function.');
-    $form['#submit']['block_assign_block_admin_submit'] = array();
-  }
-}
-
-
-function block_assign_menu($may_cache) {
-  $items[] = array(
-    'path' => 'admin/settings/block_assign',
+function block_assign_menu() {
+  $items['admin/settings/block_assign'] = array(
     'title' => t('Block Assign Settings'),
-    'callback' => 'block_assign_admin',
-    /*'callback' => 'drupal_get_form',
-    'callback arguments' => 'block_assign_admin',*/
-    'access' => user_access('access administration pages'),
+    'page callback' => 'block_assign_admin',
+	'access arguments' => array('access administration pages'),
     'type' => MENU_NORMAL_ITEM,
   );
-
   $arg = intval(arg(3));
   if ($arg > 0) {
-    $items[] = array(
-      'path' => 'admin/settings/block_assign/'. $arg,
+    $items['admin/settings/block_assign/%block_assign'] = array(
       'title' => t('Edit Block Assignment'),
-      'callback' => 'block_assign_admin',
-      'access' => user_access('access administration pages')
+      'page callback' => 'block_assign_admin',
+	  'access arguments' => array('access administration pages'),
     );
   }
 
-  $items[] = array(
-    'path' => 'admin/build/block/visibility',
+  $items['admin/build/block/visibility'] = array(
     'title' => t('Page Visibility'),
-    'callback' => 'block_assign_admin',
-    'access' => user_access('access administration pages'),
+    'page callback' => 'block_assign_admin',
+	'access arguments' => array('access administration pages'),
     'type' => MENU_LOCAL_TASK,
   ); 
   return $items;
 }
 
+function block_assign_block_admin_submit($form, &$form_state) {
+  if (function_exists('block_assign_show')) {
+      $sql = 'UPDATE blocks SET visibility = 2, pages = CONCAT("<", "?", "php ", "if (function_exists(\'block_assign_show\')) { return block_assign_show(\'", module, "\',\'", delta, "\'); }", "?", ">") WHERE status=1 AND theme=\'%s\'';
+	  db_query($sql, variable_get('theme_default', 'garland'));
+  }
+}
+
+function block_assign_form_alter(&$form, $form_state, $form_id) {
+  // not sure why the form_id has the _form on it? In drupal 5, the form_id was simply block_admin_display
+  if ($form_id == 'block_admin_display_form') {
+    $form['#submit'][] = 'block_assign_block_admin_submit';	
+  }
+  elseif ($form_id == 'block_admin_configure') {
+    $module = arg(4);
+    $delta  = arg(5);
+    $form['page_vis_settings']['visibility']['#disabled'] = TRUE;
+    $form['page_vis_settings']['pages']['#disabled'] = TRUE;
+    $form['page_vis_settings']['#description'] = t('Page specific visibility is being handled by your <strong>block_assign_show()</strong> function.');
+    $form['#submit'][] = 'block_assign_block_admin_submit';
+  }
+}
+
 function block_assign_edit_form() {
   $id = intval(arg(3));
   $form = array();
@@ -271,7 +263,6 @@
           $titles[$row->module .'_'. $k] = $v['info'];
         }
       }
-
       foreach ($blocks as $row) {
         if ($sep != $row->sep) {
           $data[] = array('<strong>Type '. $row->type .' for value '. $row->value .'</strong>', '', '', '');
@@ -331,5 +322,4 @@
   }
 
   return false;
-}
-
+}
\ No newline at end of file
Index: block_assign.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/block_assign/block_assign.install,v
retrieving revision 1.4
diff -u -r1.4 block_assign.install
--- block_assign.install	6 Feb 2008 12:59:17 -0000	1.4
+++ block_assign.install	6 Jan 2009 10:57:10 -0000
@@ -1,23 +1,59 @@
 <?php
-// $Id: block_assign.install,v 1.4 2008/02/06 12:59:17 daryl Exp $
+// $Id: block_assign.install,v 1.5 2008/02/06 12:59:17 daryl Exp $
 
+/**
+ * Implementation of hook_schema().
+ */
+function block_assign_schema() {
+  $schema['block_assign'] = array(
+    'description' => t('Stores block assignments.'),
+    'fields' => array(
+      'id' => array(
+        'description' => t('Primary Key'),
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'module' => array(
+        'description' => t('Module'),
+        'type' => 'varchar',
+		'length' => 30,
+        'not null' => FALSE,
+        'default' => NULL),
+      'condition_type' => array(
+        'description' => t('Type of condition.'),
+        'type' => 'varchar',
+        'length' => 4,
+        'not null' => FALSE,
+        'default' => NULL),
+	  'condition_value' => array(
+        'description' => t('Value of condition.'),
+        'type' => 'text'),
+	  'box_id' => array(
+        'description' => t('Id of the box.'),
+        'type' => 'int',
+		'not null' => FALSE,
+        'default' => NULL),
+    ),
+	'primary key' => array('id'),
+  );
+  return $schema;
+}
+
+/**
+ * Implementation of hook_install().
+ */
 function block_assign_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-  db_query('
-    CREATE TABLE `{block_assign}` (
-        `id` int(10) unsigned zerofill NOT NULL auto_increment,
-        `module` varchar(30) default NULL,
-        `condition_type` varchar(4) default NULL,
-        `condition_value` text,
-        `box_id` int(3) default NULL,
-        PRIMARY KEY  (`id`)
-      ) ENGINE=MyISAM DEFAULT CHARSET=latin1
-  ');
+  drupal_install_schema('block_assign');
+  
   //By default, show the user block on all pages.
   db_query('
     INSERT INTO {block_assign} (module, condition_type, condition_value, box_id) VALUES("user", "uri", ".*", 1)
   ');
-  }
 }
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function image_uninstall() {
+  drupal_uninstall_schema('block_assign');
+}
\ No newline at end of file