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 29 May 2008 20:03:15 -0000 @@ -1,37 +1,72 @@ t('Table for storing information about block instances used by the multiblock module.'), + 'fields' => array( + 'delta' => array( + 'description' => t('Unique key for each created block instance.'), + 'type' => 'serial', + 'not null' => TRUE, + ), + 'title' => array( + 'description' => t('The title used to display a block instance in the instance administration.'), + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'module' => array( + 'description' => t('The name of the module that provided the original block.'), + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'orig_delta' => array( + 'description' => t('The delta of the original block.'), + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '0', + ), + 'multi_settings' => array( + 'description' => t('Boolean flag that stores if the original module has multiblock support for multiple instance of this block.'), + 'type' => 'int', + 'size' => 'tiny', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('delta'), + ); + + return $schema; +} + function multiblock_install() { - switch ($GLOBALS['db_type']) { - case 'pgsql': - db_query("CREATE TABLE {multiblock} ( - delta int_unsigned NOT NULL default '1', - title varchar(64) NOT NULL default '', - module varchar(64) NOT NULL default '', - orig_delta varchar(32) NOT NULL default '', - multi_settings int_unsigned NOT NULL default '0', - PRIMARY KEY (delta) - )"); - db_query("CREATE SEQUENCE {multiblock}_delta_seq INCREMENT 1 START 1;"); - break; - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {multiblock} ( - delta int(11) UNSIGNED NOT NULL DEFAULT '1', - title varchar(64) NOT NULL , - module varchar(64) NOT NULL , - orig_delta varchar(32) NOT NULL , - multi_settings int(10) NOT NULL DEFAULT '0', - PRIMARY KEY (delta) - )"); - break; - } + drupal_install_schema('multiblock'); } function multiblock_uninstall() { - db_query("DROP TABLE {multiblock}"); - if ($GLOBALS['db_type'] == 'pgsql') { - db_query("DROP SEQUENCE {multiblock}_delta_seq}"); - } + drupal_uninstall_schema('multiblock'); } +/** + * Upgrade to Drupal 6. + */ +function multiblock_update_6100() { + $ret = array(); + // Keys must be dropped before altering the column. + db_drop_primary_key($ret, 'multiblock'); + // Alter to add primary key with auto-increment. + db_change_field($ret, 'multiblock', 'delta', 'delta', array('type' => 'serial', 'not null' => TRUE), array('primary key' => array('delta'))); + + // Reduce the size of the multi_settings flag column. + db_change_field($ret, 'multiblock', 'multi_settings', 'multi_settings', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); + return $ret; +} Index: multiblock.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/multiblock/multiblock.module,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 multiblock.module --- multiblock.module 29 May 2008 19:57:16 -0000 1.1.2.5 +++ multiblock.module 29 May 2008 20:03:15 -0000 @@ -4,27 +4,25 @@ /** * Implementation of hook_menu(). */ -function multiblock_menu($may_cache) { +function multiblock_menu() { $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, - ); - $items[] = array( - 'path' => 'admin/build/block/instances/delete', - 'title' => t('Delete Block Instance'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('multiblock_delete_form'), - 'access' => user_access('administer blocks'), - 'type' => MENU_CALLBACK, - ); - } + $items['admin/build/block/instances'] = array( + 'title' => 'Instances', + 'description' => t('Create and delete instances of blocks.'), + 'page callback' => 'multiblock_general', + 'access callback' => 'user_access', + 'access arguments' => array('administer blocks'), + 'type' => MENU_LOCAL_TASK, + 'weight' => -1, + ); + $items['admin/build/block/instances/delete'] = array( + 'title' => 'Delete Block Instance', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('multiblock_delete_form'), + 'access callback' => 'user_access', + 'access arguments' => array('administer blocks'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -111,7 +109,7 @@ /** * "Add Instance" form. */ -function multiblock_add_form($blocks) { +function multiblock_add_form($form_state, $blocks) { $form = array(); $form['title'] = array( '#type' => 'textfield', @@ -144,7 +142,7 @@ return $form; } -function multiblock_delete_form($delta) { +function multiblock_delete_form($form_state, $delta) { $block = multiblock_get_block($delta); if (empty($block)) { @@ -160,14 +158,14 @@ t('Delete'), t('Cancel')); } -function multiblock_delete_form_submit($form_id, $form_values) { - if (multiblock_delete($form_values['delta'])) { +function multiblock_delete_form_submit($form, &$form_state) { + if (multiblock_delete($form_state['values']['delta'])) { drupal_set_message(t('Block successfully deleted!')); } else { drupal_set_message(t('There was a problem deleting the block')); } - return 'admin/build/block/instances'; + $form_state['redirect'] = 'admin/build/block/instances'; } @@ -183,12 +181,11 @@ */ function multiblock_add($original_block, $block_instance) { // Create new delta for block instance. - $delta = db_next_id('{multiblock}_delta'); $sql = "INSERT INTO {multiblock} - (delta, title, module, orig_delta, multi_settings) - VALUES (%d, '%s', '%s', '%s', %d)"; - db_query($sql, $delta, $block_instance->title, $original_block->module, $original_block->delta, $block_instance->mb_enbabled); - return $delta; + (title, module, orig_delta, multi_settings) + VALUES ('%s', '%s', '%s', %d)"; + $result = db_query($sql, $block_instance->title, $original_block->module, $original_block->delta, $block_instance->mb_enbabled); + return db_last_insert_id('multiblock', 'delta'); } /** @@ -208,14 +205,14 @@ /** * Validate "Add Block Instance" form. */ -function multiblock_add_form_validate($form_id, $form_values) { +function multiblock_add_form_validate($form, &$form_state) { // Make sure we are getting a valid block to add. - if (!preg_match('/^.+\*\*\*MB\*\*\*.+$/', $form_values['block'])) { + if (!preg_match('/^.+\*\*\*MB\*\*\*.+$/', $form_state['values']['block'])) { form_set_error('block', t('Bad block module input, contact administrator')); return; } // Make sure the block and delta exist. - $orig_block = multiblock_blockinfo_from_form($form_values['block']); + $orig_block = multiblock_blockinfo_from_form($form_state['values']['block']); if (!module_hook($orig_block['module'], 'block') || !array_key_exists($orig_block['delta'], module_invoke($orig_block['module'], 'block', 'list'))) { form_set_error('block', t('Module or doesn\t exist, contact administrator')); @@ -225,17 +222,17 @@ /** * Add block instance to database from "Add Block Instance" form. */ -function multiblock_add_form_submit($form_id, $form_values) { +function multiblock_add_form_submit($form, &$form_state) { // Get the original block info. - $orig_block = multiblock_blockinfo_from_form($form_values['block']); + $orig_block = multiblock_blockinfo_from_form($form_state['values']['block']); // Check whether this module is multiblock enabled. - $mb_enabled = (int) module_invoke($orig_block['module'], 'block', 'mb_enabled') == 'mb_enabled'; + $mb_enabled = (int) module_invoke($orig_block->module, 'block', 'mb_enabled') == 'mb_enabled'; // Create block instance information. $orig_block = (object) $orig_block; - $instance = (object) array('title' => $form_values['title'], 'mb_enabled' => $mb_enabled); + $instance = (object) array('title' => $form_state['values']['title'], 'mb_enabled' => $mb_enabled); // Add the block instance. multiblock_add($orig_block, $instance); - drupal_set_message(t('Block instance %instance created.', array('%instance' => $form_values['title']))); + drupal_set_message(t('Block instance %instance created.', array('%instance' => $form_state['values']['title']))); } /** @@ -263,6 +260,17 @@ } /** + * Implementation of hook_theme(). + */ +function multiblock_theme() { + return array( + 'multiblock_general' => array( + 'arguments' => array('add_block_form' => NULL, 'multiblocks' => NULL), + ), + ); +} + +/** * Theme function for the "Manage Block Instances" page. */ function theme_multiblock_general($add_block_form, $multiblocks) { Index: multiblock.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/multiblock/multiblock.info,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 multiblock.info --- multiblock.info 29 Feb 2008 20:44:26 -0000 1.1.2.1 +++ multiblock.info 29 May 2008 20:03:14 -0000 @@ -1,2 +1,3 @@ name = MultiBlock description = Allows the creation of multiple instances of blocks +core = 6.x