Index: modules/dashboard/dashboard.module =================================================================== RCS file: /cvs/drupal/drupal/modules/dashboard/dashboard.module,v retrieving revision 1.38 diff -u -p -r1.38 dashboard.module --- modules/dashboard/dashboard.module 1 Oct 2010 15:24:18 -0000 1.38 +++ modules/dashboard/dashboard.module 2 Oct 2010 20:08:50 -0000 @@ -281,14 +281,16 @@ function dashboard_admin_blocks() { 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. + // currently displayed in non-dashboard regions, or have the dashboard + // availability block setting disabled. // @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); + $available_blocks = variable_get('dashboard_available_blocks', array()); foreach ($blocks as $id => $block) { - if (isset($regions_to_remove[$block['region']])) { + if (isset($regions_to_remove[$block['region']]) || empty($available_blocks[$block['module']][$block['delta']])) { unset($blocks[$id]); } } @@ -356,6 +358,31 @@ function dashboard_form_block_admin_conf $region['#options'] = array_diff_key($region['#options'], $dashboard_regions); } } + + // Provide a dashboard availability block setting. A block must have this + // setting enabled to allow it to be used in the dashboard. + $available_blocks = variable_get('dashboard_available_blocks', array()); + $form['settings']['available_on_dashboard'] = array( + '#type' => 'checkbox', + '#title' => t('Available on dashboard'), + '#default_value' => !empty($available_blocks[$form['module']['#value']][$form['delta']['#value']]), + ); + $form['#submit'][] = 'dashboard_form_block_admin_configure_submit'; +} + +/** + * Form submission handler for block configuration form. + */ +function dashboard_form_block_admin_configure_submit($form, &$form_state) { + // Save the dashboard availability setting. + $available_blocks = variable_get('dashboard_available_blocks', array()); + if ($form_state['values']['available_on_dashboard']) { + $available_blocks[$form_state['values']['module']][$form_state['values']['delta']] = TRUE; + } + else { + unset($available_blocks[$form_state['values']['module']][$form_state['values']['delta']]); + } + variable_set('dashboard_available_blocks', $available_blocks); } /** @@ -445,9 +472,11 @@ 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 disabled blocks for the current theme, which have the + // dashboard availability block setting. + $available_blocks = variable_get('dashboard_available_blocks', array()); foreach ($blocks as $key => $block) { - if ($block['theme'] != $theme_key || (!empty($block['status']) && !empty($block['region']))) { + if ($block['theme'] != $theme_key || (!empty($block['status']) && !empty($block['region'])) || empty($available_blocks[$block['module']][$block['delta']])) { unset($blocks[$key]); } } Index: profiles/standard/standard.install =================================================================== RCS file: /cvs/drupal/drupal/profiles/standard/standard.install,v retrieving revision 1.25 diff -u -p -r1.25 standard.install --- profiles/standard/standard.install 1 Oct 2010 01:37:13 -0000 1.25 +++ profiles/standard/standard.install 2 Oct 2010 20:08:50 -0000 @@ -202,6 +202,23 @@ function standard_install() { } $query->execute(); + // Set dashboard availability for our initial blocks. + variable_set('dashboard_available_blocks', array( + 'comment' => array( + 'recent' => TRUE, + ), + 'node' => array( + 'recent' => TRUE, + ), + 'user' => array( + 'new' => TRUE, + 'online' => TRUE, + ), + 'search' => array( + 'form' => TRUE, + ) + )); + // Insert default pre-defined node types into the database. For a complete // list of available node type attributes, refer to the node type API // documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info.