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