_menu_check_access

  1. drupal
    1. 6
    2. 8
    3. 7
Versions
6 – 8 _menu_check_access(&$item, $map)

Check access to a menu item using the access callback

Parameters

$item A menu router or menu link item

$map An array of path arguments (ex: array('node', '5'))

Return value

$item['access'] becomes TRUE if the item is accessible, FALSE otherwise.

Related topics

▾ 2 functions call _menu_check_access()

_menu_link_translate in includes/menu.inc
This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions
_menu_translate in includes/menu.inc
Handles dynamic path translation and menu access control.

Code

includes/menu.inc, line 606

<?php
function _menu_check_access(&$item, $map) {
  // Determine access callback, which will decide whether or not the current
  // user has access to this path.
  $callback = empty($item['access_callback']) ? 0 : trim($item['access_callback']);
  // Check for a TRUE or FALSE value.
  if (is_numeric($callback)) {
    $item['access'] = (bool) $callback;
  }
  else {
    $arguments = menu_unserialize($item['access_arguments'], $map);
    // As call_user_func_array is quite slow and user_access is a very common
    // callback, it is worth making a special case for it.
    if ($callback == 'user_access') {
      $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
    }
    elseif (function_exists($callback)) {
      $item['access'] = call_user_func_array($callback, $arguments);
    }
  }
}
?>