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

Check access and perform other dynamic operations for each link in the tree.

Parameters

$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

4 calls to menu_tree_check_access()
book_menu_subtree_data in modules/book/book.module
Get the data representing a subtree of the book hierarchy.
menu_overview_form in modules/menu/menu.admin.inc
Form for editing an entire menu tree at once.
menu_tree_all_data in includes/menu.inc
Get the data structure representing a named menu tree.
menu_tree_page_data in includes/menu.inc
Get the data structure representing a named menu tree, based on the current page.

File

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

Code

function menu_tree_check_access(&$tree, $node_links = array()) {
  if ($node_links && (user_access('access content') || user_access('bypass node access'))) {

    // Use db_rewrite_sql to evaluate view access without loading each full node.
    $nids = array_keys($node_links);
    $placeholders = '%d' . str_repeat(', %d', count($nids) - 1);
    $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.nid IN (" . $placeholders . ")"), $nids);
    while ($node = db_fetch_array($result)) {
      $nid = $node['nid'];
      foreach ($node_links[$nid] as $mlid => $link) {
        $node_links[$nid][$mlid]['access'] = TRUE;
      }
    }
  }
  _menu_tree_check_access($tree);
  return;
}