View source
<?php
if (!function_exists('autologout_install')) {
function autologout_install() {
$created = FALSE;
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$query1 = db_query("CREATE TABLE IF NOT EXISTS {autologout} (" . "uid INT(10) NOT NULL," . "setting INT(2) NOT NULL DEFAULT 0," . "PRIMARY KEY (uid)" . ") /*!40100 DEFAULT CHARACTER SET utf8 */");
if ($query1) {
$created = TRUE;
}
break;
case 'pgsql':
$query1 = db_query("CREATE TABLE {autologout} (" . "uid INT NOT NULL," . "setting SMALLINT NOT NULL default 0," . "PRIMARY KEY (uid))");
if ($query1) {
$created = TRUE;
}
break;
}
db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", 1000, 'autologout');
if ($created) {
drupal_set_message(t('Autologout database tables installed'));
}
else {
drupal_set_message(t('Table install for autologout was unsuccessful.'));
}
}
}
function autologout_uninstall() {
db_query('DROP TABLE {autologout}');
variable_del('autologout');
}