function _menu_delete_item

7.x menu.inc _menu_delete_item($item, $force = FALSE)
6.x menu.inc _menu_delete_item($item, $force = FALSE)

Helper function for menu_link_delete; deletes a single menu link.

Parameters

$item: Item to be deleted.

$force: Forces deletion. Internal use only, setting to TRUE is discouraged.

Related topics

3 calls to _menu_delete_item()
drupal_uninstall_module in drupal-6.x/includes/install.inc
Calls the uninstall function and updates the system table for a given module.
menu_link_delete in drupal-6.x/includes/menu.inc
Delete one or several menu links.
_menu_navigation_links_rebuild in drupal-6.x/includes/menu.inc
Helper function to build menu links for the items in the menu router.

File

drupal-6.x/includes/menu.inc, line 1866
API for the Drupal menu system.

Code

function _menu_delete_item($item, $force = FALSE) {
  if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) {
    // Children get re-attached to the item's parent.
    if ($item['has_children']) {
      $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = %d", $item['mlid']);
      while ($m = db_fetch_array($result)) {
        $child = menu_link_load($m['mlid']);
        $child['plid'] = $item['plid'];
        menu_link_save($child);
      }
    }
    db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']);

    // Update the has_children status of the parent.
    _menu_update_parental_status($item);
    menu_cache_clear($item['menu_name']);
    _menu_clear_page_cache();
  }
}