Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
0547eb8b
Commit
0547eb8b
authored
3 years ago
by
Liam Morland
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5085: Hide links to menu edit and delete for non-admin
parent
f5b3194b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!153
ISTWCMS-5085: Prevent non-admin access to menu add, edit, and delete
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_cfg_common.module
+8
-0
8 additions, 0 deletions
uw_cfg_common.module
with
8 additions
and
0 deletions
uw_cfg_common.module
+
8
−
0
View file @
0547eb8b
...
...
@@ -9,6 +9,7 @@ use Drupal\Component\Utility\Html;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Render\Element
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\Url
;
use
Drupal\media_library
\MediaLibraryState
;
...
...
@@ -473,6 +474,13 @@ function uw_cfg_common_form_node_uw_ct_web_page_edit_form_alter(array &$form, Fo
* Menu edit form: admin/structure/menu/manage/{menu}.
*/
function
uw_cfg_common_form_menu_edit_form_alter
(
array
&
$form
,
FormStateInterface
$form_state
,
string
$form_id
):
void
{
// Hide links to menu edit and delete for non-admin.
if
(
!
\Drupal
::
currentUser
()
->
hasPermission
(
'administer menu'
))
{
foreach
(
Element
::
children
(
$form
[
'links'
][
'links'
])
as
$element_key
)
{
$form
[
'links'
][
'links'
][
$element_key
][
'operations'
][
'#access'
]
=
FALSE
;
}
}
// Prevent certain changes to the home page.
//
// No changes for those with access.
...
...
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