Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
65d61cc7
Commit
65d61cc7
authored
14 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#761956
follow-up by bleen18: Fixed missing regions on Dashboard configuration page.
parent
67937250
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/dashboard/dashboard.module
+16
-11
16 additions, 11 deletions
modules/dashboard/dashboard.module
modules/dashboard/dashboard.test
+25
-3
25 additions, 3 deletions
modules/dashboard/dashboard.test
with
41 additions
and
14 deletions
modules/dashboard/dashboard.module
+
16
−
11
View file @
65d61cc7
...
@@ -310,18 +310,23 @@ function dashboard_admin_blocks() {
...
@@ -310,18 +310,23 @@ function dashboard_admin_blocks() {
/**
/**
* Implements hook_form_FORM_ID_alter().
* 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
// Hide dashboard regions (and any blocks placed within them) from the block
// administration form and from the options list on that form.
// administration form and from the options list on that form. This
$dashboard_regions
=
dashboard_region_descriptions
();
// function is called for both the dashboard block configuration form and the
$form
[
'block_regions'
][
'#value'
]
=
array_diff_key
(
$form
[
'block_regions'
][
'#value'
],
$dashboard_regions
);
// standard block configuration form so that both forms can share the same
foreach
(
element_children
(
$form
[
'blocks'
])
as
$i
)
{
// constructor. As a result the form_id must be checked.
$block
=
&
$form
[
'blocks'
][
$i
];
if
(
$form_id
!=
'dashboard_admin_display_form'
)
{
if
(
isset
(
$block
[
'region'
][
'#default_value'
])
&&
isset
(
$dashboard_regions
[
$block
[
'region'
][
'#default_value'
]]))
{
$dashboard_regions
=
dashboard_region_descriptions
();
$block
[
'#access'
]
=
FALSE
;
$form
[
'block_regions'
][
'#value'
]
=
array_diff_key
(
$form
[
'block_regions'
][
'#value'
],
$dashboard_regions
);
}
foreach
(
element_children
(
$form
[
'blocks'
])
as
$i
)
{
elseif
(
isset
(
$block
[
'region'
][
'#options'
]))
{
$block
=
&
$form
[
'blocks'
][
$i
];
$block
[
'region'
][
'#options'
]
=
array_diff_key
(
$block
[
'region'
][
'#options'
],
$dashboard_regions
);
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
);
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/dashboard/dashboard.test
+
25
−
3
View file @
65d61cc7
...
@@ -6,11 +6,11 @@
...
@@ -6,11 +6,11 @@
* Tests for the dashboard module.
* Tests for the dashboard module.
*/
*/
class
Dashboard
Acces
sTestCase
extends
DrupalWebTestCase
{
class
Dashboard
Block
sTestCase
extends
DrupalWebTestCase
{
public
static
function
getInfo
()
{
public
static
function
getInfo
()
{
return
array
(
return
array
(
'name'
=>
'Dashboard
acces
s'
,
'name'
=>
'Dashboard
block
s'
,
'description'
=>
'Test
access control for
the dashboard.'
,
'description'
=>
'Test
blocks as used by
the dashboard.'
,
'group'
=>
'Dashboard'
,
'group'
=>
'Dashboard'
,
);
);
}
}
...
@@ -57,4 +57,26 @@ class DashboardAccessTestCase extends DrupalWebTestCase {
...
@@ -57,4 +57,26 @@ class DashboardAccessTestCase extends DrupalWebTestCase {
$this
->
assertResponse
(
403
,
t
(
'Non-admin has no access to the 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.'
));
$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
)));
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment