function menu_tree_check_access

Checks access and performs 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 drupal/core/modules/book/book.module
Gets the data representing a subtree of the book hierarchy.
menu_build_tree in drupal/core/includes/menu.inc
Builds a menu tree, translates links, and checks access.
menu_overview_form in drupal/core/modules/menu/menu.admin.inc
Form constructor to edit an entire menu tree at once.
TreeAccessTest::testRouteItemMenuLinksAccess in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/TreeAccessTest.php
Tests access check for menu links with a route item.

File

drupal/core/includes/menu.inc, line 1492
API for the Drupal menu system.

Code

function menu_tree_check_access(&$tree, $node_links = array()) {
  if ($node_links) {
    $nids = array_keys($node_links);
    $select = db_select('node_field_data', 'n');
    $select
      ->addField('n', 'nid');

    // @todo This should be actually filtering on the desired node status field
    //   language and just fall back to the default language.
    $select
      ->condition('n.status', 1);
    $select
      ->condition('n.nid', $nids, 'IN');
    $select
      ->addTag('node_access');
    $nids = $select
      ->execute()
      ->fetchCol();
    foreach ($nids as $nid) {
      foreach ($node_links[$nid] as $mlid => $link) {
        $node_links[$nid][$mlid]['access'] = TRUE;
      }
    }
  }
  _menu_tree_check_access($tree);
}