You are here

function simple_access_menu in Simple Access 5.2

Same name and namespace in other branches
  1. 5 simple_access.module \simple_access_menu()
  2. 6.2 simple_access.module \simple_access_menu()
  3. 7.2 simple_access.module \simple_access_menu()

Implementation of hook_menu().

File

./simple_access.module, line 27
This module allows administrators to make nodes viewable by specific 'access groups'. Each access group can contain any number of roles. If a node is not assigned to any access groups, it will remain viewable by all users.

Code

function simple_access_menu($may_cache) {
  $access = user_access('manage simple access');
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/user/simple_access',
      'title' => t('Access groups'),
      'access' => $access,
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'simple_access_page_overview',
      ),
      'type' => MENU_NORMAL_ITEM,
      'description' => t('Manage groups of users for node-specific access control.'),
    );
    $items[] = array(
      'path' => 'admin/user/simple_access/list',
      'title' => t('List'),
      'access' => $access,
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -8,
    );
    $items[] = array(
      'path' => 'admin/user/simple_access/add',
      'title' => t('Add Group'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'simple_access_group_form',
      ),
      'access' => $access,
      'type' => MENU_LOCAL_TASK,
      'weight' => -6,
    );
    $items[] = array(
      'path' => 'admin/user/simple_access/edit',
      'title' => t('Edit Group'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'simple_access_group_form',
      ),
      'access' => $access,
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/user/simple_access/delete',
      'title' => t('Delete Group'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'simple_access_delete_group_confirm',
      ),
      'access' => $access,
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/user/sa_profiles',
      'title' => t('Access profiles'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'simple_access_profile_list',
      ),
      'access' => $access,
      'type' => MENU_NORMAL_ITEM,
      'description' => t('Maintain access profiles'),
    );
    $items[] = array(
      'path' => 'admin/user/sa_profiles/list',
      'title' => t('List'),
      'access' => $access,
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -9,
    );
    $items[] = array(
      'path' => 'admin/user/sa_profiles/add',
      'title' => t('Add'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'simple_access_profile_form',
      ),
      'access' => $access,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/simple_access',
      'title' => t('Simple Access'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'simple_access_settings_page',
      ),
      'access' => $access,
      'type' => MENU_NORMAL_ITEM,
      'description' => t('Configure which kinds of access (view, edit, delete) users with permission to use Simple Access can define for each node.'),
    );
    $items[] = array(
      'path' => 'admin/content/simple_access',
      'title' => t('Simple Access'),
      'access' => user_access('administer nodes'),
      'callback' => 'simple_access_nodes',
      'type' => MENU_NORMAL_ITEM,
      'description' => t('View node access which has been set up via Simple Access.'),
    );
    $items[] = array(
      'path' => 'admin/content/simple_access/view',
      'title' => t('View'),
      'callback' => 'simple_access_nodes',
      'access' => user_access('administer nodes'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -5,
    );
    $items[] = array(
      'path' => 'admin/content/simple_access/edit',
      'title' => t('Edit Access'),
      'callback' => 'simple_access_nodes',
      'access' => user_access('administer nodes'),
      'type' => MENU_CALLBACK,
      'weight' => -4,
    );
    $items[] = array(
      'path' => 'admin/content/simple_access/delete',
      'title' => t('Delete Access'),
      'callback' => 'simple_access_nodes',
      'access' => user_access('administer nodes'),
      'type' => MENU_CALLBACK,
      'weight' => -3,
    );
  }
  else {
    if (arg(0) == 'admin' && arg(1) == 'user' && arg(2) == 'sa_profiles' && is_numeric(arg(3))) {
      $items[] = array(
        'path' => 'admin/user/sa_profiles/' . arg(3) . '/edit',
        'title' => t('Edit Profile'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'simple_access_profile_form',
          arg(3),
        ),
        'access' => $access,
        'type' => MENU_CALLBACK,
      );
      $items[] = array(
        'path' => 'admin/user/sa_profiles/' . arg(3) . '/delete',
        'title' => t('Delete Profile'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'simple_access_profile_delete_confirm',
          arg(3),
        ),
        'access' => $access,
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}