Cascade Effect
rfranquet - March 14, 2008 - 17:40
| Project: | Menu per Role |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
To disable a menu with all submenus try to add the next code in a includes/menu.inc in the _menu_build_visible_tree Function at line 1179:
if (module_exists('menu_per_role') && !is_null($access = menu_per_role_access($pid))) {
if( $access == 0 ){
return array();
}
}like this:
/**
* Find all visible items in the menu tree, for ease in displaying to user.
*
* Since this is only for display, we only need title, path, and children
* for each item.
*/
function _menu_build_visible_tree($pid = 0) {
global $_menu;
if (isset($_menu['items'][$pid])) {
$parent = $_menu['items'][$pid];
$children = array();
if (isset($parent['children'])) {
usort($parent['children'], '_menu_sort');
foreach ($parent['children'] as $mid) {
$children = array_merge($children, _menu_build_visible_tree($mid));
}
}
$visible = ($parent['type'] & MENU_VISIBLE_IN_TREE) ||
($parent['type'] & MENU_VISIBLE_IF_HAS_CHILDREN && count($children) > 0);
$allowed = _menu_item_is_accessible($pid);
<strong>
if (module_exists('menu_per_role') && !is_null($access = menu_per_role_access($pid))) {
if( $access == 0 ){
return array();
}
}
</strong>
if (($parent['type'] & MENU_IS_ROOT) || ($visible && $allowed)) {
$_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children, 'type' => $parent['type']);
foreach ($children as $mid) {
$_menu['visible'][$mid]['pid'] = $pid;
}
return array($pid);
}
else {
return $children;
}
}
return array();
}Please check if it works fine in your system.
Regards.

#1
WARNING !!!
Please, remove
<strong>and</strong>