restrict_by_ip.install in Restrict Login or Role Access by IP Address 7.3
File
restrict_by_ip.install
View source
<?php
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,
'not null' => TRUE,
),
'restrict_by_ip_address' => array(
'type' => 'varchar',
'length' => 256,
),
),
'primary key' => array(
'uid',
),
);
return $schema;
}
function restrict_by_ip_uninstall() {
$variables = array(
'restrict_by_ip_user_registration',
'restrict_by_ip_error_page',
'restrict_by_ip_login_range',
'restrict_by_ip_header',
);
foreach ($variables as $variable) {
variable_del($variable);
}
db_query("DELETE FROM {variable} WHERE name LIKE 'restrict_by_ip_role%'");
drupal_set_message(t('Restrict Logon By IP module uninstalled successfully.'));
}
function restrict_by_ip_update_7300() {
$query = <<<EOL
select v.name, r.rid, r.name as role from {variable} v
left join {role} r on SUBSTR(v.name, 20) = r.rid
where v.name like 'restrict_by_ip_role%'
EOL;
$rows = db_query($query);
foreach ($rows as $row) {
db_query("UPDATE {variable} SET name = :new WHERE name = :old", array(
':new' => 'restrict_by_ip_role_' . $row->role,
':old' => $row->name,
));
}
}
function restrict_by_ip_update_7301() {
$query = <<<EOL
update {variable}
set name = CONCAT('restrict_by_ip_role_', MD5(SUBSTR(name, 21)))
where name like 'restrict_by_ip_role%'
EOL;
db_query($query);
}