You are here

function http_auth_settings_form in HTTP Auth 7

Implements hook_form().

1 string reference to 'http_auth_settings_form'
http_auth_menu in ./http_auth.module
Implements hook_menu().

File

./http_auth.module, line 43
Enables Drupal to add HTTP Auth from frontend on all over the site/pages.

Code

function http_auth_settings_form($form, &$form_state) {
  $http_auth_section = variable_get('http_auth');
  if (!is_array($http_auth_section)) {
    $http_auth_section = unserialize($http_auth_section);
  }
  $applicable = array(
    'complete' => t('Complete Site'),
    'admin' => t('Admin and User Pages'),
  );
  $form['http_auth'] = array(
    '#type' => 'fieldset',
    '#title' => t('Add HTTP Auth on your site'),
    '#description' => t('By activating, your site or admin pages would be <strong>locked</strong> for unauthenticated users.'),
  );
  $form['http_auth']['username'] = array(
    '#type' => 'textfield',
    '#title' => t('HTTP Auth Username'),
    '#description' => t('Add HTTP Auth username'),
    '#default_value' => isset($http_auth_section['username']) ? $http_auth_section['username'] : '',
    '#size' => 60,
    '#maxlength' => 64,
    '#required' => TRUE,
    '#attributes' => array(
      'placeholder' => 'username',
    ),
  );
  $form['http_auth']['password'] = array(
    '#type' => 'password',
    '#title' => t('HTTP Auth password'),
    '#description' => t('Add HTTP Auth password'),
    '#default_value' => isset($http_auth_section['password']) ? $http_auth_section['password'] : '',
    '#size' => 60,
    '#maxlength' => 64,
    '#required' => TRUE,
    '#attributes' => array(
      'placeholder' => 'password',
    ),
  );
  $form['http_auth']['message'] = array(
    '#type' => 'textarea',
    '#title' => t('HTTP Auth Message'),
    '#description' => t('Add HTTP Auth message which would be shown to the unauthenticated users.'),
    '#default_value' => isset($http_auth_section['message']) ? $http_auth_section['message'] : '',
    '#attributes' => array(
      'placeholder' => t('This page is Restricted. Please contact the administrator for access.'),
    ),
  );
  $form['http_auth']['applicable'] = array(
    '#type' => 'radios',
    '#title' => t('Applicable on:'),
    '#default_value' => isset($http_auth_section['applicable']) ? $http_auth_section['applicable'] : 'complete',
    '#options' => $applicable,
  );
  $form['http_auth']['activate'] = array(
    '#type' => 'checkbox',
    '#title' => t('Activate HTTP Authentication'),
    '#default_value' => isset($http_auth_section['activate']) ? $http_auth_section['activate'] : 0,
  );
  $form['http_auth']['note'] = array(
    '#markup' => "<div><strong>Note:</strong> Please clear the cache if the settings wouldn't work!</div>",
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save Settings',
  );
  return $form;
}