diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-05-08 07:17:47 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-05-08 07:17:47 +0000 |
commit | 3de9d33e67999a7dc30664d1c49a5a9313d00a00 (patch) | |
tree | 81c68188a4f552a441ce6989791f903cd23390b4 /includes | |
parent | 7bf77b6a5e365dc42670e5b6efea338b858f8f34 (diff) | |
download | brdo-3de9d33e67999a7dc30664d1c49a5a9313d00a00.tar.gz brdo-3de9d33e67999a7dc30664d1c49a5a9313d00a00.tar.bz2 |
- Menu and code improvements by JonBob.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/menu.inc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/includes/menu.inc b/includes/menu.inc index e5ee1a0d4..0e208786b 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -25,7 +25,7 @@ define('MENU_FOUND', 2); * Register a menu item with the menu system. * * @ingroup menu - * @param $path Location then menu item refers to. + * @param $path Location the menu item refers to. Do not add a trailing slash. * @param $title The title of the menu item to show in the rendered menu. * @param $callback * - string - The function to call when this is the active menu item. @@ -394,8 +394,23 @@ function menu_build_visible_tree($pid = 0) { $children = array_merge($children, menu_build_visible_tree($mid)); } } - if ((($parent['visibility'] == MENU_SHOW) || - ($parent['visibility'] == MENU_HIDE_NOCHILD && count($children) > 1)) && $parent['callback'] !== MENU_DENIED) { + $visible = ($parent['visibility'] == MENU_SHOW) || + ($parent['visibility'] == MENU_HIDE_NOCHILD && count($children) > 0); + + if ($parent['callback'] === MENU_FALLTHROUGH) { + // Follow the path up to find the actual callback. + $path = $parent['path']; + while ($path && (!$_menu['path index'][$path] || $_menu['items'][$_menu['path index'][$path]]['callback'] === MENU_FALLTHROUGH)) { + $path = substr($path, 0, strrpos($path, '/')); + } + $callback_mid = $_menu['path index'][$path]; + $allowed = $_menu['items'][$callback_mid]['callback'] !== MENU_DENIED; + } + else { + $allowed = $parent['callback'] !== MENU_DENIED; + } + + if ($visible && $allowed) { $_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children); foreach ($children as $mid) { $_menu['visible'][$mid]['pid'] = $pid; |