Same name and namespace in other branches
  1. 7.x includes/menu.inc \_menu_update_parental_status()

Check and update the has_children status for the parent of a link.

Related topics

3 calls to _menu_update_parental_status()
menu_link_save in includes/menu.inc
Save a menu link.
_menu_delete_item in includes/menu.inc
Helper function for menu_link_delete; deletes a single menu link.
_menu_link_move_children in includes/menu.inc
Update the children of a menu link that's being moved.

File

includes/menu.inc, line 2243
API for the Drupal menu system.

Code

function _menu_update_parental_status($item, $exclude = FALSE) {

  // If plid == 0, there is nothing to update.
  if ($item['plid']) {

    // We may want to exclude the passed link as a possible child.
    $where = $exclude ? " AND mlid != %d" : '';

    // Check if at least one visible child exists in the table.
    $parent_has_children = (bool) db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND plid = %d AND hidden = 0" . $where, $item['menu_name'], $item['plid'], $item['mlid'], 0, 1));
    db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $parent_has_children, $item['plid']);
  }
}