You are here

simplesamlphp_auth.install in simpleSAMLphp Authentication 7.2

the install file for the simplesamlphp_auth module

File

simplesamlphp_auth.install
View source
<?php

/**
 * @file
 * the install file for the simplesamlphp_auth module
 */

/**
 * Implements hook_install().
 */
function simplesamlphp_auth_install() {
  user_role_revoke_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'change own password',
  ));

  // Disable the open registration to the site and store the original setting.
  $original = variable_get('user_register', 1);
  variable_set('user_register', 0);
  variable_set('simplesamlphp_auth_user_register_original', $original);
}

/**
 * Implements hook_uninstall().
 */
function simplesamlphp_auth_uninstall() {

  // Restore the original user registration directive.
  $original = variable_get('simplesamlphp_auth_user_register_original', 1);
  variable_set('user_register', $original);
  variable_del('simplesamlphp_auth_user_register_original');

  // Remove the created system variables.
  variable_del('simplesamlphp_auth_activate');
  variable_del('simplesamlphp_auth_installdir');
  variable_del('simplesamlphp_auth_logout_page');
  variable_del('simplesamlphp_auth_mailattr');
  variable_del('simplesamlphp_auth_unique_id');
  variable_del('simplesamlphp_auth_user_name');
  variable_del('simplesamlphp_auth_authsource');
  variable_del('simplesamlphp_auth_rolepopulation');
  variable_del('simplesamlphp_auth_roleevaleverytime');
  variable_del('simplesamlphp_auth_forcehttps');
  variable_del('simplesamlphp_auth_registerusers');
  variable_del('simplesamlphp_auth_allowsetdrupalpwd');
  variable_del('simplesamlphp_auth_allowdefaultlogin');
  variable_del('simplesamlphp_auth_allowdefaultloginroles');
  variable_del('simplesamlphp_auth_allowdefaultloginusers');
  variable_del('simplesamlphp_auth_logoutgotourl');
}

/**
 * Implements hook_requirements().
 */
function simplesamlphp_auth_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    if (!variable_get('simplesamlphp_auth_activate', 0)) {
      $requirements['simplesamlphp_auth'] = array(
        'severity' => REQUIREMENT_INFO,
        'title' => 'simpleSAMLphp_auth',
        'value' => t('SimpleSAMLphp authentication is NOT activated'),
        'description' => t('It can be activated on the !admin_page.', array(
          '!admin_page' => l(t('configuration page'), 'admin/config/people/simplesamlphp_auth'),
        )),
      );
    }
    $basedir = variable_get('simplesamlphp_auth_installdir', '/var/simplesamlphp');
    if (!file_exists($basedir . '/lib/_autoload.php')) {
      $requirements['simplesamlphp_auth'] = array(
        'severity' => REQUIREMENT_WARNING,
        'title' => 'simpleSAMLphp_auth',
        'value' => t('SimpleSAMLphp authentication is missing the required SimpleSAMLphp library'),
        'description' => t('Please download and install the !simplesamlphp library.', array(
          '!simplesamlphp' => l(t('SimpeSAMLphp'), 'https://simplesamlphp.org/download'),
        )),
      );
    }
  }
  return $requirements;
}