You are here

restrict_by_ip.install in Restrict Login or Role Access by IP Address 5

File

restrict_by_ip.install
View source
<?php

/**
 * Implementation of hook_install().
 * Creates a table of the variables that will be needed to use this module
 */
function restrict_by_ip_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {restrict_by_ip} (\n        uid int unsigned NOT NULL,\n        restrict_by_ip_address varchar(128),\n        PRIMARY KEY(uid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;\n      ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {restrict_by_ip} (\n        uid int NOT NULL, \n\t\t    restrict_by_ip_address character(128)\n        PRIMARY KEY(uid)\n        );\n      ");
      break;
  }
  watchdog('restrict_by_ip', 'restrict_by_ip module installed');
  drupal_set_message(t('The restrict_by_ip module was installed.'));
}

/**
* Implementation of hook_uninstall().
*/
function restrict_by_ip_uninstall() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("DROP TABLE {restrict_by_ip}");
      break;
    case 'pgsql':
      db_query("DROP TABLE {restrict_by_ip}");
      break;
  }

  // clear the cache tables (see http://drupal.org/node/64279#comment-211282)
  cache_clear_all('*', 'cache', TRUE);
  cache_clear_all('*', 'cache_filter', TRUE);
  cache_clear_all('*', 'cache_menu', TRUE);
  cache_clear_all('*', 'cache_page', TRUE);
  watchdog('restrict_by_ip', 'restrict_by_ip module removed');
}

Functions

Namesort descending Description
restrict_by_ip_install Implementation of hook_install(). Creates a table of the variables that will be needed to use this module
restrict_by_ip_uninstall Implementation of hook_uninstall().