Skip to content
Snippets Groups Projects
Commit bc2a814c authored by Angie Byron's avatar Angie Byron
Browse files

#519046 by catch, pwolanin: Fix how toolbar_get_menu_tree() determines menu to...

#519046 by catch, pwolanin: Fix how toolbar_get_menu_tree() determines menu to remove unneeded calls to _menu_check_access().
parent 40052b63
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -111,19 +111,18 @@ function toolbar_build() {
* Get only the top level items below the 'admin' path.
*/
function toolbar_get_menu_tree() {
$tree = menu_tree_all_data('management');
foreach ($tree as $item) {
if ($item['link']['link_path'] == 'admin' && !empty($item['below'])) {
// Only take items right below the 'admin' path. All other management
// items are discarded.
$tree = $item['below'];
break;
$tree = array();
$admin_link = db_query("SELECT * FROM {menu_links} WHERE menu_name = 'management' AND module = 'system' AND link_path = 'admin'")->fetchAssoc();
if ($admin_link) {
$tree = menu_tree_all_data('management', $admin_link);
// The tree will be a sub-tree with the admin link as a single root item.
$admin_link = array_pop($tree);
$tree = $admin_link['below'] ? $admin_link['below'] : array();
foreach ($tree as $key => $item) {
// Get rid of subitems to have a leaner data structure.
unset($tree[$key]['below']);
}
}
foreach ($tree as $key => $item) {
// Get rid of subitems to have a leaner data structure.
unset($tree[$key]['below']);
}
return $tree;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment