Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.90 diff -u -p -r1.90 block.admin.inc --- modules/block/block.admin.inc 10 Oct 2010 20:11:21 -0000 1.90 +++ modules/block/block.admin.inc 23 Oct 2010 03:19:04 -0000 @@ -286,11 +286,12 @@ function block_admin_configure($form, &$ '#type' => 'fieldset', '#title' => t('Region settings'), '#collapsible' => FALSE, - '#description' => t('Specify in which themes and regions this block is displayed.'), + '#description' => t('Specify where this block is displayed.'), '#tree' => TRUE, ); $theme_default = variable_get('theme_default', 'bartik'); + $admin_theme = variable_get('admin_theme'); foreach (list_themes() as $key => $theme) { // Only display enabled themes if ($theme->status) { @@ -300,9 +301,18 @@ function block_admin_configure($form, &$ ':theme' => $key, ))->fetchField(); + // Use a meaningful title for the main site theme and administrative + // theme. + $theme_title = $theme->info['name']; + if ($key == $theme_default) { + $theme_title = t('!theme (default theme)', array('!theme' => $theme_title)); + } + elseif ($admin_theme && $key == $admin_theme) { + $theme_title = t('!theme (administration theme)', array('!theme' => $theme_title)); + } $form['regions'][$key] = array( '#type' => 'select', - '#title' => $theme->info['name'], + '#title' => $theme_title, '#default_value' => !empty($region) && $region != -1 ? $region : NULL, '#empty_value' => BLOCK_REGION_NONE, '#options' => system_region_list($key, REGIONS_VISIBLE), Index: modules/block/block.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.api.php,v retrieving revision 1.13 diff -u -p -r1.13 block.api.php --- modules/block/block.api.php 13 Aug 2010 12:25:14 -0000 1.13 +++ modules/block/block.api.php 23 Oct 2010 03:19:04 -0000 @@ -57,6 +57,7 @@ * - DRUPAL_CACHE_GLOBAL: The block is the same for every user on every * page where it is visible. * - DRUPAL_NO_CACHE: The block should not get cached. + * - 'properties': (optional) @todo: Document me! * - 'weight': (optional) Initial value for the ordering weight of this block. * Most modules do not provide an initial value, and any value provided can * be modified by a user on the block configuration screen. Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.906 diff -u -p -r1.906 comment.module --- modules/comment/comment.module 20 Oct 2010 01:31:06 -0000 1.906 +++ modules/comment/comment.module 23 Oct 2010 03:19:04 -0000 @@ -402,6 +402,7 @@ function comment_permission() { */ function comment_block_info() { $blocks['recent']['info'] = t('Recent comments'); + $blocks['recent']['properties']['administrative'] = TRUE; return $blocks; } Index: modules/dashboard/dashboard.module =================================================================== RCS file: /cvs/drupal/drupal/modules/dashboard/dashboard.module,v retrieving revision 1.40 diff -u -p -r1.40 dashboard.module --- modules/dashboard/dashboard.module 21 Oct 2010 11:55:08 -0000 1.40 +++ modules/dashboard/dashboard.module 23 Oct 2010 03:19:04 -0000 @@ -90,6 +90,25 @@ function dashboard_permission() { } /** + * Implements hook_block_info_alter(). + */ +function dashboard_block_info_alter(&$blocks, $theme, $code_blocks) { + $admin_theme = variable_get('admin_theme'); + if (($admin_theme && $theme == $admin_theme) || (!$admin_theme && $theme == variable_get('theme_default'))) { + foreach ($blocks as $module => &$module_blocks) { + foreach ($module_blocks as $delta => &$block) { + // Make administrative blocks that are not already in use elsewhere + // available for the dashboard. + if (empty($block['status']) && (empty($block['region']) || $block['region'] == BLOCK_REGION_NONE) && !empty($code_blocks[$module][$delta]['properties']['administrative'])) { + $block['status'] = 1; + $block['region'] = 'dashboard_hidden'; + } + } + } + } +} + +/** * Implements hook_block_list_alter(). * * Skip rendering dashboard blocks when not on the dashboard page itself. This @@ -121,6 +140,10 @@ function dashboard_page_build(&$page) { // region into it. $page['content']['dashboard'] = array('#theme_wrappers' => array('dashboard')); foreach (dashboard_regions() as $region) { + // Do not show dashboard blocks that are disabled. + if ($region == 'dashboard_hidden') { + continue; + } // Insert regions even when they are empty, so that they will be // displayed when the dashboard is being configured. $page['content']['dashboard'][$region] = !empty($page[$region]) ? $page[$region] : array(); @@ -177,7 +200,15 @@ function dashboard_page_build(&$page) { */ function dashboard_system_info_alter(&$info, $file, $type) { if ($type == 'theme') { - $info['regions'] += dashboard_region_descriptions(); + // Add the dashboard regions (the "hidden" region should always appear last + // in the list, for usability reasons). + $dashboard_regions = dashboard_region_descriptions(); + if (isset($dashboard_regions['dashboard_hidden'])) { + $hidden_region = $dashboard_regions['dashboard_hidden']; + unset($dashboard_regions['dashboard_hidden']); + $dashboard_regions['dashboard_hidden'] = $hidden_region; + } + $info['regions'] += $dashboard_regions; // Indicate that these regions are intended to be displayed whenever the // dashboard is displayed in an overlay. This information is provided for // any module that might need to use it, not just the core Overlay module. @@ -312,12 +343,23 @@ function dashboard_form_block_admin_disp $form['block_regions']['#value'] = array_diff_key($form['block_regions']['#value'], $dashboard_regions); foreach (element_children($form['blocks']) as $i) { $block = &$form['blocks'][$i]; - if (isset($block['region']['#default_value']) && isset($dashboard_regions[$block['region']['#default_value']])) { + if (isset($block['region']['#default_value']) && isset($dashboard_regions[$block['region']['#default_value']]) && $block['region']['#default_value'] != 'dashboard_hidden') { $block['#access'] = FALSE; } elseif (isset($block['region']['#options'])) { $block['region']['#options'] = array_diff_key($block['region']['#options'], $dashboard_regions); } + // Show hidden dashboard blocks as disabled on the main block + // administration form, so that they are available to place in other + // regions of the theme. Note that when the form is submitted, any such + // blocks which still remain disabled will immediately be put back in the + // 'dashboard_hidden' region, because dashboard_block_info_alter() is + // called when the blocks are rehashed. Fortunately, this is the exact + // behavior we want. + if ($block['region']['#default_value'] == 'dashboard_hidden') { + // @todo These do not wind up in correct alphabetical order. + $block['region']['#default_value'] = NULL; + } } } } @@ -370,6 +412,9 @@ function dashboard_form_block_add_block_ */ function template_preprocess_dashboard_admin_display_form(&$variables) { template_preprocess_block_admin_display_form($variables); + if (isset($variables['block_regions'][BLOCK_REGION_NONE])) { + $variables['block_regions'][BLOCK_REGION_NONE] = t('Not currently on dashboard'); + } } /** @@ -431,8 +476,9 @@ function dashboard_regions() { */ function dashboard_dashboard_regions() { return array( - 'dashboard_main' => 'Dashboard main', - 'dashboard_sidebar' => 'Dashboard sidebar', + 'dashboard_main' => 'Dashboard (main)', + 'dashboard_sidebar' => 'Dashboard (sidebar)', + 'dashboard_hidden' => 'Dashboard (hidden)', ); } @@ -445,9 +491,9 @@ function dashboard_show_disabled() { // Blocks are not necessarily initialized at this point. $blocks = _block_rehash(); - // Limit the list to disabled blocks for the current theme. + // Limit the list to blocks that are marked as disabled for the dashboard. foreach ($blocks as $key => $block) { - if ($block['theme'] != $theme_key || (!empty($block['status']) && !empty($block['region']))) { + if ($block['theme'] != $theme_key || $block['region'] != 'dashboard_hidden') { unset($blocks[$key]); } } @@ -496,7 +542,7 @@ function dashboard_update() { parse_str($_REQUEST['regions'], $regions); foreach ($regions as $region_name => $blocks) { if ($region_name == 'disabled_blocks') { - $region_name = ''; + $region_name = 'dashboard_hidden'; } foreach ($blocks as $weight => $block_string) { // Parse the query string to determine the block's module and delta. @@ -507,12 +553,7 @@ function dashboard_update() { $block->region = $region_name; $block->weight = $weight; - if (empty($region_name)) { - $block->status = 0; - } - else { - $block->status = 1; - } + $block->status = 1; db_merge('block') ->key(array( Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1309 diff -u -p -r1.1309 node.module --- modules/node/node.module 20 Oct 2010 08:15:33 -0000 1.1309 +++ modules/node/node.module 23 Oct 2010 03:19:04 -0000 @@ -2076,6 +2076,7 @@ function node_block_info() { $blocks['syndicate']['cache'] = DRUPAL_NO_CACHE; $blocks['recent']['info'] = t('Recent content'); + $blocks['recent']['properties']['administrative'] = TRUE; return $blocks; } Index: modules/search/search.module =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.module,v retrieving revision 1.365 diff -u -p -r1.365 search.module --- modules/search/search.module 20 Oct 2010 01:31:07 -0000 1.365 +++ modules/search/search.module 23 Oct 2010 03:19:05 -0000 @@ -143,6 +143,7 @@ function search_block_info() { $blocks['form']['info'] = t('Search form'); // Not worth caching. $blocks['form']['cache'] = DRUPAL_NO_CACHE; + $blocks['form']['properties']['administrative'] = TRUE; return $blocks; } Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1211 diff -u -p -r1.1211 user.module --- modules/user/user.module 20 Oct 2010 05:32:31 -0000 1.1211 +++ modules/user/user.module 23 Oct 2010 03:19:05 -0000 @@ -1273,10 +1273,13 @@ function user_block_info() { $blocks['login']['cache'] = DRUPAL_NO_CACHE; $blocks['new']['info'] = t('Who\'s new'); + $blocks['new']['properties']['administrative'] = TRUE; // Too dynamic to cache. $blocks['online']['info'] = t('Who\'s online'); $blocks['online']['cache'] = DRUPAL_NO_CACHE; + $blocks['online']['properties']['administrative'] = TRUE; + return $blocks; }