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 12 Oct 2010 02:22:43 -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 the locations within each theme in which 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 12 Oct 2010 02:22:43 -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.904 diff -u -p -r1.904 comment.module --- modules/comment/comment.module 5 Oct 2010 06:17:28 -0000 1.904 +++ modules/comment/comment.module 12 Oct 2010 02:22:43 -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.39 diff -u -p -r1.39 dashboard.module --- modules/dashboard/dashboard.module 3 Oct 2010 00:14:57 -0000 1.39 +++ modules/dashboard/dashboard.module 12 Oct 2010 02:22:43 -0000 @@ -19,7 +19,7 @@ function dashboard_help($path, $arg) { $output .= ''; return $output; - case 'admin/structure/dashboard': + case 'admin/dashboard/configure': // @todo This assumes the current page is being displayed using the same // theme that the dashboard is displayed in. $output = '

' . t('Rearrange blocks for display on the dashboard. Disabling a block makes it available on the main blocks administration page.', array('@dashboard-url' => url('admin/dashboard'), '@blocks-url' => url("admin/structure/block/list/{$GLOBALS['theme_key']}"))) . '

'; @@ -31,12 +31,6 @@ function dashboard_help($path, $arg) { * Implements hook_menu(). */ function dashboard_menu() { - $items['admin/structure/dashboard'] = array( - 'title' => 'Dashboard', - 'description' => 'Configure which blocks can be shown on the dashboard.', - 'page callback' => 'dashboard_admin_blocks', - 'access arguments' => array('administer blocks'), - ); $items['admin/dashboard'] = array( 'title' => 'Dashboard', 'description' => 'View and customize your dashboard.', @@ -46,6 +40,13 @@ function dashboard_menu() { // the top corner of the window as a convenient "home link". 'weight' => -15, ); + $items['admin/dashboard/configure'] = array( + 'title' => 'Configure available dashboard blocks', + 'description' => 'Configure which blocks can be shown on the dashboard.', + 'page callback' => 'dashboard_admin_blocks', + 'access arguments' => array('administer blocks'), + 'type' => MENU_VISIBLE_IN_BREADCRUMB, + ); $items['admin/dashboard/customize'] = array( 'title' => 'Customize dashboard', 'description' => 'Customize your dashboard.', @@ -89,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 @@ -120,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(); @@ -176,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. @@ -250,7 +282,7 @@ function dashboard_admin($launch_customi ); $build = array( '#theme' => 'dashboard_admin', - '#message' => t('To customize the dashboard page, move blocks to the dashboard regions on the Dashboard administration page, or enable JavaScript on this page to use the drag-and-drop interface.', array('@dashboard' => url('admin/structure/dashboard'))), + '#message' => t('To customize the dashboard page, move blocks to the dashboard regions on the Dashboard administration page, or enable JavaScript on this page to use the drag-and-drop interface.', array('@dashboard' => url('admin/dashboard/configure'))), '#access' => user_access('administer blocks'), '#attached' => array( 'js' => array( @@ -277,7 +309,6 @@ function dashboard_admin($launch_customi function dashboard_admin_blocks() { global $theme_key; drupal_theme_initialize(); - drupal_set_title(t('Configure available dashboard blocks')); module_load_include('inc', 'block', 'block.admin'); // Prepare the blocks for the current theme, and remove those that are @@ -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; + } } } } @@ -330,10 +372,10 @@ function dashboard_form_dashboard_admin_ // dashboard blocks administration page. foreach ($form['blocks'] as &$block) { if (isset($block['configure']['#href'])) { - $block['configure']['#options']['query']['destination'] = 'admin/structure/dashboard'; + $block['configure']['#options']['query']['destination'] = 'admin/dashboard/configure'; } if (isset($block['delete']['#href'])) { - $block['delete']['#options']['query']['destination'] = 'admin/structure/dashboard'; + $block['delete']['#options']['query']['destination'] = 'admin/dashboard/configure'; } } } @@ -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 available 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( @@ -598,7 +639,7 @@ function theme_dashboard_region($variabl */ function theme_dashboard_disabled_blocks($variables) { extract($variables); - $output = '

' . t('Drag and drop these blocks to the columns below. Changes are automatically saved. More options are available on the configuration page.', array('@dashboard-url' => url('admin/structure/dashboard'))) . '

'; + $output = '

' . t('Drag and drop these blocks to the columns below. Changes are automatically saved. More options are available on the configuration page.', array('@dashboard-url' => url('admin/dashboard/configure'))) . '

'; $output .= '
'; foreach ($blocks as $block) { $output .= theme('dashboard_disabled_block', array('block' => $block)); Index: modules/dashboard/dashboard.test =================================================================== RCS file: /cvs/drupal/drupal/modules/dashboard/dashboard.test,v retrieving revision 1.5 diff -u -p -r1.5 dashboard.test --- modules/dashboard/dashboard.test 14 Sep 2010 21:51:01 -0000 1.5 +++ modules/dashboard/dashboard.test 12 Oct 2010 02:22:43 -0000 @@ -65,7 +65,7 @@ class DashboardBlocksTestCase extends Dr $dashboard_regions = dashboard_region_descriptions(); // Ensure blocks can be placed in dashboard regions. - $this->drupalGet('admin/structure/dashboard'); + $this->drupalGet('admin/dashboard/configure'); foreach ($dashboard_regions as $region => $description) { $elements = $this->xpath('//option[@value=:region]', array(':region' => $region)); $this->assertTrue(!empty($elements), t('%region is an available choice on the dashboard block configuration page.', array('%region' => $region))); Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1306 diff -u -p -r1.1306 node.module --- modules/node/node.module 11 Oct 2010 21:00:33 -0000 1.1306 +++ modules/node/node.module 12 Oct 2010 02:22:44 -0000 @@ -2071,6 +2071,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.364 diff -u -p -r1.364 search.module --- modules/search/search.module 9 Oct 2010 03:24:46 -0000 1.364 +++ modules/search/search.module 12 Oct 2010 02:22:44 -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.1208 diff -u -p -r1.1208 user.module --- modules/user/user.module 11 Oct 2010 19:43:23 -0000 1.1208 +++ modules/user/user.module 12 Oct 2010 02:22:44 -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; }