You are here

function content_access_menu in Content Access 5

Same name and namespace in other branches
  1. 6 content_access.module \content_access_menu()
  2. 7 content_access.module \content_access_menu()

File

./content_access.module, line 10

Code

function content_access_menu($may_cache) {
  global $user;
  $items = array();
  if (!$may_cache) {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if (!empty($node) && content_access_get_settings('per_node', $node->type)) {
        $items[] = array(
          'path' => 'node/' . $node->nid . '/access',
          'title' => t('Access control'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'content_access_page',
            $node->nid,
          ),
          'access' => user_access('grant content access') || user_access('grant own content access') && $user->uid == $node->uid,
          'weight' => 5,
          'type' => MENU_LOCAL_TASK,
        );
      }
    }
    if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'types' && arg(3)) {
      $type = str_replace('-', '_', arg(3));
      if ($type_name = node_get_types('name', $type)) {
        $items[] = array(
          'path' => 'admin/content/types/' . arg(3) . '/edit',
          'title' => t('Edit'),
          'type' => MENU_DEFAULT_LOCAL_TASK,
        );
        $items[] = array(
          'path' => 'admin/content/types/' . arg(3) . '/access',
          'title' => t('Access control'),
          'description' => t('Configure content access control.'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'content_access_admin_settings',
            $type,
          ),
          'access' => user_access('administer nodes') && user_access('administer content types'),
          'type' => MENU_LOCAL_TASK,
          'weight' => 2,
        );
      }
    }
  }
  return $items;
}