You are here

function admin_menu_get_menu in Administration menu 5

Same name and namespace in other branches
  1. 5.3 admin_menu.module \admin_menu_get_menu()
  2. 5.2 admin_menu.module \admin_menu_get_menu()

Retrieves, sclices and returns the menu tree below /admin.

1 call to admin_menu_get_menu()
admin_menu_footer in ./admin_menu.module
Implementation of hook_footer().

File

./admin_menu.inc, line 6

Code

function admin_menu_get_menu() {
  global $_menu;
  $admin_items = array();

  // get path id of /q=admin, which we suppose to be the root of admin menu
  $mid_admin = $_menu['path index']['admin'];

  // Temporary access permissions fix for root menu items until #126621 is committed to core.
  foreach ($_menu['items'][$mid_admin]['children'] as $key => $parent) {
    if ($_menu['items'][$parent]['access'] != false || !isset($_menu['items'][$parent]['children'])) {
      continue;
    }
    $is_accessible = false;
    foreach ($_menu['items'][$parent]['children'] as $key => $child) {
      if ($_menu['items'][$child]['access'] == true) {
        $is_accessible = true;
      }
    }
    if ($is_accessible) {
      $_menu['items'][$parent]['access'] = true;
    }
  }

  // slice admin menu items into a new menu tree
  $admin_items[$mid_admin] = $_menu['items'][$mid_admin];
  _admin_menu_get_children($admin_items, $admin_items[$mid_admin]);

  // adjust some specific menu items for better user experience
  admin_menu_adjust_items($admin_items);

  // remove administer menu item from parent's children list
  $parent_id = $_menu['items'][$mid_admin]['pid'];
  $child_key = array_search($mid_admin, $_menu['visible'][$parent_id]['children']);
  unset($_menu['visible'][$parent_id]['children'][$child_key]);
  return theme('admin_menu_tree', $admin_items, $mid_admin);
}