function _tb_megamenu_access in The Better Mega Menu 7
Access callback: Checks TB Megamenu config access.
Parameters
$menu: The menu name provided in the route.
object $account: (optional) A user object representing the user for whom the operation is to be performed. Determines access for a user other than the current user.
Return value
TRUE if access is allowed, FALSE otherwise.
1 string reference to '_tb_megamenu_access'
- tb_megamenu_menu in ./
tb_megamenu.module - Implements hook_menu().
File
- ./
tb_megamenu.module, line 70
Code
function _tb_megamenu_access($menu, $account = NULL) {
$access =& drupal_static(__FUNCTION__, array());
if (!$menu || !is_array($menu)) {
// If there was no menu to check against we return access denied.
return FALSE;
}
// Get the machine name for the menu.
$menu_name = reset($menu);
// Get the current user's account if no user was specified.
if (!isset($account)) {
$account = $GLOBALS['user'];
}
// Statically cache access by menu name and user account ID.
$cid = $menu_name . ':' . $account->uid;
if (!isset($access[$cid])) {
// Perform basic permission checks first.
if (!user_access('administer tb_megamenu', $account)) {
return $access[$cid] = FALSE;
}
// Check access on the specific route.
$access[$cid] = drupal_valid_path('admin/structure/menu/manage/' . $menu_name) ? TRUE : FALSE;
}
return $access[$cid];
}