You are here

function tokenauth_menu in Token authentication 5

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

Implementation of hook_menu().

File

./tokenauth.module, line 51

Code

function tokenauth_menu($may_cache) {
  global $user;
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/tokenauth',
      'title' => t('Token authentication'),
      'description' => t('Configure length of tokens, specify which pages accept authentication via token, and reset all tokens, etc.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'tokenauth_admin_settings',
      'access' => user_access('administer tokenauth'),
    );
    $items[] = array(
      'path' => 'admin/settings/tokenauth/reset',
      'title' => t('Reset tokens'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'tokenauth_reset_confirm',
      ),
      'access' => user_access('administer tokenauth'),
      'type' => MENU_CALLBACK,
    );
  }
  else {
    if (arg(0) == 'user' && is_numeric(arg(1))) {
      $items[] = array(
        'path' => 'user/' . arg(1) . '/tokenauth',
        'title' => t('Token auth'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'tokenauth_user_profile_form',
          arg(1),
        ),
        'access' => (user_access('administer users') || $user->uid == arg(1)) && user_access('access tokenauth'),
        'type' => MENU_IS_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'user/' . arg(1) . '/tokenauth/reset',
        'title' => t('Reset token'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'tokenauth_user_reset_confirm',
        ),
        'access' => (user_access('administer users') || $user->uid == arg(1)) && user_access('access tokenauth'),
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}