function menu_tree_check_access

Checks access and performs dynamic operations for each link in the tree.


$tree: The menu tree you wish to operate on.

$node_links: A collection of node link references generated from $tree by menu_tree_collect_node_links().

Related topics

3 calls to menu_tree_check_access()
book_menu_subtree_data in drupal/modules/book/book.module
Gets the data representing a subtree of the book hierarchy.
menu_build_tree in drupal/includes/
Builds a menu tree, translates links, and checks access.
menu_overview_form in drupal/modules/menu/
Form for editing an entire menu tree at once.


drupal/includes/, line 1497
API for the Drupal menu system.


function menu_tree_check_access(&$tree, $node_links = array()) {
  if ($node_links && (user_access('access content') || user_access('bypass node access'))) {
    $nids = array_keys($node_links);
    $select = db_select('node', 'n');
      ->addField('n', 'nid');
      ->condition('n.status', 1);
      ->condition('n.nid', $nids, 'IN');
    $nids = $select
    foreach ($nids as $nid) {
      foreach ($node_links[$nid] as $mlid => $link) {
        $node_links[$nid][$mlid]['access'] = TRUE;