My company recently wanted to use admin_menu on a client site, but we also wanted to be able to have the module load custom menus depending on the user role. So I hacked admin_menu to do just that, and it seems like it might be a worthwhile addition to the next release of the module.

This patch adds a few extra controls to the admin_menu configuration form. You can choose which roles (out of the ones with the "access administration menu" permission) get to see which menu, and assign weights to each rule to account for users with more than one role. The super-administrator (user 1) always gets the full admin_menu, regardless of role.

Apply the patch from the main modules directory, like so:

cd sites/default/modules (or wherever your modules directory is)
patch -p0 < admin_menu.inc.patch
patch -p0 < admin_menu.module.patch

This patch is for Drupal 6.x only!

Comments

sun’s picture

Status: Needs review » Needs work

Your coding-style needs work. Please read http://drupal.org/coding-standards carefully. Additionally, please do not use tabs (2 spaces instead), and place inline comments above the remarked line (not behind it).

Also, could use please elaborate a bit more on what this patch does, your concrete use-case, and why you implemented it that way?

philingle’s picture

I think that this is a great idea. I only have 6.x-3.0-alpha3 on my dev sites at the minute so cant test it out but I second the idea of adding this feature to the admin menu.
I currently create individual admin menu's for my users but have to put them in blocks on the site somewhere, it would be far better if they could have their own custom admin menu.

klonos’s picture

+1

...subscribing.

sun’s picture

Version: 6.x-1.1 » 7.x-3.x-dev
klonos’s picture

Hope to see this in D6 as well once done with D7.

mattgilbert’s picture

subscribing

I also would like to see this with Drupal 6.

manoloka’s picture

subscribe

nancydru’s picture

Don't know what happened to the OP.

@Sun: My use case: We have several different departments using the site. The Communications department "owns" it and does most of the maintenance (IT does the rest). There are, however, other departments who create content. Some departments can create some types of content, others other types. Communications may create or alters users; one department has to maintain a sidebar block. There are many combinations of permissions, as on many sites. While a standard menu block would handle this, different pages have different block placements. For us, the best place for an administrative menu is at the top, as this module does.

The site is still on 6.x because most of the needed modules are not ready for D7.

Why is there a 7.x branch when this is in core?

jeff.maes’s picture

If you don't need the settings in the back-end, you could do something like this in your own module:

<?php
/**
 * Implementation of drupal_alter('admin_menu_output', $content)
 */
function mymodule_admin_menu_output_alter(&$content) {
  // If the user has a specific role, show him another admnu menu
  global $user;
  if(in_array('eurogifts administrator', $user->roles)) {
    $content['menu'] = admin_menu_links_menu(admin_menu_tree('PUT-YOUR-MENU-NAME-IN-HERE'));
    $content['menu']['#theme'] = 'admin_menu_links';
    $content['menu']['#weight'] = 0;
    $content['menu']['#sorted'] = TRUE;
  }
}
?>

I think it's cleaner than patching the module.
Tested and working with the 7.x-3.x-dev version of 2011-May-06

travelertt’s picture

Why not have Admin Menu work the same way as the Toolbar in D7. Where Menu Items appear in the menu according to the permissions of the user? This could be the default functionality of the menu. Honestly, as someone new to Drupal, this is what I expected Administration menu to do.
I was surprised to find out that after I had set my site up, that my site Editors (role) were unable to see any menu items, and my site Editors(role) the other case had access to more menu options than their permissions allowed. Now I'm not implying that I enabled this Module for all users, just users that I had granted limited rights to moderate and edit my site.

sun’s picture

Title: Assign different admin menus to user roles » Allow to configure different menu to use for certain roles
Status: Needs work » Active
  1. Administration menu is not in core.
  2. All links in the menu are restricted to the permissions of the currently logged in user, as always.
  3. This issue aims to allow to configure different menus to use for certain user roles, while keeping the default "Management" menu for all others by default.
sun’s picture

FWIW: http://drupal.org/project/admin_menu_source

This link does not mean that I recommend to use that module. In fact, the module's implementation can easily blow up.

truls1502’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)
Issue tags: +postponed2w

I am sorry for no reply until now.

There are many issues regarding this module admin_menu which is a bit difficult for us to follow up since some of the issues might be already outdated, or is already fixed by the module or any other modules or itself core which means that the problem might no longer need to be fixed.

We can see that the issue has been created for a few years ago, I hope it is okay for you that I am postponing the issue, and give you around two weeks. If you still face the problem, could you tell us the step by step when until you get the error message or what is frustrated you, and a list of modules you are using related to admin_menu and a screenshot that might help us? So it makes us easier to reproduce your issue.

However, after two weeks with no feedback - we will close this issue. So in case, you noticed it after the issue is closed, do not hesitate to reopen it like and fill information which is mentioned above.

So before giving us a feedback, do you mind to test it again with our latest 7.x-3.x-dev?

Thank you for understanding! :)

truls1502’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
Issue tags: -postponed2w

This issue has been automatically marked as closed because it has not had recent activity after the last post.

However, if you or someone is still facing the same issue as described to the issue, could you please to re-open the issue by changing the status of the issue, and add an explanation with more details which can help us to reproduce your situation.

Again, thank you for your contributions! :)