You are here

function securesite_admin_settings in Secure Site 6.2

Same name and namespace in other branches
  1. 5 securesite.module \securesite_admin_settings()
  2. 6 securesite.admin.inc \securesite_admin_settings()
  3. 7.2 securesite.admin.inc \securesite_admin_settings()

FAPI definition for Secure Site admin settings form

See also

system_settings_form()

securesite_admin_settings_validate()

securesite_admin_settings_submit()

1 string reference to 'securesite_admin_settings'
securesite_menu in ./securesite.module
Implementation of hook_menu().

File

./securesite.admin.inc, line 135
Secure Site administration pages.

Code

function securesite_admin_settings() {
  $form['authentication'] = array(
    '#type' => 'fieldset',
    '#title' => t('Authentication'),
    '#description' => t('Enable Secure Site below. Users must have the <em>!access</em> permission in order to access the site if authentication is forced.', array(
      '!access' => l(t('access secured pages'), 'admin/user/permissions', array(
        'fragment' => 'module-securesite',
      )),
    )),
  );
  $form['authentication']['securesite_enabled'] = array(
    '#type' => 'radios',
    '#title' => t('Force authentication'),
    '#default_value' => variable_get('securesite_enabled', SECURESITE_DISABLED),
    '#options' => array(
      SECURESITE_DISABLED => t('Never'),
      SECURESITE_ALWAYS => t('Always'),
      SECURESITE_OFFLINE => t('During maintenance'),
      SECURESITE_403 => t('On restricted pages'),
    ),
    '#description' => t('Choose when to force authentication.'),
  );
  $form['authentication']['securesite_type'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Allowed authentication types'),
    '#default_value' => variable_get('securesite_type', array(
      SECURESITE_BASIC,
    )),
    '#options' => array(
      SECURESITE_DIGEST => t('HTTP digest'),
      SECURESITE_BASIC => t('HTTP basic'),
      SECURESITE_FORM => t('HTML log-in form'),
    ),
    '#required' => TRUE,
  );
  $form['authentication']['securesite_type']['#description'] = "\n" . '<p>' . t('HTTP authentication requires extra configuration if PHP is not installed as an Apache module. See the !link section of the Secure Site help for details.', array(
    '!link' => l(t('Known issues'), 'admin/help/securesite', array(
      'fragment' => 'issues',
    )),
  )) . '</p>' . "\n" . '<p>' . t('Digest authentication protects a user&rsquo;s password from eavesdroppers when you are not using SSL to encrypt the connection. However, it can only be used when a copy of the password is stored on the server.') . ' ' . t('For security reasons, Drupal does not store passwords. You will need to configure scripts to securely save passwords and authenticate users. See the !link section of the Secure Site help for details.', array(
    '!link' => l(t('Secure password storage'), 'admin/help/securesite', array(
      'fragment' => 'passwords',
    )),
  )) . '</p>' . "\n" . '<p>' . t('When digest authentication is enabled, passwords will be saved when users log in or set their passwords. If you use digest authentication to protect your whole site, you should allow guest access or allow another authentication type until users whose passwords are not yet saved have logged in. Otherwise, <strong>you may lock yourself out of your own site.</strong>') . '</p>' . "\n";
  $form['authentication']['securesite_digest_script'] = array(
    '#type' => 'textarea',
    '#title' => t('Digest authentication script'),
    '#default_value' => variable_get('securesite_digest_script', drupal_get_path('module', 'securesite') . '/digest_md5/digest_md5.php'),
    '#description' => t('Enter the digest authentication script exactly as it should appear on the command line. Use absolute paths.'),
    '#rows' => 2,
  );
  $form['authentication']['securesite_password_script'] = array(
    '#type' => 'textarea',
    '#title' => t('Password storage script'),
    '#default_value' => variable_get('securesite_password_script', drupal_get_path('module', 'securesite') . '/digest_md5/stored_passwords.php'),
    '#description' => t('Enter the password storage script exactly as it should appear on the command line. Use absolute paths.'),
    '#rows' => 2,
  );
  $form['authentication']['securesite_realm'] = array(
    '#type' => 'textfield',
    '#title' => t('Authentication realm'),
    '#default_value' => variable_get('securesite_realm', variable_get('site_name', 'Drupal')),
    '#length' => 30,
    '#maxlength' => 40,
    '#description' => t('Name to identify the log-in area in the HTTP authentication dialog.'),
  );
  $form['guest'] = array(
    '#type' => 'fieldset',
    '#title' => t('Guest access'),
    '#description' => t('Guest access allows anonymous users to view secure pages, though they will still be prompted for a user name and password. If you give anonymous users the <em>!access</em> permission, you can set the user name and password for anonymous users below.', array(
      '!access' => l(t('access secured pages'), 'admin/user/permissions', array(
        'fragment' => 'module-securesite',
      )),
    )),
  );
  $guest_access = !user_access('access secured pages', drupal_anonymous_user());
  $form['guest']['securesite_guest_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Guest user'),
    '#default_value' => variable_get('securesite_guest_name', ''),
    '#length' => 30,
    '#maxlength' => 40,
    '#description' => t('Do not use the name of a registered user. Leave empty to accept any name.'),
    '#disabled' => $guest_access,
  );
  $form['guest']['securesite_guest_pass'] = array(
    '#type' => 'textfield',
    '#title' => t('Guest password'),
    '#default_value' => variable_get('securesite_guest_pass', ''),
    '#length' => 30,
    '#maxlength' => 40,
    '#description' => t('Leave empty to accept any password.'),
    '#disabled' => $guest_access,
  );
  $form['login_form'] = array(
    '#type' => 'fieldset',
    '#title' => t('Customize HTML forms'),
    '#description' => t('Configure the message displayed on the HTML log-in form (if enabled) and password reset form below.'),
  );
  $form['login_form']['securesite_login_form'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom message for HTML log-in form'),
    '#default_value' => variable_get('securesite_login_form', t('Enter your user name and password:')),
    '#length' => 60,
    '#height' => 3,
  );
  $form['login_form']['securesite_reset_form'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom message for password reset form'),
    '#default_value' => variable_get('securesite_reset_form', t('Enter your user name or e-mail address:')),
    '#length' => 60,
    '#height' => 3,
    '#description' => t('Leave empty to disable Secure Site&rsquo;s password reset form.'),
  );
  $form['#submit'][] = 'securesite_admin_settings_submit';
  return system_settings_form($form);
}