You are here

function admin_menu_move_item in Administration menu 5.3

Same name and namespace in other branches
  1. 5 admin_menu.inc \admin_menu_move_item()
  2. 5.2 admin_menu.inc \admin_menu_move_item()

Moves the child pointer of a menu item to a new parent.

Parameters

array $_admin_menu: An array containing the complete administration menu structure, passed by reference.

int $mid: The menu item id of the item to move.

int $pid: The menu item id of the new parent.

1 call to admin_menu_move_item()
admin_menu_adjust_items in ./admin_menu.inc
Add some hard-coded features for better user experience.

File

./admin_menu.inc, line 383
Menu build functions for Administration menu.

Code

function admin_menu_move_item(&$_admin_menu, $mid, $pid) {
  global $_menu;
  if (isset($_admin_menu[$mid]) && isset($_admin_menu[$pid])) {

    // Remove current child pointer. Determine the path from the index
    // because it contains the unprocessed urls.
    $index = array_flip($_admin_menu['index']);
    admin_menu_remove_item($_admin_menu, $index[$mid]);

    // Insert new child pointer.
    $_admin_menu[$mid]['pid'] = $pid;
    $_admin_menu[$pid]['children'][] = $mid;

    // Sort items.
    usort($_admin_menu[$pid]['children'], '_admin_menu_sort');
    return TRUE;
  }
  return FALSE;
}