menu_node_edit_check_user

Versions
menu_node_edit
menu_node_edit_check_user($items, $account = NULL)

Check to see if a user can access a menu item.

This check succeeds if the user has access to the most granular 'section' assigned by the module settings.

Parameters

$items The menu item(s) being viewed. This is passed as an array.

$account The user account being checked (optional).

Return value

Boolean TRUE/FALSE for access.

Code

./menu_node_edit.module, line 211

<?php
function menu_node_edit_check_user($items, $account = NULL) {
  global $user;
  if (empty($account)) {
    $account = $user;
  }
  // Load the users's permissions.
  $account->menu_node_edit = menu_node_edit_load_access($account);
  // If none, then deny access.
  if (empty($account->menu_node_edit)) {
    return FALSE;
  }
  // Loop through the matching items.
  foreach ($items as $item) {
    // Now, check for access to this menu item.
    // If we match on the mlid iteself, this is simple.
    if (in_array($item->mlid, $account->menu_node_edit)) {
      return TRUE;
    }
    // OK, now check the parent, also easy.
    if (in_array($item->plid, $account->menu_node_edit)) {
      return TRUE;
    }
    // Not found yet? OK, check the parent tree.
    for ($i = 1; $i <= 9; $i++) {
      $id = "p$i";
      if (in_array($item->$id, $account->menu_node_edit)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List