You are here

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

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() {
  $ret = drupal_install_schema('restrict_by_ip');
  $failed = array();
  foreach ($ret as $query) {
    if (!$query['success']) {
      $failed[] = $query['query'];
    }
  }
  if (empty($failed)) {
    drupal_set_message(t('Restrict Logon By IP module installed successfully.'));
  }
  else {
    drupal_set_message(t('Table installation for the Restrict Logon By IP module was unsuccessful. The following queries failed: !queries', array(
      '!queries' => theme('item_list', $failed),
    )), 'error');
  }
}

/**
* Implementation of hook_schema().
*/
function restrict_by_ip_schema() {
  $schema['restrict_by_ip'] = array(
    'description' => t('The Restrict By IP Table'),
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
      ),
      'rid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
      ),
      'restrict_by_ip_type' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'restrict_by_ip_address' => array(
        'type' => 'varchar',
        'length' => 128,
      ),
    ),
    //'primary key' => array('uid'),
    'key' => array(
      'uid',
    ),
    'key' => array(
      'rid',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_uninstall().
 */
function restrict_by_ip_uninstall() {
  drupal_uninstall_schema('restrict_by_ip');

  // Drop variables.
  $variables = array(
    'restrict_by_ip_user_registration',
  );
  foreach ($variables as $variable) {
    variable_del($variable);
  }
  drupal_set_message(t('Restrict Logon By IP module uninstalled successfully.'));
}

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_schema Implementation of hook_schema().
restrict_by_ip_uninstall Implementation of hook_uninstall().