/[drupal]/contributions/modules/single_login/single_login.install
ViewVC logotype

Diff of /contributions/modules/single_login/single_login.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.2.1

  ViewVC Help
Powered by ViewVC 1.1.2