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	24 Oct 2010 16:40:05 -0000
@@ -286,7 +286,7 @@ 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 regions in which this block is displayed.'),
     '#tree' => TRUE,
   );
 
Index: modules/dashboard/dashboard.install
===================================================================
RCS file: modules/dashboard/dashboard.install
diff -N modules/dashboard/dashboard.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/dashboard/dashboard.install	24 Oct 2010 16:40:05 -0000
@@ -0,0 +1,21 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Install, update and uninstall functions for the dashboard module.
+ */
+
+/**
+ * Implements hook_enable().
+ */
+function dashboard_enable() {
+  theme_enable(array('dashboard_theme'));
+}
+
+/**
+ * Implements hook_disable().
+ */
+function dashboard_disable() {
+  theme_disable(array('dashboard_theme'));
+}
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	24 Oct 2010 16:40:06 -0000
@@ -20,9 +20,7 @@ function dashboard_help($path, $arg) {
       return $output;
 
     case 'admin/dashboard/configure':
-      // @todo This assumes the current page is being displayed using the same
-      //   theme that the dashboard is displayed in.
-      $output = '<p>' . t('Rearrange blocks for display on the <a href="@dashboard-url">dashboard</a>. Disabling a block makes it available on the main <a href="@blocks-url">blocks administration page</a>.', array('@dashboard-url' => url('admin/dashboard'), '@blocks-url' => url("admin/structure/block/list/{$GLOBALS['theme_key']}"))) . '</p>';
+      $output = '<p>' . t('Rearrange blocks for display on the <a href="@dashboard-url">dashboard</a>.', array('@dashboard-url' => url('admin/dashboard'))) . '</p>';
       return $output;
   }
 }
@@ -36,6 +34,7 @@ function dashboard_menu() {
     'description' => 'View and customize your dashboard.',
     'page callback' => 'dashboard_admin',
     'access arguments' => array('access dashboard'),
+    'theme callback' => '_dashboard_page_theme',
     // Make this appear first, so for example, in admin menus, it shows up on
     // the top corner of the window as a convenient "home link".
     'weight' => -15,
@@ -45,6 +44,12 @@ function dashboard_menu() {
     'description' => 'Configure which blocks can be shown on the dashboard.',
     'page callback' => 'dashboard_admin_blocks',
     'access arguments' => array('administer blocks'),
+    // All dashboard-related callbacks inherit the dashboard-specific theme
+    // from the 'admin/dashboard' menu item, but this page is a normal
+    // administrative page so we want to use the regular administrative theme
+    // instead.
+    'theme callback' => 'variable_get',
+    'theme arguments' => array('admin_theme'),
     'type' => MENU_VISIBLE_IN_BREADCRUMB,
   );
   $items['admin/dashboard/customize'] = array(
@@ -76,6 +81,24 @@ function dashboard_menu() {
 }
 
 /**
+ * Implements hook_menu_alter().
+ */
+function dashboard_menu_alter(&$items) {
+  // Do not allow dashboard blocks to be configured via the Block module's user
+  // interface.
+  if (isset($items['admin/structure/block/list/dashboard_theme'])) {
+    $items['admin/structure/block/list/dashboard_theme']['access callback'] = FALSE;
+  }
+}
+
+/**
+ * Theme callback for the page that displays the dashboard.
+ */
+function _dashboard_page_theme() {
+  return 'dashboard_theme';
+}
+
+/**
  * Implements hook_permission().
  */
 function dashboard_permission() {
@@ -172,11 +195,20 @@ function dashboard_page_build(&$page) {
 
 /**
  * Implements hook_system_info_alter().
- *
- * Add regions to each theme to store the dashboard blocks.
  */
 function dashboard_system_info_alter(&$info, $file, $type) {
-  if ($type == 'theme') {
+  if ($type == 'theme' && $file->name == 'dashboard_theme') {
+    // Make the dashboard theme a subtheme of the site's current administrative
+    // theme, so that it will automatically display with the same style as
+    // other administrative pages.
+    if ($admin_theme = variable_get('admin_theme')) {
+      $base_theme = $admin_theme;
+    }
+    else {
+      $base_theme = variable_get('theme_default', 'bartik');
+    }
+    $info['base theme'] = $base_theme;
+    // Dynamically add the dashboard regions to the dashboard theme.
     $info['regions'] += dashboard_region_descriptions();
     // Indicate that these regions are intended to be displayed whenever the
     // dashboard is displayed in an overlay. This information is provided for
@@ -276,50 +308,17 @@ function dashboard_admin($launch_customi
  * @see template_preprocess_dashboard_admin_display_form()
  */
 function dashboard_admin_blocks() {
-  global $theme_key;
-  drupal_theme_initialize();
   module_load_include('inc', 'block', 'block.admin');
-
-  // Prepare the blocks for the current theme, and remove those that are
-  // currently displayed in non-dashboard regions.
-  // @todo This assumes the current page is being displayed using the same
-  //   theme that the dashboard is displayed in.
-  $blocks = block_admin_display_prepare_blocks($theme_key);
-  $dashboard_regions = dashboard_region_descriptions();
-  $regions_to_remove = array_diff_key(system_region_list($theme_key, REGIONS_VISIBLE), $dashboard_regions);
+  $blocks = block_admin_display_prepare_blocks('dashboard_theme');
   foreach ($blocks as $id => $block) {
-    if (isset($regions_to_remove[$block['region']])) {
+    // The main system content block cannot be placed in any region, since the
+    // dashboard regions themselves are displayed as part of the main page
+    // content.
+    if ($block['module'] == 'system' && $block['delta'] == 'main') {
       unset($blocks[$id]);
     }
   }
-
-  // Pass in the above blocks and dashboard regions to the form, so that only
-  // dashboard-related regions will be displayed.
-  return drupal_get_form('dashboard_admin_display_form', $blocks, $theme_key, $dashboard_regions);
-}
-
-/**
- * Implements hook_form_FORM_ID_alter().
- */
-function dashboard_form_block_admin_display_form_alter(&$form, &$form_state, $form_id) {
-  // Hide dashboard regions (and any blocks placed within them) from the block
-  // administration form and from the options list on that form. This
-  // function is called for both the dashboard block configuration form and the
-  // standard block configuration form so that both forms can share the same
-  // constructor. As a result the form_id must be checked.
-  if ($form_id != 'dashboard_admin_display_form') {
-    $dashboard_regions = dashboard_region_descriptions();
-    $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']])) {
-        $block['#access'] = FALSE;
-      }
-      elseif (isset($block['region']['#options'])) {
-        $block['region']['#options'] = array_diff_key($block['region']['#options'], $dashboard_regions);
-      }
-    }
-  }
+  return drupal_get_form('dashboard_admin_display_form', $blocks, 'dashboard_theme');
 }
 
 /**
@@ -339,33 +338,6 @@ function dashboard_form_dashboard_admin_
 }
 
 /**
- * Implements hook_form_FORM_ID_alter().
- */
-function dashboard_form_block_admin_configure_alter(&$form, &$form_state) {
-  global $theme_key;
-  drupal_theme_initialize();
-  // Hide the dashboard regions from the region select list on the block
-  // configuration form, for all themes except the current theme (since the
-  // other themes do not display the dashboard).
-  // @todo This assumes the current page is being displayed using the same
-  //   theme that the dashboard is displayed in.
-  $dashboard_regions = dashboard_region_descriptions();
-  foreach (element_children($form['regions']) as $region_name) {
-    $region = &$form['regions'][$region_name];
-    if ($region_name != $theme_key && isset($region['#options'])) {
-      $region['#options'] = array_diff_key($region['#options'], $dashboard_regions);
-    }
-  }
-}
-
-/**
- * Implements hook_form_FORM_ID_alter().
- */
-function dashboard_form_block_add_block_form_alter(&$form, &$form_state) {
-  dashboard_form_block_admin_configure_alter($form, $form_state);
-}
-
-/**
  * Preprocesses variables for block-admin-display-form.tpl.php.
  */
 function template_preprocess_dashboard_admin_display_form(&$variables) {
Index: modules/dashboard/dashboard.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/dashboard/dashboard.test,v
retrieving revision 1.6
diff -u -p -r1.6 dashboard.test
--- modules/dashboard/dashboard.test	21 Oct 2010 11:55:09 -0000	1.6
+++ modules/dashboard/dashboard.test	24 Oct 2010 16:40:06 -0000
@@ -21,16 +21,6 @@ class DashboardBlocksTestCase extends Dr
     // Create and log in an administrative user having access to the dashboard.
     $admin_user = $this->drupalCreateUser(array('access dashboard', 'administer blocks'));
     $this->drupalLogin($admin_user);
-
-    // Make sure that the dashboard is using the same theme as the rest of the
-    // site (and in particular, the same theme used on 403 pages). This forces
-    // the dashboard blocks to be the same for an administrator as for a
-    // regular user, and therefore lets us test that the dashboard blocks
-    // themselves are specifically removed for a user who does not have access
-    // to the dashboard page.
-    theme_enable(array('stark'));
-    variable_set('theme_default', 'stark');
-    variable_set('admin_theme', 'stark');
   }
 
   /**
@@ -42,7 +32,7 @@ class DashboardBlocksTestCase extends Dr
     $custom_block['info'] = $this->randomName(8);
     $custom_block['title'] = $this->randomName(8);
     $custom_block['body[value]'] = $this->randomName(32);
-    $custom_block['regions[stark]'] = 'dashboard_main';
+    $custom_block['regions[dashboard_theme]'] = 'dashboard_main';
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
 
     // Ensure admin access.
@@ -56,6 +46,18 @@ class DashboardBlocksTestCase extends Dr
     $this->drupalGet('admin/dashboard');
     $this->assertResponse(403, t('Non-admin has no access to the dashboard.'));
     $this->assertNoText($custom_block['title'], t('Non-admin has no access to a dashboard block.'));
+
+    // Ensure that even if the dashboard is using the same theme as the rest of
+    // the site (in particular, the same theme used on 403 pages), a non-admin
+    // user still does not have access to the dashboard blocks. In this
+    // scenario, the administrator and regular user will both see the same
+    // theme when trying to access the dashboard page, and it therefore lets us
+    // test that the dashboard blocks themselves are specifically removed for a
+    // user who does not have access to that page.
+    variable_set('theme_default', 'dashboard_theme');
+    $this->drupalGet('admin/dashboard');
+    $this->assertResponse(403, t('Non-admin has no access to the dashboard, even when viewing the dashboard theme.'));
+    $this->assertNoText($custom_block['title'], t('Non-admin has no access to a dashboard block, even when viewing the dashboard theme.'));
   }
 
   /**
Index: profiles/standard/standard.install
===================================================================
RCS file: /cvs/drupal/drupal/profiles/standard/standard.install,v
retrieving revision 1.28
diff -u -p -r1.28 standard.install
--- profiles/standard/standard.install	21 Oct 2010 04:22:34 -0000	1.28
+++ profiles/standard/standard.install	24 Oct 2010 16:40:06 -0000
@@ -90,7 +90,7 @@ function standard_install() {
     array(
       'module' => 'node',
       'delta' => 'recent',
-      'theme' => $admin_theme,
+      'theme' => 'dashboard_theme',
       'status' => 1,
       'weight' => 10,
       'region' => 'dashboard_main',
@@ -170,7 +170,7 @@ function standard_install() {
     array(
       'module' => 'user',
       'delta' => 'new',
-      'theme' => $admin_theme,
+      'theme' => 'dashboard_theme',
       'status' => 1,
       'weight' => 0,
       'region' => 'dashboard_sidebar',
@@ -180,7 +180,7 @@ function standard_install() {
     array(
       'module' => 'search',
       'delta' => 'form',
-      'theme' => $admin_theme,
+      'theme' => 'dashboard_theme',
       'status' => 1,
       'weight' => -10,
       'region' => 'dashboard_sidebar',
Index: themes/dashboard_theme/dashboard_theme.info
===================================================================
RCS file: themes/dashboard_theme/dashboard_theme.info
diff -N themes/dashboard_theme/dashboard_theme.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ themes/dashboard_theme/dashboard_theme.info	24 Oct 2010 16:40:06 -0000
@@ -0,0 +1,14 @@
+; $Id$
+name = Dashboard
+description = This is a hidden theme used by the Dashboard module only.
+package = Core
+version = VERSION
+core = 7.x
+engine = phptemplate
+hidden = TRUE
+regions[content] = Content
+regions[help] = Help
+regions[page_top] = Page top
+regions[page_bottom] = Page bottom
+regions_hidden[] = content
+regions_hidden[] = help
