Drupal menu permissions question
- by Luke
I'm creating an admin module for my client that gives then access to some administration functionality concerning their content. I'm starting off my adding some permissions in my module by implementing hook_perm:
function mymodule_perm()
{
return array(
'manage projects',
);
}
I can then create my menu by adding to the admin section that already exists:
function mymodule_menu()
{
$items['admin/projects'] = array(
'title' => 'Projects',
'description' => 'Manage your projects.',
'page callback' => 'manage_projects_overview',
'access callback' => 'user_access',
'access arguments' => array('manage projects'),
'type' => MENU_NORMAL_ITEM,
'weight' => -100,
);
$items['admin/projects/add'] = array(
'title' => 'Add project',
'access arguments' => array('manage projects'),
'page callback' => 'mymodule_projects_add',
'type' => MENU_NORMAL_ITEM,
'weight' => 1,
);
return $items;
}
This will add a Projects section to the Administration area with an Add project sub section. All good.
The behavior I want is that my client can only see the Projects section when they log in. I've accomplished this by ticking the "manage projects" permission for authenticated users. Now to give my client actual access to the Administration area I also need to tick "access administration pages" under the "system module" in the users permissions section. This works great, when I log in as my client I can only see the Projects section in the Administration area. There is one thing though, I my Navigation menu shown in the left column I can see the following items:
- Administer
- Projects
- Content management
- Site building
- Site configuration
- User management
I was expecting only the see Administer and Projects, not the other ones. When I click e.g. Content Management I get a Content Management titled page with no options. Same for Site Building, Site Configuration and User Management. What's really odd is that Reports is not being shown which is also a top level Administration section.
Why are these other items, besides my Projects section, being shown and how can I make them stop from appearing if I'm not logged in as administrator?