Problem/Motivation

The Menu Per Role module currently lacks the necessary granularity to control who can assign roles for menu item visibility. The module provides a general permission (administer menu_per_role), which allows access to the configuration of the module but does not distinguish between users who should only manage the settings and those who should have the ability to assign visibility roles to menu links.

Additionally, the naming and description of the administer menu_per_role permission are misleading. This permission implies general module administration, but its real function is more limited. It needs to be renamed and clarified to reflect its actual usage.

Steps to reproduce

  1. Install the Menu Per Role module on a Drupal 10.x site.
  2. Assign the administer menu_per_role permission to a user role.
  3. Edit a menu item and observe that there is no specific permission to control who can assign roles to determine the visibility of the menu link.
  4. Any user with the administer menu_per_role permission can both access the module settings and assign visibility roles to menu links, without separate permissions to control these actions.

Proposed resolution

  1. Rename and clarify the existing permission:
    • Change the name of administer menu_per_role to administer menu_per_role settings.
    • Update the title and description of the permission to reflect that it is specifically for accessing the module’s settings.
    • Proposed new title and description:

    • Name: administer menu_per_role settings
    • Title: "Administer Menu Per Role settings"
    • Description: "Permission to configure Menu Per Role settings."
  2. Create a new permission to control role assignments for menu item visibility:
    • Name: assign menu role visibility
    • Title: "Assign roles for menu link visibility"
    • Description: "Allows users to assign which roles can view specific menu links."
  3. Modify the module’s form logic (in menu_per_role_form_menu_link_content_form_alter) to check for the new assign menu role visibility permission. Only users with this permission should be able to assign visibility roles to menu links, while the general module settings should remain restricted to users with administer menu_per_role settings.

With this proposed change, the module will provide better control over who can manage its settings and who can assign role-based visibility to menu items.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

einarulfhednar created an issue. See original summary.

angel ruiz’s picture

Status: Active » Needs review

grask0 made their first commit to this issue’s fork.

grask0’s picture

Hey,

Seems like ok for me. Thanks for such update!

grask0’s picture

Status: Needs review » Reviewed & tested by the community
grimreaper’s picture

Version: 8.x-1.8 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

Hi,

Thanks for your work on this issue.

Changing status to needs work as the change is missing a hook_update_N.

Also tests needs to be updated.

It may be better to wait for #3456786: Remove user 1 special behavior to avoid user 1 side effects.

grimreaper’s picture

Version: 8.x-1.x-dev » 2.x-dev

anton4uk made their first commit to this issue’s fork.

anton4uk’s picture

Status: Needs work » Needs review
Issue tags: +LutskGCW26
grimreaper’s picture

Status: Needs review » Needs work

Hi,

Thanks for your work, I made some review comments.

I have not tested, and am surprised that tests do not need to be updated.

anton4uk’s picture

Status: Needs work » Needs review

grimreaper’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.