summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-09-14 21:51:01 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-09-14 21:51:01 +0000
commit65d61cc7e63b0172715771f0f72b593070cc809e (patch)
treea8e244e1390ea2a14d6786496495514b53c36f0b /modules
parent679372502bac82b614814312e557979b0151014a (diff)
downloadbrdo-65d61cc7e63b0172715771f0f72b593070cc809e.tar.gz
brdo-65d61cc7e63b0172715771f0f72b593070cc809e.tar.bz2
#761956 follow-up by bleen18: Fixed missing regions on Dashboard configuration page.
Diffstat (limited to 'modules')
-rw-r--r--modules/dashboard/dashboard.module27
-rw-r--r--modules/dashboard/dashboard.test28
2 files changed, 41 insertions, 14 deletions
diff --git a/modules/dashboard/dashboard.module b/modules/dashboard/dashboard.module
index 041934fb4..b1266ef88 100644
--- a/modules/dashboard/dashboard.module
+++ b/modules/dashboard/dashboard.module
@@ -310,18 +310,23 @@ function dashboard_admin_blocks() {
/**
* Implements hook_form_FORM_ID_alter().
*/
-function dashboard_form_block_admin_display_form_alter(&$form, &$form_state) {
+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.
- $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);
+ // 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);
+ }
}
}
}
diff --git a/modules/dashboard/dashboard.test b/modules/dashboard/dashboard.test
index 8d7f22296..9c03d75c2 100644
--- a/modules/dashboard/dashboard.test
+++ b/modules/dashboard/dashboard.test
@@ -6,11 +6,11 @@
* Tests for the dashboard module.
*/
-class DashboardAccessTestCase extends DrupalWebTestCase {
+class DashboardBlocksTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
- 'name' => 'Dashboard access',
- 'description' => 'Test access control for the dashboard.',
+ 'name' => 'Dashboard blocks',
+ 'description' => 'Test blocks as used by the dashboard.',
'group' => 'Dashboard',
);
}
@@ -57,4 +57,26 @@ class DashboardAccessTestCase extends DrupalWebTestCase {
$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.'));
}
+
+ /**
+ * Test that dashboard regions are displayed or hidden properly.
+ */
+ function testDashboardRegions() {
+ $dashboard_regions = dashboard_region_descriptions();
+
+ // Ensure blocks can be placed in dashboard regions.
+ $this->drupalGet('admin/structure/dashboard');
+ 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)));
+ }
+ }
}