Commit 353eb10c authored by webchick's avatar webchick

Issue #950956 by tim.plunkett, aspilicious, jenlampton, chx, Rob Loach: Remove...

Issue #950956 by tim.plunkett, aspilicious, jenlampton, chx, Rob Loach: Remove Dashboard module until/unless such time as it's more useful.
parent 50a46229
......@@ -23,6 +23,7 @@ Drupal 8.0, xxxx-xx-xx (development version)
* The following modules have been removed from core, because contributed
modules with similar functionality are available:
* Blog
* Dashboard
* Profile
* Trigger
- Removed the Garland theme from core.
......
......@@ -174,9 +174,6 @@ Contact module
Contextual module
- Daniel F. Kudwien 'sun' <http://drupal.org/user/54136>
Dashboard module
- ?
Database Logging module
- Khalid Baheyeldin 'kbahey' <http://drupal.org/user/4063>
......
......@@ -48,7 +48,7 @@ function block_help($path, $arg) {
case 'admin/help#block':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Block module allows you to create boxes of content, which are rendered into an area, or region, of one or more pages of a website. The core Seven administration theme, for example, implements the regions "Content", "Help", "Dashboard main", and "Dashboard sidebar", and a block may appear in any one of these regions. The <a href="@blocks">Blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. For more information, see the online handbook entry for <a href="@block">Block module</a>.', array('@block' => 'http://drupal.org/documentation/modules/block', '@blocks' => url('admin/structure/block'))) . '</p>';
$output .= '<p>' . t('The Block module allows you to create boxes of content, which are rendered into an area, or region, of one or more pages of a website. The core Seven administration theme, for example, implements the regions "Content" and "Help", and a block may appear in either of these regions. The <a href="@blocks">Blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. For more information, see the online handbook entry for <a href="@block">Block module</a>.', array('@block' => 'http://drupal.org/documentation/modules/block', '@blocks' => url('admin/structure/block'))) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Positioning content') . '</dt>';
......
/**
* @file
* Right-to-left specific stylesheet for the Dashboard module.
*/
#dashboard div.dashboard-region {
float: right;
}
#dashboard #disabled-blocks .block, #dashboard .block-placeholder {
float: right;
margin: 3px 0 3px 3px;
padding: 6px 8px 6px 4px;
}
#dashboard .canvas-content a.button {
margin: 0 10px 0 0;
}
#dashboard .ui-sortable .block h2 {
background-position: right -39px;
padding: 0 19px;
}
#dashboard.customize-inactive #disabled-blocks .block:hover h2 {
background-position: right -39px;
}
#dashboard.customize-inactive .dashboard-region .ui-sortable .block:hover h2 {
background-position: right -36px;
}
#dashboard div#dashboard_main {
margin-left: 1%;
margin-right: 0;
}
<?php
/**
* @file
* Hooks provided by the Dashboard module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Add regions to the dashboard.
*
* @return
* An array whose keys are the names of the dashboard regions and whose
* values are the titles that will be displayed in the blocks administration
* interface. The keys are also used as theme wrapper functions.
*/
function hook_dashboard_regions() {
// Define a new dashboard region. Your module can also then define
// theme_mymodule_dashboard_region() as a theme wrapper function to control
// the region's appearance.
return array('mymodule_dashboard_region' => "My module's dashboard region");
}
/**
* Alter dashboard regions provided by modules.
*
* @param $regions
* An array containing all dashboard regions, in the format provided by
* hook_dashboard_regions().
*/
function hook_dashboard_regions_alter($regions) {
// Remove the sidebar region defined by the core dashboard module.
unset($regions['dashboard_sidebar']);
}
/**
* @} End of "addtogroup hooks".
*/
/**
* @file
* Stylesheet for the Dashboard module.
*/
#dashboard div.dashboard-region {
float: left;
min-height: 1px;
}
#dashboard div#dashboard_main {
margin-right: 1%; /* LTR */
width: 65%;
}
#dashboard div#dashboard_sidebar {
width: 33%;
}
#dashboard div.block {
margin-bottom: 20px;
}
#dashboard .dashboard-region .block {
clear: both;
}
#dashboard .dashboard-region .block-placeholder {
display: block;
height: 1.6em;
margin: 0 0 20px 0;
padding: 0;
width: 100%;
}
#dashboard div.block h2 {
float: none;
}
#dashboard #disabled-blocks .block,
#dashboard .block-placeholder {
background: #e2e1dc;
-moz-border-radius: 4px;
border-radius: 4px;
float: left; /* LTR */
margin: 3px 3px 3px 0; /* LTR */
padding: 6px 4px 6px 8px; /* LTR */
}
#dashboard .dashboard-add-other-blocks {
margin: 10px 0 0 0;
}
#dashboard .ui-sortable {
border: 2px dashed #ccc;
padding: 10px;
}
#dashboard .canvas-content {
padding: 10px;
}
#dashboard .canvas-content a.button {
color: #5a5a5a;
margin: 0 0 0 10px; /* LTR */
text-decoration: none;
}
#dashboard .region {
margin: 5px;
}
#dashboard #disabled-blocks {
padding: 5px 0;
}
#dashboard #disabled-blocks .ui-sortable {
background-color: #777;
border: 0;
padding: 0;
}
#dashboard #disabled-blocks .region {
background-color: #e0e0d8;
border: #ccc 1px solid;
padding: 10px;
}
#dashboard #disabled-blocks h2 {
display: inline;
font-weight: normal;
white-space: nowrap;
}
#dashboard #disabled-blocks .block {
background: #444;
color: #fff;
}
#dashboard.customize-inactive #disabled-blocks .block:hover {
background: #0074bd;
}
#dashboard #disabled-blocks .block-placeholder {
height: 1.6em;
width: 30px;
}
#dashboard #disabled-blocks .block .content,
#dashboard .ui-sortable-helper .content {
display: none;
}
#dashboard .ui-sortable .block {
cursor: move;
min-height: 1px;
}
#dashboard .ui-sortable .block h2 {
background: transparent url(../../misc/draggable.png) no-repeat 0px -39px;
padding: 0 17px;
}
#dashboard.customize-inactive #disabled-blocks .block:hover h2 {
background: #0074bd url(../../misc/draggable.png) no-repeat 0px -39px;
color: #fff;
}
#dashboard.customize-inactive .dashboard-region .ui-sortable .block:hover h2 {
background: #0074bd url(../../misc/draggable.png) no-repeat 3px -36px;
color: #fff;
}
name = Dashboard
description = Provides a dashboard page in the administrative interface for organizing administrative tasks and tracking information within your site.
core = 8.x
package = Core
version = VERSION
dependencies[] = block
configure = admin/dashboard/customize
<?php
/**
* @file
* Install, update and uninstall functions for the dashboard module.
*/
/**
* Implements hook_disable().
*
* Stash a list of blocks enabled on the dashboard, so they can be re-enabled
* if the dashboard is re-enabled. Then disable those blocks, since the
* dashboard regions will no longer be defined.
*/
function dashboard_disable() {
// Stash a list of currently enabled blocks.
$stashed_blocks = array();
$result = db_select('block', 'b')
->fields('b', array('module', 'delta', 'region'))
->condition('b.region', dashboard_regions(), 'IN')
->execute();
foreach ($result as $block) {
$stashed_blocks[] = array(
'module' => $block->module,
'delta' => $block->delta,
'region' => $block->region,
);
}
variable_set('dashboard_stashed_blocks', $stashed_blocks);
// Disable the dashboard blocks.
db_update('block')
->fields(array(
'status' => 0,
'region' => BLOCK_REGION_NONE,
))
->condition('region', dashboard_regions(), 'IN')
->execute();
}
/**
* Implements hook_enable().
*
* Restores blocks to the dashboard that were there when the dashboard module
* was disabled.
*/
function dashboard_enable() {
global $theme_key;
if (!$stashed_blocks = variable_get('dashboard_stashed_blocks')) {
return;
}
if (!$admin_theme = variable_get('admin_theme')) {
drupal_theme_initialize();
$admin_theme = $theme_key;
}
foreach ($stashed_blocks as $block) {
db_update('block')
->fields(array(
'status' => 1,
'region' => $block['region']
))
->condition('module', $block['module'])
->condition('delta', $block['delta'])
->condition('theme', $admin_theme)
->condition('status', 0)
->execute();
}
variable_del('dashboard_stashed_blocks');
}
/**
* Implements hook_uninstall().
*/
function dashboard_uninstall() {
variable_del('dashboard_stashed_blocks');
}
/**
* @file
* Attaches behaviors for the Dashboard module.
*/
(function ($) {
"use strict";
/**
* Implements Drupal.behaviors for the Dashboard module.
*/
Drupal.behaviors.dashboard = {
attach: function (context, settings) {
$(context).find('#dashboard').once(function () {
$(this).prepend('<div class="customize clearfix"><ul class="action-links"><li><a href="#">' + Drupal.t('Customize dashboard') + '</a></li></ul><div class="canvas"></div></div>');
$('.customize .action-links a', this).click(Drupal.behaviors.dashboard.enterCustomizeMode);
});
Drupal.behaviors.dashboard.addPlaceholders();
if (Drupal.settings.dashboard.launchCustomize) {
Drupal.behaviors.dashboard.enterCustomizeMode();
}
},
addPlaceholders: function() {
$('#dashboard .dashboard-region .region').each(function () {
var $this = $(this);
var empty_text = "";
// If the region is empty
if ($this.find('.block').length === 0) {
// Check if we are in customize mode and grab the correct empty text
if ($('#dashboard').hasClass('customize-mode')) {
empty_text = Drupal.settings.dashboard.emptyRegionTextActive;
} else {
empty_text = Drupal.settings.dashboard.emptyRegionTextInactive;
}
// We need a placeholder.
if ($this.find('.placeholder').length === 0) {
$this.append('<div class="placeholder"></div>');
}
$this.find('.placeholder').html(empty_text);
}
else {
$this.find('.placeholder').remove();
}
});
},
/**
* Enters "customize" mode by displaying disabled blocks.
*/
enterCustomizeMode: function () {
$('#dashboard').addClass('customize-mode customize-inactive');
Drupal.behaviors.dashboard.addPlaceholders();
// Hide the customize link
$('#dashboard .customize .action-links').hide();
// Load up the disabled blocks
$('div.customize .canvas').load(Drupal.settings.dashboard.drawer, Drupal.behaviors.dashboard.setupDrawer);
},
/**
* Exits "customize" mode by simply forcing a page refresh.
*/
exitCustomizeMode: function () {
$('#dashboard').removeClass('customize-mode customize-inactive');
Drupal.behaviors.dashboard.addPlaceholders();
location.href = Drupal.settings.dashboard.dashboard;
},
/**
* Sets up the drag-and-drop behavior and the 'close' button.
*/
setupDrawer: function () {
$('div.customize .canvas-content input').click(Drupal.behaviors.dashboard.exitCustomizeMode);
$('div.customize .canvas-content').append('<a class="button" href="' + Drupal.settings.dashboard.dashboard + '">' + Drupal.t('Done') + '</a>');
// Initialize drag-and-drop.
var regions = $('#dashboard div.region');
regions.sortable({
connectWith: regions,
cursor: 'move',
cursorAt: {top:0},
dropOnEmpty: true,
items: '> div.block, > div.disabled-block',
placeholder: 'block-placeholder clearfix',
tolerance: 'pointer',
start: Drupal.behaviors.dashboard.start,
over: Drupal.behaviors.dashboard.over,
sort: Drupal.behaviors.dashboard.sort,
update: Drupal.behaviors.dashboard.update
});
},
/**
* Makes the block appear as a disabled block while dragging.
*
* This function is called on the jQuery UI Sortable "start" event.
*
* @param event
* The event that triggered this callback.
* @param ui
* An object containing information about the item that is being dragged.
*/
start: function (event, ui) {
$('#dashboard').removeClass('customize-inactive');
var item = $(ui.item);
// If the block is already in disabled state, don't do anything.
if (!item.hasClass('disabled-block')) {
item.css({height: 'auto'});
}
},
/**
* Adapts block's width to the region it is moved into while dragging.
*
* This function is called on the jQuery UI Sortable "over" event.
*
* @param event
* The event that triggered this callback.
* @param ui
* An object containing information about the item that is being dragged.
*/
over: function (event, ui) {
var item = $(ui.item);
// If the block is in disabled state, remove width.
if ($(this).closest('#disabled-blocks').length) {
item.css('width', '');
}
else {
item.css('width', $(this).width());
}
},
/**
* Adapts a block's position to stay connected with the mouse pointer.
*
* This function is called on the jQuery UI Sortable "sort" event.
*
* @param event
* The event that triggered this callback.
* @param ui
* An object containing information about the item that is being dragged.
*/
sort: function (event, ui) {
var item = $(ui.item);
if (event.pageX > ui.offset.left + item.width()) {
item.css('left', event.pageX);
}
},
/**
* Sends block order to the server, and expands previously disabled blocks.
*
* This function is called on the jQuery UI Sortable "update" event.
*
* @param event
* The event that triggered this callback.
* @param ui
* An object containing information about the item that was just dropped.
*/
update: function (event, ui) {
$('#dashboard').addClass('customize-inactive');
var item = $(ui.item);
// If the user dragged a disabled block, load the block contents.
if (item.hasClass('disabled-block')) {
var module, delta, itemClass;
itemClass = item.attr('class');
// Determine the block module and delta.
module = itemClass.match(/\bmodule-(\S+)\b/)[1];
delta = itemClass.match(/\bdelta-(\S+)\b/)[1];
// Load the newly enabled block's content.
$.get(Drupal.settings.dashboard.blockContent + '/' + module + '/' + delta, {},
function (block) {
if (block) {
item.html(block);
}
if (item.find('div.content').is(':empty')) {
item.find('div.content').html(Drupal.settings.dashboard.emptyBlockText);
}
Drupal.attachBehaviors(item);
},
'html'
);
// Remove the "disabled-block" class, so we don't reload its content the
// next time it's dragged.
item.removeClass("disabled-block");
}
Drupal.behaviors.dashboard.addPlaceholders();
// Let the server know what the new block order is.
$.post(Drupal.settings.dashboard.updatePath, {
'form_token': Drupal.settings.dashboard.formToken,
'regions': Drupal.behaviors.dashboard.getOrder
}
);
},
/**
* Returns the current order of the blocks in each of the sortable regions.
*
* @return
* The current order of the blocks, in query string format.
*/
getOrder: function () {
var order = [];
$('#dashboard div.region').each(function () {
var region = $(this).parent().attr('id').replace(/-/g, '_');
var blocks = $(this).sortable('toArray');
for (var i = 0, il = blocks.length; i < il; i += 1) {
order.push(region + '[]=' + blocks[i]);
}
});
order = order.join('&');
return order;
}
};
})(jQuery);
This diff is collapsed.
<?php
/**
* @file
* Definition of Drupal\dashboard\Tests\DashboardBlockAvailabilityTest.
*/
namespace Drupal\dashboard\Tests;
use Drupal\simpletest\WebTestBase;
class DashboardBlockAvailabilityTest extends WebTestBase {
protected $profile = 'standard';
public static function getInfo() {
return array(
'name' => 'Block availability',
'description' => 'Test blocks as used by the dashboard.',
'group' => 'Dashboard',
);
}
function setUp() {
parent::setUp();
// Create and log in an administrative user having access to the dashboard.
$admin_user = $this->drupalCreateUser(array('access dashboard', 'administer blocks', 'access administration pages', 'administer modules'));
$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');
}
/**
* Tests that administrative blocks are available for the dashboard.
*/
function testBlockAvailability() {
// Test "Recent comments", which should be available (defined as
// "administrative") but not enabled.
$this->drupalGet('admin/dashboard');
$this->assertNoText(t('Recent comments'), t('"Recent comments" not on dashboard.'));
$this->drupalGet('admin/dashboard/drawer');
$this->assertText(t('Recent comments'), t('Drawer of disabled blocks includes a block defined as "administrative".'));
$this->assertNoText(t('Syndicate'), t('Drawer of disabled blocks excludes a block not defined as "administrative".'));
$this->drupalGet('admin/dashboard/configure');
$elements = $this->xpath('//select[@id=:id]//option[@selected="selected"]', array(':id' => 'edit-blocks-comment-recent-region'));
$this->assertTrue($elements[0]['value'] == 'dashboard_inactive', t('A block defined as "administrative" defaults to dashboard_inactive.'));
// Now enable the block on the dashboard.
$values = array();
$values['blocks[comment_recent][region]'] = 'dashboard_main';
$this->drupalPost('admin/dashboard/configure', $values, t('Save blocks'));
$this->drupalGet('admin/dashboard');
$this->assertText(t('Recent comments'), t('"Recent comments" was placed on dashboard.'));
$this->drupalGet('admin/dashboard/drawer');
$this->assertNoText(t('Recent comments'), t('Drawer of disabled blocks excludes enabled blocks.'));
}
}
<?php
/**
* @file
* Definition of Drupal\dashboard\Tests\DashboardBlocksTest.
*/
namespace Drupal\dashboard\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests the Dashboard module blocks.
*/
class DashboardBlocksTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'Dashboard blocks',
'description' => 'Test blocks as used by the dashboard.',
'group' => 'Dashboard',
);
}
function setUp() {
parent::setUp(array('block', 'dashboard'));
// Create and log in an administrative user having access to the dashboard.
$admin_user = $this->drupalCreateUser(array('access dashboard', 'administer blocks', 'access administration pages', 'administer modules'));
$this->drupalLogin($admin_user);
}
/**
* Tests adding a block to the dashboard and checking access to it.
*/
function testDashboardAccess() {
// Add a new custom block to a dashboard region.
$custom_block = array();
$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'));
// Ensure admin access.
$this->drupalGet('admin/dashboard');
$this->assertResponse(200, t('Admin has access to the dashboard.'));
$this->assertRaw($custom_block['title'], t('Admin has access to a dashboard block.'));
// Ensure non-admin access is denied.
$normal_user = $this->drupalCreateUser();
$this->drupalLogin($normal_user);
$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.'));
}
/**
* Tests that dashboard regions are displayed or hidden properly.
*/
function testDashboardRegions() {
$dashboard_regions = dashboard_region_descriptions();
$this->assertTrue(!empty($dashboard_regions), 'One or more dashboard regions found.');
// Ensure blocks can be placed in dashboard regions.
$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)));
}
// Ensure blocks cannot be placed in dashboard regions on the standard
// blocks configuration page.
$this->drupalGet('admin/structure/block');
foreach ($dashboard_regions as $region => $description) {
$elements = $this->xpath('//option[@value=:region]', array(':region' => $region));
$this->assertTrue(empty($elements), t('%region is not an available choice on the block configuration page.', array('%region' => $region)));
}
}
/**
* Tests that the dashboard module can be re-enabled, retaining its blocks.
*/
function testDisableEnable() {
// Add a new custom block to a dashboard region.
$custom_block = array();
$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->drupalGet('admin/dashboard');
$this->assertRaw($custom_block['title'], t('Block appears on the dashboard.'));
$edit = array();
$edit['modules[Core][dashboard][enable]'] = FALSE;
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
$this->assertNoRaw('assigned to the invalid region', t('Dashboard blocks gracefully disabled.'));
system_list_reset();
$this->assertFalse(module_exists('dashboard'), t('Dashboard disabled.'));
$edit['modules[Core][dashboard][enable]'] = 'dashboard';
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
system_list_reset();
$this->assertTrue(module_exists('dashboard'), t('Dashboard enabled.'));
$this->drupalGet('admin/dashboard');
$this->assertRaw($custom_block['title'], t('Block still appears on the dashboard.'));
}
}
......@@ -2429,7 +2429,7 @@ function theme_admin_page($variables) {
}
/**