summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2004-02-25 21:19:31 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2004-02-25 21:19:31 +0000
commite3bedc47d7097def2a1756ee74849bbc271e347b (patch)
treee8541044b9085bee004c34046d3f92fb5dfe30dc
parent939a816e8faf09c7eeb49b15e1d929f8532be630 (diff)
downloadbrdo-e3bedc47d7097def2a1756ee74849bbc271e347b.tar.gz
brdo-e3bedc47d7097def2a1756ee74849bbc271e347b.tar.bz2
Fixed an apparently old bug which always defaulted user-togglable blocks to off, and clarified the explanation a bit.
-rw-r--r--modules/block.module8
-rw-r--r--modules/block/block.module8
2 files changed, 12 insertions, 4 deletions
diff --git a/modules/block.module b/modules/block.module
index 6f4aa95ed..9734ea587 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -40,7 +40,7 @@ function block_help($section = "admin/help#block") {
$output = t("Controls the boxes that are displayed around the main content.");
break;
case 'admin/system/block':
- $output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <strong>active</strong> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%createblock" => url("admin/system/block/add"), "%throttle" => url("admin/system/modules/throttle")));
+ $output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <strong>active</strong> Drupal modules. The 'enabled' checkbox sets the default status of the block. Only enabled blocks are shown. When the 'custom' checkbox is checked, your users can show or hide the block using their account settings. In that case, the 'enabled' checkbox signifies the block's default status. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%createblock" => url("admin/system/block/add"), "%throttle" => url("admin/system/modules/throttle")));
break;
case 'admin/system/block/add':
$output = t("Here you can create a new block. Once you have created this block you must make it active, and give it a place on the page using <a href=\"%overview\">blocks</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">blocks</a> page. If you are going to place PHP code in the block, and you have <strong>create php content</strong> permission (see the <a href=\"%permission\">permissions</a> page) you <strong>must</strong> change the type to PHP to make your code active.", array("%overview" => url("admin/system/block"), "%permission" => url("admin/user/permission")));
@@ -323,7 +323,7 @@ function block_user($type, $edit, &$user) {
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
if ($data[$block->delta]["info"]) {
- $form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]);
+ $form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, isset($user->block[$block->module][$block->delta]) ? $user->block[$block->module][$block->delta] : $block->status);
}
}
@@ -362,6 +362,10 @@ function block_list($region) {
$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);
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)
+ if ($block['custom'] && $user->uid && !isset($user->block[$block['module']][$block['delta']])) {
+ $user->block[$block['module']][$block['delta']] = $block['status'];
+ }
if ((($block['status'] && (!$user->uid || !$block['custom'])) || ($block['custom'] && $user->block[$block['module']][$block['delta']])) && (!$block['path'] || preg_match($block['path'], "/" . $_GET["q"]))) {
/*
diff --git a/modules/block/block.module b/modules/block/block.module
index 6f4aa95ed..9734ea587 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -40,7 +40,7 @@ function block_help($section = "admin/help#block") {
$output = t("Controls the boxes that are displayed around the main content.");
break;
case 'admin/system/block':
- $output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <strong>active</strong> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%createblock" => url("admin/system/block/add"), "%throttle" => url("admin/system/modules/throttle")));
+ $output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <strong>active</strong> Drupal modules. The 'enabled' checkbox sets the default status of the block. Only enabled blocks are shown. When the 'custom' checkbox is checked, your users can show or hide the block using their account settings. In that case, the 'enabled' checkbox signifies the block's default status. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%createblock" => url("admin/system/block/add"), "%throttle" => url("admin/system/modules/throttle")));
break;
case 'admin/system/block/add':
$output = t("Here you can create a new block. Once you have created this block you must make it active, and give it a place on the page using <a href=\"%overview\">blocks</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">blocks</a> page. If you are going to place PHP code in the block, and you have <strong>create php content</strong> permission (see the <a href=\"%permission\">permissions</a> page) you <strong>must</strong> change the type to PHP to make your code active.", array("%overview" => url("admin/system/block"), "%permission" => url("admin/user/permission")));
@@ -323,7 +323,7 @@ function block_user($type, $edit, &$user) {
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
if ($data[$block->delta]["info"]) {
- $form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]);
+ $form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, isset($user->block[$block->module][$block->delta]) ? $user->block[$block->module][$block->delta] : $block->status);
}
}
@@ -362,6 +362,10 @@ function block_list($region) {
$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);
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)
+ if ($block['custom'] && $user->uid && !isset($user->block[$block['module']][$block['delta']])) {
+ $user->block[$block['module']][$block['delta']] = $block['status'];
+ }
if ((($block['status'] && (!$user->uid || !$block['custom'])) || ($block['custom'] && $user->block[$block['module']][$block['delta']])) && (!$block['path'] || preg_match($block['path'], "/" . $_GET["q"]))) {
/*