View source
<?php
function uiplog_schema() {
$schema['uiplog'] = array(
'description' => 'Logs users IP to db table on user login.',
'fields' => array(
'lid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Unique ID.',
),
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Maps to uid in user table.',
),
'ip' => array(
'type' => 'varchar',
'length' => 40,
'not null' => TRUE,
'description' => 'IP address of logged in users.',
),
'timestamp' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'Time of login.',
),
),
'indexes' => array(
'uid' => array(
'uid',
),
),
'primary key' => array(
'lid',
),
);
return $schema;
}
function uiplog_install() {
drupal_install_schema('uiplog');
}
function uiplog_uninstall() {
drupal_uninstall_schema('uiplog');
}
function uiplog_disable() {
module_load_include('inc', 'views', 'includes/view');
module_load_include('inc', 'uiplog', 'views/uiplog.views_default');
$default_views = array_keys(module_invoke('uiplog', 'views_default_views'));
$views_status = variable_get('views_defaults', array());
foreach ($default_views as $default_view) {
$views_status[$default_view] = TRUE;
}
variable_set('views_defaults', $views_status);
views_invalidate_cache();
}