You are here

function nodeaccess_menu in Nodeaccess 5

Same name and namespace in other branches
  1. 6.2 nodeaccess.module \nodeaccess_menu()
  2. 6 nodeaccess.module \nodeaccess_menu()
  3. 7 nodeaccess.module \nodeaccess_menu()

Implementation of hook_menu().

File

./nodeaccess.module, line 15

Code

function nodeaccess_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/user/nodeaccess',
      'title' => t('Nodeaccess'),
      'callback' => 'nodeaccess_admin',
      'access' => user_access('administer nodeaccess'),
      'description' => t('Change default settings for the Nodeaccess module.'),
    );
  }
  else {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if (nodeaccess_access('grant', $node)) {
        $items[] = array(
          'path' => 'node/' . $node->nid . '/grant',
          'title' => t('Grant'),
          'callback' => 'nodeaccess_grants',
          'callback arguments' => $node->nid,
          'access' => nodeaccess_access('grant', $node),
          'weight' => 5,
          'type' => MENU_LOCAL_TASK,
        );
      }
    }
  }
  return $items;
}