You are here

function securelogin_form_alter in Secure Login 7

Same name and namespace in other branches
  1. 8 securelogin.module \securelogin_form_alter()
  2. 5 securelogin.module \securelogin_form_alter()
  3. 6 securelogin.module \securelogin_form_alter()

Implements hook_form_alter().

File

./securelogin.module, line 19
Enables user login and other forms to be submitted securely via HTTPS.

Code

function securelogin_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form_state['build_info']['base_form_id'])) {
    $form_id = $form_state['build_info']['base_form_id'];
  }
  if (variable_get('securelogin_all_forms', FALSE)) {
    $form['#https'] = TRUE;
  }
  elseif (variable_get('securelogin_form_' . $form_id, FALSE)) {
    $form['#https'] = TRUE;
  }
  elseif ($forms = explode(' ', variable_get('securelogin_other_forms', ''))) {
    if (in_array($form_id, $forms)) {
      $form['#https'] = TRUE;
    }
  }

  // Other modules may use #https to indicate that a form should be secured.
  if (!empty($form['#https'])) {
    securelogin_secure_form($form);
  }
}