You are here

simplesamlphp_auth.install in simpleSAMLphp Authentication 6.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
 */

/**
 * Implementation of hook_install().
 */
function simplesamlphp_auth_install() {
  $abc = 'test';

  // Necessary userprotect settings
  $query1 = db_result(db_query('SELECT perm FROM {permission} WHERE rid = 2'));
  if ($query1) {
    $new_perms = str_replace(", change own password", "", $query1);
    $new_perms = str_replace("change own password", "", $new_perms);
    $query2 = db_query("UPDATE {permission} SET perm = '" . $new_perms . "' WHERE rid = 2");
  }

  //Hide Login block by default

  //$query3 = db_query("UPDATE {blocks} SET status='0' WHERE module='user' AND delta='0'");

  //Remove Logout from the menu by default

  //$query4 = db_query("UPDATE {menu} SET type=48 WHERE path='logout'");

  //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);
  if ($query1) {
    drupal_set_message('The simpleSAMLphp authentication module was installed successfully.');
  }
  else {
    drupal_set_message('There was an error installing the simpleSAMLphp authentication database tables.', 'error');
  }
}

/**
 * Implementation of hook_uninstall().
 */
function simplesamlphp_auth_uninstall() {

  //Show Login block by default
  $query1 = db_query("UPDATE {blocks} SET status='1' WHERE module='user' AND delta='0'");

  //Restore Logout from the menu by default

  //$query2 = db_query("UPDATE {menu} SET type=54 WHERE path='logout'");

  //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_allowdefaultlogin");
  variable_del("simplesamlphp_auth_allowdefaultloginusers");
  if ($query1) {
    drupal_set_message('The simpleSAMLphp authentication module was uninstalled successfully.');
  }
  else {
    drupal_set_message('There was an error removing the simpleSAMLphp authentication database tables.', 'error');
  }
}

Functions

Namesort descending Description
simplesamlphp_auth_install Implementation of hook_install().
simplesamlphp_auth_uninstall Implementation of hook_uninstall().