You are here

function r4032login_admin_settings in Redirect 403 to User Login 6

Same name and namespace in other branches
  1. 5 r4032login.module \r4032login_admin_settings()
1 string reference to 'r4032login_admin_settings'
r4032login_menu in ./r4032login.module
Implementation of hook_menu().

File

./r4032login.module, line 37
Redirect denied pages to the user login form.

Code

function r4032login_admin_settings() {
  $form = array();
  $form['r4032login_display_denied_message'] = array(
    '#type' => 'textarea',
    '#title' => t('Display access denied message on login page'),
    '#default_value' => variable_get('r4032login_display_denied_message', t('Access denied. You must login to view this page.')),
  );
  $form['r4032login_user_register_message'] = array(
    '#type' => 'textfield',
    '#title' => t('User register message'),
    '#description' => t('The message to display when a logged-in user tries to register another account through the !new_account. Drupal does not allow it, so regular users must log out first. Administrators should create new users in !link.', array(
      '!new_account' => l(t('new account registration form'), 'user/register'),
      '!link' => l(t('User management'), 'admin/user/user/create'),
    )),
    '#default_value' => variable_get('r4032login_user_register_message', t('You are not authorized to access this page.')),
  );
  $form['r4032login_redirect_authenticated_users_to'] = array(
    '#type' => 'textfield',
    '#title' => t('Redirect authenticated users to'),
    '#description' => t('If an authenticated user tries to access a page they can not, redirect them to the given page. Use <front> for the front page, leave blank for the default access denied page.'),
    '#default_value' => variable_get('r4032login_redirect_authenticated_users_to', ''),
  );
  $form['r4032login_user_login_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to user login form'),
    '#description' => t('The path to the user login form. Omit the beginning slash, ie: user/login'),
    '#default_value' => variable_get('r4032login_user_login_path', 'user/login'),
  );
  $options = array(
    '301' => '301 Moved Permanently',
    '302' => '302 Found',
  );
  $form['r4032login_default_redirect_code'] = array(
    '#type' => 'select',
    '#title' => t("HTTP redirect code"),
    '#description' => t('The redirect code to send. 301 responses may be cached by browsers and proxies, so 302 is normally the correct choice.'),
    '#options' => $options,
    '#default_value' => variable_get('r4032login_default_redirect_code', 302),
  );
  $form['matching_paths'] = array(
    '#type' => 'fieldset',
    '#title' => t('Skip redirect for matching pages'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['matching_paths']['r4032login_match_noredirect_pages'] = array(
    '#type' => 'textarea',
    '#default_value' => variable_get('r4032login_match_noredirect_pages', ''),
    '#description' => t('Instead of redirecting, the user will get an access deined response and see the standard login form. This may be useful when the response code is important - such as for removing outdated content from search engines.  Use the path node/* for all content.') . ' ' . t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    )),
  );
  return system_settings_form($form);
}