diff --git a/includes/menu.inc b/includes/menu.inc index d127df6..7ad6651 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -994,16 +994,19 @@ function menu_get_object($type = 'node', $position = 1, $path = NULL) { * * @param $menu_name * The name of the menu. + * @param $skip_hidden + * (optional) Improve performance by skipping hidden menu links in tree + * see _menu_tree_check_access * * @return * A structured array representing the specified menu on the current page, to * be rendered by drupal_render(). */ -function menu_tree($menu_name) { +function menu_tree($menu_name, $skip_hidden = FALSE) { $menu_output = &drupal_static(__FUNCTION__, array()); if (!isset($menu_output[$menu_name])) { - $tree = menu_tree_page_data($menu_name); + $tree = menu_tree_page_data($menu_name, $skip_hidden); $menu_output[$menu_name] = menu_tree_output($tree); } return $menu_output[$menu_name]; @@ -1215,6 +1218,9 @@ function menu_tree_get_path($menu_name) { * (optional) Whether to only return the links in the active trail (TRUE) * instead of all links on every level of the menu link tree (FALSE). Defaults * to FALSE. Internally used for breadcrumbs only. + * @param $skip_hidden + * (optional) Improve performance by skipping hidden menu links in tree + * see _menu_tree_check_access * * @return * An array of menu links, in the order they should be rendered. The array @@ -1223,7 +1229,7 @@ function menu_tree_get_path($menu_name) { * submenu below the link if there is one, and it is a subtree that has the * same structure described for the top-level array. */ -function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) { +function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE, $skip_hidden = FALSE) { $tree = &drupal_static(__FUNCTION__, array()); // Check if the active trail has been overridden for this menu tree. @@ -2382,11 +2388,14 @@ function menu_set_active_item($path) { * Menu trail to set; the value is saved in a static variable and can be * retrieved by menu_get_active_trail(). The format of this array should be * the same as the return value of menu_get_active_trail(). + * @param $skip_hidden + * (optional) Improve performance by skipping hidden menu links in tree + * see _menu_tree_check_access * * @return * The active trail. See menu_get_active_trail() for details. */ -function menu_set_active_trail($new_trail = NULL) { +function menu_set_active_trail($new_trail = NULL, $skip_hidden = FALSE) { $trail = &drupal_static(__FUNCTION__); if (isset($new_trail)) { @@ -2412,7 +2421,7 @@ function menu_set_active_trail($new_trail = NULL) { // Pass TRUE for $only_active_trail to make menu_tree_page_data() build // a stripped down menu tree containing the active trail only, in case // the given menu has not been built in this request yet. - $tree = menu_tree_page_data($preferred_link['menu_name'], NULL, TRUE); + $tree = menu_tree_page_data($preferred_link['menu_name'], NULL, TRUE, $skip_hidden); list($key, $curr) = each($tree); } // There is no link for the current path.