View source
<?php
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');
}
}
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,
),
),
'key' => array(
'uid',
),
'key' => array(
'rid',
),
);
return $schema;
}
function restrict_by_ip_uninstall() {
drupal_uninstall_schema('restrict_by_ip');
$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.'));
}