function _admin_menu_get_children in Administration menu 5.3
Same name and namespace in other branches
- 5 admin_menu.inc \_admin_menu_get_children()
- 5.2 admin_menu.inc \_admin_menu_get_children()
Recursively adds items to the administration menu.
Any accessible menu items are added, including local tasks.
Parameters
$_admin_menu: An array containing the complete administration menu structure, passed by reference.
$item: The (starting) menu item to use for the administration menu.
1 call to _admin_menu_get_children()
- admin_menu_build in ./
admin_menu.inc - Rebuild administration menu links.
File
- ./
admin_menu.inc, line 81 - Menu build functions for Administration menu.
Code
function _admin_menu_get_children(&$_admin_menu, &$item) {
global $_menu;
if (isset($item['children'])) {
foreach ($item['children'] as $child) {
// Check access permissions.
if (!variable_get('admin_menu_show_all', 0)) {
$item_is_accessible = FALSE;
if (!isset($_menu['items'][$child]['access'])) {
// If parent item is one of the admin categories and uses our custom
// 'access' value defined in admin_menu_build(), then it is not
// accessible.
if (isset($item['access']) && $item['access'] === 1) {
$item_is_accessible = $_menu['items'][$child]['access'] = FALSE;
}
elseif (isset($item['access']) && $item['access']) {
$item_is_accessible = TRUE;
}
else {
$item_is_accessible = _menu_item_is_accessible($child);
}
}
else {
$item_is_accessible = $_menu['items'][$child]['access'];
}
}
else {
$item_is_accessible = TRUE;
}
// Check menu item type.
$item_is_visible = $_menu['items'][$child]['type'] & (MENU_VISIBLE_IN_TREE | MENU_IS_LOCAL_TASK);
// Create the child item if it is accessible and visible.
if ($item_is_accessible && $item_is_visible) {
$_admin_menu[$child] = $_menu['items'][$child];
admin_menu_item_url($_admin_menu, $child);
// Recurse to child menu items.
if (isset($_menu['items'][$child]['children'])) {
_admin_menu_get_children($_admin_menu, $_admin_menu[$child]);
// Sort items.
usort($_admin_menu[$child]['children'], '_admin_menu_sort');
}
// Remove this child item if it is visible in the navigation.
unset($_menu['visible'][$child]);
}
else {
// Remove child menu item from parent's children list.
$parent_id = $_menu['items'][$child]['pid'];
if (isset($_menu['items'][$parent_id]['children']) && is_array($_menu['items'][$parent_id]['children'])) {
$child_key = array_search($child, $_menu['items'][$parent_id]['children']);
if ($child_key !== FALSE) {
unset($_admin_menu[$parent_id]['children'][$child_key]);
}
}
}
}
}
}