You are here

function masquerade_menu in Masquerade 5

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

Implementation of hook_menu().

File

./masquerade.module, line 64
masquerade.module

Code

function masquerade_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $default_test_user = user_load(array(
      'name' => variable_get('masquerade_test_user', ''),
    ));
    if ($default_test_user->uid) {
      $items[] = array(
        'path' => 'masquerade/switch/' . $default_test_user->uid,
        'title' => t('Masquerade as @testuser', array(
          '@testuser' => $default_test_user->name,
        )),
        'access' => !$GLOBALS['masquerading'] && (user_access('masquerade as user') || user_access('masquerade as admin')),
        'type' => MENU_NORMAL_ITEM,
      );
    }
    $items[] = array(
      'path' => 'masquerade/autocomplete',
      'title' => t('Masquerade autocomplete'),
      'callback' => 'masquerade_autocomplete',
      'access' => $GLOBALS['masquerading'] || (user_access('masquerade as user') || user_access('masquerade as admin')),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/settings/masquerade',
      'title' => t('Masquerade'),
      'description' => t('Masquerade module allows administrators to masquerade as other users.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'masquerade_settings',
      'type' => MENU_NORMAL_ITEM,
    );
  }
  else {
    $items[] = array(
      'path' => 'masquerade/unswitch',
      'title' => t('Switch back'),
      'callback' => 'masquerade_switch_back',
      'access' => $GLOBALS['masquerading'],
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'masquerade/switch/' . arg(2),
      'title' => t('Switch user'),
      'callback' => 'masquerade_switch_user',
      'callback arguments' => array(
        arg(2),
      ),
      'access' => !$GLOBALS['masquerading'] && (user_access('masquerade as user') || user_access('masquerade as admin')),
      'type' => MENU_CALLBACK,
    );
  }
  return $items;
}