=== modified file 'modules/block/block-admin-display-form.tpl.php'
--- modules/block/block-admin-display-form.tpl.php 2009-10-05 02:43:01 +0000
+++ modules/block/block-admin-display-form.tpl.php 2010-10-24 04:02:01 +0000
@@ -36,10 +36,10 @@
- |
- |
- |
- |
+
+ |
+
+ |
=== modified file 'modules/block/block.admin.inc'
--- modules/block/block.admin.inc 2010-10-10 20:11:21 +0000
+++ modules/block/block.admin.inc 2010-10-24 05:01:13 +0000
@@ -77,6 +77,14 @@ function block_admin_display_prepare_blo
* @see block_admin_display_form_submit()
*/
function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_regions = NULL) {
+ $form['header'] = array(
+ '#type' => 'value',
+ '#value' => array(
+ 'block' => t('Block'),
+ 'region' => t('Region'),
+ 'weight' => t('Weight'),
+ ),
+ );
drupal_add_css(drupal_get_path('module', 'block') . '/block.css');
@@ -640,6 +648,7 @@ function block_custom_block_delete_submi
* @see theme_block_admin_display()
*/
function template_preprocess_block_admin_display_form(&$variables) {
+ $variables['header'] = $variables['form']['header']['#value'];
$variables['block_regions'] = $variables['form']['block_regions']['#value'];
if (isset($variables['block_regions'][BLOCK_REGION_NONE])) {
$variables['block_regions'][BLOCK_REGION_NONE] = t('Disabled');
=== modified file 'modules/block/block.install'
--- modules/block/block.install 2010-10-20 01:15:58 +0000
+++ modules/block/block.install 2010-10-24 06:28:52 +0000
@@ -27,7 +27,7 @@ function block_schema() {
),
'delta' => array(
'type' => 'varchar',
- 'length' => 32,
+ 'length' => 96,
'not null' => TRUE,
'default' => '0',
'description' => 'Unique ID for block within a module.',
@@ -114,7 +114,7 @@ function block_schema() {
),
'delta' => array(
'type' => 'varchar',
- 'length' => 32,
+ 'length' => 96,
'not null' => TRUE,
'description' => "The block's unique delta within module, from {block}.delta.",
),
@@ -462,6 +462,20 @@ function block_update_7007() {
}
/**
+ * Change delta to max 96 characters to accomodate for the module name.
+ */
+function block_update_7008() {
+ $delta_field = array(
+ 'type' => 'varchar',
+ 'length' => 96,
+ 'not null' => TRUE,
+ 'default' => '0',
+ );
+ db_change_field('block', 'delta', 'delta', $delta_field);
+ db_change_field('block', 'delta', 'delta', $delta_field);
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
=== modified file 'modules/comment/comment.module'
--- modules/comment/comment.module 2010-10-23 15:30:34 +0000
+++ modules/comment/comment.module 2010-10-24 03:40:39 +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;
}
=== modified file 'modules/dashboard/dashboard.module'
--- modules/dashboard/dashboard.module 2010-10-21 11:55:08 +0000
+++ modules/dashboard/dashboard.module 2010-10-24 06:12:31 +0000
@@ -1,6 +1,8 @@
' . 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']}"))) . '';
+ $output = '' . t('Rearrange blocks for display on the dashboard.', array('@dashboard-url' => url('admin/dashboard'))) . '
';
return $output;
}
}
@@ -47,6 +49,15 @@ function dashboard_menu() {
'access arguments' => array('administer blocks'),
'type' => MENU_VISIBLE_IN_BREADCRUMB,
);
+ $items['admin/dashboard/configure/add'] = array(
+ 'title' => 'Add block',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('dashboard_add_block_form'),
+ 'access arguments' => array('administer blocks'),
+ 'type' => MENU_LOCAL_ACTION,
+ 'file' => 'block.admin.inc',
+ 'file path' => drupal_get_path('module', 'block'),
+ );
$items['admin/dashboard/customize'] = array(
'title' => 'Customize dashboard',
'description' => 'Customize your dashboard.',
@@ -97,7 +108,14 @@ function dashboard_permission() {
* where they will never be displayed.
*/
function dashboard_block_list_alter(&$blocks) {
- if (!dashboard_is_visible()) {
+ if (dashboard_is_visible()) {
+ foreach ($blocks as $key => $block) {
+ if ($block->region == 'dashboard_available') {
+ unset($blocks[$key]);
+ }
+ }
+ }
+ else {
foreach ($blocks as $key => $block) {
if (in_array($block->region, dashboard_regions())) {
unset($blocks[$key]);
@@ -106,6 +124,48 @@ function dashboard_block_list_alter(&$bl
}
}
+function dashboard_block_info_alter(&$blocks, $theme, $code_blocks) {
+ // Need every dashboard block so get it from the database.
+ $result = db_query('SELECT * FROM {block} WHERE module = :module AND theme = :theme', array('module' => 'dashboard', 'theme' => $theme));
+ $dashboard_blocks = array();
+ foreach ($result as $block) {
+ list($module, $delta) = explode(':', $block->delta, 2);
+ if (isset($blocks[$module][$delta])) {
+ $dashboard_blocks[$block->delta] = (array) $block;
+ $dashboard_blocks[$block->delta]['info'] = $blocks[$module][$delta]['info'];
+ }
+ }
+ foreach ($blocks as $module => $module_blocks) {
+ if ($module != 'dashboard') {
+ foreach ($module_blocks as $delta => $block) {
+ $dashboard_delta = "$module:$delta";
+ if (isset($dashboard_blocks[$dashboard_delta])) {
+ $dashboard_block = $dashboard_blocks[$dashboard_delta];
+ }
+ else {
+ $dashboard_block = $block;
+ unset($dashboard_block['bid']);
+ $dashboard_block['module'] = 'dashboard';
+ $dashboard_block['delta'] = $dashboard_delta;
+ if (!empty($code_blocks[$module][$delta]['properties']['administrative'])) {
+ $dashboard_block['region'] = 'dashboard_available';
+ $dashboard_block['status'] = 1;
+ }
+ else {
+ $dashboard_block['status'] = 0;
+ }
+ }
+ $blocks['dashboard'][$dashboard_delta] = $dashboard_block;
+ }
+ }
+ }
+}
+
+function dashboard_block_view($dashboard_delta) {
+ list($module, $delta) = explode(':', $dashboard_delta, 2);
+ return module_invoke($module, 'block_view', $delta);
+}
+
/**
* Implements hook_page_build().
*
@@ -121,6 +181,12 @@ function dashboard_page_build(&$page) {
// region into it.
$page['content']['dashboard'] = array('#theme_wrappers' => array('dashboard'));
foreach (dashboard_regions() as $region) {
+ // Although dashboard_block_list_alter() removed every block from the
+ // dashboard_available region, remove the empty array completely to avoid
+ // seeing an (empty) on screen.
+ if ($region == 'dashboard_available') {
+ 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();
@@ -225,6 +291,9 @@ function dashboard_forms() {
$forms['dashboard_admin_display_form'] = array(
'callback' => 'block_admin_display_form',
);
+ $forms['dashboard_add_block_form'] = array(
+ 'callback' => 'block_add_block_form',
+ );
return $forms;
}
@@ -302,17 +371,32 @@ function dashboard_admin_blocks() {
* 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') {
+ // 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') {
+ // On the dashboard block configuration page only allow dashboard blocks.
+ foreach (element_children($form['blocks']) as $i) {
+ if ($form['blocks'][$i]['module']['#value'] != 'dashboard') {
+ unset($form['blocks'][$i]);
+ }
+ else {
+ $form['blocks'][$i]['region']['#empty_option'] = DASHBOARD_DISABLED;
+ }
+ $form['header']['#value']['region'] = t('Dashboard region');
+ }
+ }
+ else {
+ // Hide dashboard regions (and any blocks placed within them) from the block
+ // administration form and from the options list on that 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']])) {
+ if ($block['module']['#value'] == 'dashboard') {
+ unset($form['blocks'][$i]);
+ }
+ elseif (isset($block['region']['#default_value']) && isset($dashboard_regions[$block['region']['#default_value']])) {
$block['#access'] = FALSE;
}
elseif (isset($block['region']['#options'])) {
@@ -341,19 +425,28 @@ function dashboard_form_dashboard_admin_
/**
* Implements hook_form_FORM_ID_alter().
*/
-function dashboard_form_block_admin_configure_alter(&$form, &$form_state) {
+function dashboard_form_block_admin_configure_alter(&$form, &$form_state, $form_id) {
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);
+ if ($form['module']['#value'] =='dashboard' || $form_id == 'dashboard_add_block_form') {
+ $form['regions']['#access'] = FALSE;
+ // Remove path and node type visibility as these make little sense, the
+ // dashboard has a given path and that's not a node.
+ $form['visibility']['path']['#access'] = FALSE;
+ $form['visibility']['node_type']['#access'] = FALSE;
+ }
+ else {
+ // 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 $theme) {
+ $region = &$form['regions'][$theme];
+ if (isset($region['#options'])) {
+ $region['#options'] = array_diff_key($region['#options'], $dashboard_regions);
+ }
}
}
}
@@ -361,8 +454,8 @@ function dashboard_form_block_admin_conf
/**
* 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);
+function dashboard_form_block_add_block_form_alter(&$form, &$form_state, $form_id) {
+ dashboard_form_block_admin_configure_alter($form, $form_state, $form_id);
}
/**
@@ -370,6 +463,7 @@ function dashboard_form_block_add_block_
*/
function template_preprocess_dashboard_admin_display_form(&$variables) {
template_preprocess_block_admin_display_form($variables);
+ $variables['block_regions'][BLOCK_REGION_NONE] = t('Not shown for dashboard customization.');
}
/**
@@ -431,8 +525,9 @@ function dashboard_regions() {
*/
function dashboard_dashboard_regions() {
return array(
- 'dashboard_main' => 'Dashboard main',
- 'dashboard_sidebar' => 'Dashboard sidebar',
+ 'dashboard_main' => 'Main',
+ 'dashboard_sidebar' => 'Sidebar',
+ 'dashboard_available' => 'Available for customization',
);
}
@@ -447,7 +542,7 @@ function dashboard_show_disabled() {
// Limit the list to disabled blocks for the current theme.
foreach ($blocks as $key => $block) {
- if ($block['theme'] != $theme_key || (!empty($block['status']) && !empty($block['region']))) {
+ if ($block['module'] != 'dashboard' || $block['theme'] != $theme_key || $block['region'] != 'dashboard_available') {
unset($blocks[$key]);
}
}
@@ -629,4 +724,3 @@ function theme_dashboard_disabled_block(
}
return $output;
}
-
=== modified file 'modules/dashboard/dashboard.test'
--- modules/dashboard/dashboard.test 2010-10-21 11:55:08 +0000
+++ modules/dashboard/dashboard.test 2010-10-24 06:14:17 +0000
@@ -42,8 +42,10 @@ 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';
- $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+ $this->drupalPost('admin/dashboard/configure/add', $custom_block, t('Save block'));
+ $bid = db_query('SELECT bid FROM {block_custom} WHERE info = :info', array(':info' => $custom_block['info']))->fetchField();
+ $edit["blocks[dashboard_block:$bid][region]"] = 'dashboard_main';
+ $this->drupalPost('admin/dashboard/configure', $edit, t('Save blocks'));
// Ensure admin access.
$this->drupalGet('admin/dashboard');
=== modified file 'modules/node/node.module'
--- modules/node/node.module 2010-10-23 15:30:34 +0000
+++ modules/node/node.module 2010-10-24 03:41:10 +0000
@@ -2078,6 +2078,7 @@ function node_block_info() {
$blocks['syndicate']['cache'] = DRUPAL_NO_CACHE;
$blocks['recent']['info'] = t('Recent content');
+ $blocks['recent']['properties']['administrative'] = TRUE;
return $blocks;
}
=== modified file 'modules/search/search.module'
--- modules/search/search.module 2010-10-20 01:31:06 +0000
+++ modules/search/search.module 2010-10-24 03:42:27 +0000
@@ -143,6 +143,8 @@ 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;
}
=== modified file 'modules/user/user.module'
--- modules/user/user.module 2010-10-23 15:30:34 +0000
+++ modules/user/user.module 2010-10-24 03:41:59 +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;
}
=== modified file 'profiles/standard/standard.install'
--- profiles/standard/standard.install 2010-10-21 04:22:34 +0000
+++ profiles/standard/standard.install 2010-10-24 05:00:37 +0000
@@ -88,8 +88,8 @@ function standard_install() {
'cache' => -1,
),
array(
- 'module' => 'node',
- 'delta' => 'recent',
+ 'module' => 'dashboard',
+ 'delta' => 'node:recent',
'theme' => $admin_theme,
'status' => 1,
'weight' => 10,
@@ -168,8 +168,8 @@ function standard_install() {
'cache' => -1,
),
array(
- 'module' => 'user',
- 'delta' => 'new',
+ 'module' => 'dashboard',
+ 'delta' => 'user:new',
'theme' => $admin_theme,
'status' => 1,
'weight' => 0,
@@ -178,8 +178,8 @@ function standard_install() {
'cache' => -1,
),
array(
- 'module' => 'search',
- 'delta' => 'form',
+ 'module' => 'dashboard',
+ 'delta' => 'search:form',
'theme' => $admin_theme,
'status' => 1,
'weight' => -10,