--- modules/block.module 2004-10-26 17:17:36.000000000 -0700 +++ modules/block.module.syg 2004-10-26 17:17:32.000000000 -0700 @@ -14,7 +14,7 @@ function block_help($section) { case 'admin/help#block': return t("

Blocks are the boxes visible in the sidebar(s) of your web site. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks.

-

The sidebar each block appears in depends on both which theme you're using (some are left-only, some right, some both), and on the settings in block management.

Whether a block is visible in the first place depends on four things:

+

The sidebar each block appears in depends on both which theme you're using (some are left-only, some right, some both), and on the settings in block management.

Whether a block is visible in the first place depends on four things:

The block management screen also lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a weight to each block. Lighter blocks (smaller weight) \"float up\" towards the top of the sidebar. Heavier ones \"sink down\" towards the bottom of it.

The path setting lets you define the pages on which a specific block is visible. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters! The path expression is matched against the relative URL of a Drupal page, e.g. book, node/12, admin.

In case you do not know what a regular expression is, you should read about them in the PHP manual. The chapter to look at is the one on Perl-Compatible Regular Expressions (PCRE).

@@ -94,8 +94,8 @@ function block_block($op = 'list', $delt function block_admin_save($edit) { foreach ($edit as $module => $blocks) { foreach ($blocks as $delta => $block) { - db_query("UPDATE {blocks} SET region = %d, status = %d, custom = %d, path = '%s', weight = %d, throttle = %d WHERE module = '%s' AND delta = '%s'", - $block['region'], $block['status'], $block['custom'], $block['path'], $block['weight'], $block['throttle'], $module, $delta); + db_query("UPDATE {blocks} SET region = %d, status = %d, custom = %d, hidden = %d, path = '%s', weight = %d, throttle = %d WHERE module = '%s' AND delta = '%s'", + $block['region'], $block['status'], $block['custom'], $block['hidden'], $block['path'], $block['weight'], $block['throttle'], $module, $delta); } } @@ -132,16 +132,17 @@ function _block_rehash($order_by = array $block['region'] = $old_blocks[$module][$delta]->region; $block['path'] = $old_blocks[$module][$delta]->path; $block['custom'] = $old_blocks[$module][$delta]->custom; + $block['hidden'] = $old_blocks[$module][$delta]->hidden; $block['throttle'] = $old_blocks[$module][$delta]->throttle; } else { - $block['status'] = $block['weight'] = $block['region'] = $block['custom'] = 0; + $block['status'] = $block['weight'] = $block['region'] = $block['custom'] = $block['hidden'] = 0; $block['path'] = ''; } // reinsert blocks into table - db_query("INSERT INTO {blocks} (module, delta, status, weight, region, path, custom, throttle) VALUES ('%s', '%s', %d, %d, %d, '%s', %d, %d)", - $block['module'], $block['delta'], $block['status'], $block['weight'], $block['region'], $block['path'], $block['custom'], $block['throttle']); + db_query("INSERT INTO {blocks} (module, delta, status, weight, region, path, custom, hidden, throttle) VALUES ('%s', '%s', %d, %d, %d, '%s', %d, %d, %d)", + $block['module'], $block['delta'], $block['status'], $block['weight'], $block['region'], $block['path'], $block['custom'], $block['hidden'], $block['throttle']); $blocks[] = $block; @@ -171,7 +172,7 @@ function block_admin_display() { $formats[$box->bid] = $box->format; } - $header = array(t('Block'), t('Enabled'), t('Custom'), t('Throttle'), t('Weight'), t('Region'), t('Path'), array('data' => t('Operations'))); + $header = array(t('Block'), t('Enabled'), t('Custom'), t('Hidden'), t('Throttle'), t('Weight'), t('Region'), t('Path'), array('data' => t('Operations'))); foreach ($blocks as $block) { if ($block['module'] == 'block' && filter_access($formats[$block['delta']])) { @@ -181,7 +182,7 @@ function block_admin_display() { $edit = ''; } - $rows[] = array($block['info'], array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][custom', 1, $block['custom']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle'], NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled')), 'align' => 'center'), form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']), form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], array(t('left'), t('right'))), form_textfield(NULL, $block['module'] .']['. $block['delta'] .'][path', $block['path'], 10, 255), $edit); + $rows[] = array($block['info'], array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][custom', 1, $block['custom']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][hidden', 1, $block['hidden']), 'align' => 'center'), array('data' => form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle'], NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled')), 'align' => 'center'), form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']), form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], array(t('left'), t('right'))), form_textfield(NULL, $block['module'] .']['. $block['delta'] .'][path', $block['path'], 10, 255), $edit); } $output = theme('table', $header, $rows); @@ -333,7 +334,11 @@ function block_list($region) { if (!isset($blocks[$region])) { $blocks[$region] = array(); - $result = db_query('SELECT * FROM {blocks} WHERE (status = 1 OR custom = 1) '. ($region != 'all' ? 'AND region = %d ' : '') .'ORDER BY weight, module', $region == 'left' ? 0 : 1); + if ($user->uid != '0') { + $result = db_query('SELECT * FROM {blocks} WHERE (status = 1 OR custom = 1) '. ($region != 'all' ? 'AND region = %d ' : '') .'ORDER BY weight, module', $region == 'left' ? 0 : 1); + } else { + $result = db_query('SELECT * FROM {blocks} WHERE (status = 1 OR custom = 1) AND hidden = 0 '. ($region != 'all' ? 'AND region = %d ' : '') .'ORDER BY weight, module', $region == 'left' ? 0 : 1); + } while ($result && ($block = db_fetch_array($result))) { // When the user's account setting is empty, we use the block's regular 'status' (which is the default) --- database/database.mysql 2004-10-18 11:35:19.000000000 -0700 +++ database/database.mysql.syg 2004-10-26 17:21:31.000000000 -0700 @@ -123,6 +123,7 @@ region tinyint(1) DEFAULT '0' NOT NULL, path varchar(255) DEFAULT '' NOT NULL, custom tinyint(2) DEFAULT '0' NOT NULL, + hidden tinyint(2) DEFAULT '0' NOT NULL, throttle tinyint(1) DEFAULT '0' NOT NULL ) TYPE=MyISAM; --- database/database.pgsql 2004-10-18 11:35:19.000000000 -0700 +++ database/database.pgsql.syg 2004-10-26 17:22:02.000000000 -0700 @@ -50,6 +50,7 @@ status smallint NOT NULL default '0', weight smallint NOT NULL default '0', region smallint NOT NULL default '0', + hidden smallint NOT NULL default '0', path varchar(255) NOT NULL default '', custom smallint NOT NULL default '0', throttle smallint NOT NULL default '0' --- database/updates.inc 2004-10-19 13:00:06.000000000 -0700 +++ database/updates.inc.syg 2004-10-26 17:25:50.000000000 -0700 @@ -1921,6 +1921,13 @@ function update_109() { return $ret; } +function update_110() { + $ret = array(); + // updates the blocks table to add the new hidden row + $ret[] = update_sql("ALTER TABLE `blocks` ADD `hidden` TINYINT( 2 ) DEFAULT '0' NOT NULL "); + + return $ret; +} function update_sql($sql) { $edit = $_POST["edit"];