You are here

function securesite_boot in Secure Site 7.2

Same name and namespace in other branches
  1. 6.2 securesite.module \securesite_boot()
  2. 6 securesite.module \securesite_boot()

Implements hook_boot().

File

./securesite.module, line 120
Enables HTTP authentication or an HTML form to restrict site access.

Code

function securesite_boot() {
  global $user;
  if ($_GET['q'] != 'user/logout') {

    // Did the user send credentials that we accept? (This should be a hook.)
    $type = _securesite_mechanism();
    if ($type !== FALSE && (isset($_SESSION['securesite_repeat']) ? !$_SESSION['securesite_repeat'] : TRUE)) {

      // Doing a full boot before login causes access denied errors because
      // menu access has already been set.
      drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL, FALSE);
      module_load_include('inc', 'securesite');
      _securesite_boot($type);
    }
    elseif (empty($user->uid) && !isset($_SESSION['securesite_guest'])) {
      if (isset($_SESSION['securesite_repeat'])) {
        unset($_SESSION['securesite_repeat']);
      }
      $types = variable_get('securesite_type', array(
        SECURESITE_BASIC,
      ));
      sort($types, SORT_NUMERIC);
      drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL, FALSE);
      module_load_include('inc', 'securesite');
      if (_securesite_forced()) {
        _securesite_dialog(array_pop($types));
      }
    }
  }
}