You are here

password_policy.install in Password Policy 5

File

password_policy.install
View source
<?php

/**
 * Implementation of the hook_install() module.
 */
function password_policy_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {password_policy} (\n        id int(10) unsigned NOT NULL default '0',\n        name varchar(48) NOT NULL default '',\n        description longtext,\n        enabled int(1) unsigned NOT NULL default '0',\n        serialized_policy longtext NOT NULL,\n        created int(11) default NULL,\n        PRIMARY KEY (id)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE {password_policy_users} (\n        uid int(10) unsigned NOT NULL default '0',\n        pass varchar(32) NOT NULL default '',\n        created int(11) NOT NULL default '0',\n        KEY (uid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE {password_policy_expiration} (\n        uid int(10) unsigned NOT NULL,\n        warning int(11) default NULL,\n        blocked int(11) default NULL,\n        unblocked int(11) default NULL,\n        KEY (uid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      break;
  }
  drupal_set_message('The password policy module has been installed.');
}

/**
 * Implementation of hook_uninstall().
 */
function password_policy_uninstall() {
  variable_del('password_policy_admin');
  variable_del('password_policy_begin');
  variable_del('password_policy_block');
  variable_del('password_policy_mail_warning_subject');
  variable_del('password_policy_mail_warning_body');
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query('DROP TABLE {password_policy}');
      db_query('DROP TABLE {password_policy_users}');
      db_query('DROP TABLE {password_policy_expiration}');
      break;
  }
}

/**
 * Implementation of hook_update_X().
 *
 * Add a table to store password expiration information.
 *
 * @return array
 */
function password_policy_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {password_policy_expiration} (\n        uid int(10) unsigned NOT NULL,\n        warning int(11) default NULL,\n        blocked int(11) default NULL,\n        unblocked int(11) default NULL,\n        KEY (uid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      $ret[] = update_sql("ALTER TABLE {password_policy} ADD created int(11) default NULL");
      break;
  }
  return $ret;
}
function password_policy_update_5000() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {password_policy_users} ADD KEY (uid)");
      $ret[] = update_sql("ALTER TABLE {password_policy_expiration} ADD KEY (uid)");
      break;
  }
  return $ret;
}

Functions

Namesort descending Description
password_policy_install Implementation of the hook_install() module.
password_policy_uninstall Implementation of hook_uninstall().
password_policy_update_1 Implementation of hook_update_X().
password_policy_update_5000