Hi,

I'm trying to install the 'Menu Per Role' module but I'm not sure which section I need to replace within the the Menu.module.

Would anyone be kind enough to explain?

Thank you, please excuse my naivety,

Michael

Comments

michrid’s picture

Unless anybody could tell me which bit of this is "the leading plus"?

I'd really appreciate any help, I'm rather desperate...

Thank you

Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.120.2.8
diff -u -r1.120.2.8 menu.inc
--- includes/menu.inc 11 Dec 2006 17:30:36 -0000 1.120.2.8
+++ includes/menu.inc 6 Jan 2007 15:17:52 -0000
@@ -1107,6 +1107,9 @@

// If the administrator has changed the item, reflect the change.
if ($item->type & MENU_MODIFIED_BY_ADMIN) {
+ if (module_exist('menu_per_role') && !is_null($access = menu_per_role_access($item->mid))) {
+ $_menu['items'][$item->mid]['access'] = isset($_menu['items'][$item->mid]['access']) ? $_menu['items'][$item->mid]['access'] && $access : $access;
+ }
$_menu['items'][$item->mid]['title'] = $item->title;
$_menu['items'][$item->mid]['description'] = $item->description;
$_menu['items'][$item->mid]['pid'] = $item->pid;

marcoBauli’s picture

1. open the menu.inc file in your ./drupal/includes folder and search the line that says
// If the administrator has changed the item, reflect the change.
(should be around line 1107)

2. paste the following three lines:

        if (module_exist('menu_per_role') && !is_null($access = menu_per_role_access($item->mid))) {
          $_menu['items'][$item->mid]['access'] = isset($_menu['items'][$item->mid]['access']) ? $_menu['items'][$item->mid]['access'] && $access : $access;
        }

right below if ($item->type & MENU_MODIFIED_BY_ADMIN) {

so that the final code will look like:

       // If the administrator has changed the item, reflect the change.
       if ($item->type & MENU_MODIFIED_BY_ADMIN) {
        if (module_exist('menu_per_role') && !is_null($access = menu_per_role_access($item->mid))) {
          $_menu['items'][$item->mid]['access'] = isset($_menu['items'][$item->mid]['access']) ? $_menu['items'][$item->mid]['access'] && $access : $access;
        }
         $_menu['items'][$item->mid]['title'] = $item->title;
         $_menu['items'][$item->mid]['description'] = $item->description;
         $_menu['items'][$item->mid]['pid'] = $item->pid;

3. save it.

Here you go, hope it helps!

guschnit’s picture

hi
when I add the 3 lines I get the following error message

Fatal error: Call to undefined function: module_exist() in .....includes/menu.inc on line 1133

and ideas?
regards
gustavo.

baraban’s picture

module_exist() is one of the core functions: http://api.drupal.org/api/4.7/function/module_exist
If you are getting this error your installation was probably modified from standard.

http://www.baraban.com
Russians in America

bazdrupal’s picture

Hi,
I've added the patch and don't have any errors on my page.
The problem is that once i've done this, the menu module disappears from my Site building section inside my administrator interface?

The other thing that i don't understand is that, when i give a menu item to a role and then log in
with the user associated with this role i have access to the whole menu module.

Could anyone help please.

baz

bazdrupal’s picture

Hi,
I've added the patch and don't have any errors on my page.
The problem is that once i've done this, the menu module disappears from my Site building section inside my administrator interface?

The other thing that i don't understand is that, when i give a menu item to a role and then log in
with the user associated with this role i have access to the whole menu module.

Could anyone help please.

baz