| 1 |
<?php |
<?php |
| 2 |
|
// $Id: single_login.install,v 1.1.2.3 2008/10/08 06:19:43 sanduhrs Exp $ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* Single Login is a session management system for Drupal. |
| 6 |
|
* |
| 7 |
|
* @file |
| 8 |
|
* Single login install routines. |
| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
/** |
| 12 |
|
* Implementation of hook_install(). |
| 13 |
|
*/ |
| 14 |
function single_login_install() { |
function single_login_install() { |
| 15 |
switch ($GLOBALS['db_type']) { |
switch ($GLOBALS['db_type']) { |
| 16 |
case 'mysql': |
case 'mysql': |
| 17 |
case 'mysqli': |
case 'mysqli': |
| 18 |
db_query('CREATE TABLE {single_login} ( |
db_query('CREATE TABLE {single_login} ( |
| 19 |
single_login_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , |
single_login_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , |
| 20 |
uid INT UNSIGNED NOT NULL , |
uid INT UNSIGNED NOT NULL , |
| 21 |
counter INT(0) UNSIGNED NOT NULL , |
counter INT(0) UNSIGNED NOT NULL , |
| 22 |
INDEX (counter) , |
INDEX (counter) , |
| 23 |
UNIQUE (uid) |
UNIQUE (uid) |
| 24 |
) ENGINE = MYISAM'); |
) ENGINE = MYISAM'); |
| 25 |
db_query('CREATE TABLE {single_login_history} ( |
db_query('CREATE TABLE {single_login_history} ( |
| 26 |
history_id int(10) unsigned NOT NULL auto_increment, |
history_id int(10) unsigned NOT NULL auto_increment, |
| 27 |
uid int(10) unsigned NOT NULL, |
uid int(10) unsigned NOT NULL, |
| 28 |
session_id varchar(64) NOT NULL, |
session_id varchar(64) NOT NULL, |
| 29 |
date int(11) NOT NULL, |
date int(11) NOT NULL, |
| 30 |
ip varchar(15) NOT NULL, |
ip varchar(15) NOT NULL, |
| 31 |
browser varchar(255) NOT NULL, |
browser varchar(255) NOT NULL, |
| 32 |
type enum(\'login\',\'cookie\') NOT NULL default \'login\', |
type enum(\'login\',\'cookie\') NOT NULL default \'login\', |
| 33 |
PRIMARY KEY (history_id), |
PRIMARY KEY (history_id), |
| 34 |
UNIQUE KEY session_id (session_id), |
UNIQUE KEY session_id (session_id), |
| 35 |
KEY uid (uid) |
KEY uid (uid) |
| 36 |
) ENGINE=MyISAM'); |
) ENGINE=MyISAM'); |
| 37 |
drupal_set_message(t('Single login database tables have been installed.')); |
drupal_set_message(t('Single login database tables have been installed.')); |
| 38 |
break; |
break; |
| 39 |
case 'pgsql': |
case 'pgsql': |
| 40 |
drupal_set_message(t('Watch List database tables have not been installed! PgSQL is not supported')); |
drupal_set_message(t('Watch List database tables have not been installed! PgSQL is not supported')); |
| 41 |
break; |
break; |
| 42 |
} |
} |
|
|
|
|
// needed for google analytics |
|
|
db_query("INSERT INTO |
|
|
{profile_fields} ( |
|
|
title, name, explanation, |
|
|
category, page, type, weight, required, |
|
|
register, visibility, autocomplete, options |
|
|
) VALUES (' |
|
|
Current Session ID', 'profile_current_session_id', 'User session ID', |
|
|
'User Information', '', 'textfield', 0, 0, |
|
|
0, 4, 0, '')"); |
|
| 43 |
} |
} |
| 44 |
|
|
| 45 |
|
/** |
| 46 |
|
* Implementation of hook_uninstall(). |
| 47 |
|
*/ |
| 48 |
function single_login_uninstall() { |
function single_login_uninstall() { |
| 49 |
db_query('DROP TABLE {single_login}'); |
db_query('DROP TABLE {single_login}'); |
| 50 |
db_query('DROP TABLE {single_login_history}'); |
db_query('DROP TABLE {single_login_history}'); |
| 51 |
|
|
| 52 |
$res = db_query('SELECT fid FROM {profile_fields} WHERE name = \'profile_current_session_id\''); |
if (module_exists('profile')) { |
| 53 |
if (db_num_rows($res)) { |
$res = db_query('SELECT fid FROM {profile_fields} WHERE name = \'profile_current_session_id\''); |
| 54 |
$row = db_fetch_object($res); |
if (db_num_rows($res)) { |
| 55 |
db_query('DELETE FROM {profile_fields} WHERE fid = %d', $row->fid); |
$row = db_fetch_object($res); |
| 56 |
db_query('DELETE FROM {profile_values} WHERE fid = %d', $row->fid); |
db_query('DELETE FROM {profile_fields} WHERE fid = %d', $row->fid); |
| 57 |
} |
db_query('DELETE FROM {profile_values} WHERE fid = %d', $row->fid); |
| 58 |
|
} |
| 59 |
|
} |
| 60 |
} |
} |
|
?> |
|