| 
webmaster@1
 | 
     1 <?php | 
| 
franck@19
 | 
     2 // $Id: statistics.install,v 1.13.2.1 2009/01/06 15:46:37 goba Exp $ | 
| 
webmaster@1
 | 
     3  | 
| 
webmaster@1
 | 
     4 /** | 
| 
webmaster@1
 | 
     5  * Implementation of hook_install(). | 
| 
webmaster@1
 | 
     6  */ | 
| 
webmaster@1
 | 
     7 function statistics_install() { | 
| 
webmaster@1
 | 
     8   // Create tables. | 
| 
webmaster@1
 | 
     9   drupal_install_schema('statistics'); | 
| 
webmaster@1
 | 
    10 } | 
| 
webmaster@1
 | 
    11  | 
| 
webmaster@1
 | 
    12 /** | 
| 
webmaster@1
 | 
    13  * Changes session ID  field to VARCHAR(64) to add support for SHA-1 hashes. | 
| 
webmaster@1
 | 
    14  */ | 
| 
webmaster@1
 | 
    15 function statistics_update_1000() { | 
| 
webmaster@1
 | 
    16   $ret = array(); | 
| 
webmaster@1
 | 
    17  | 
| 
webmaster@1
 | 
    18   switch ($GLOBALS['db_type']) { | 
| 
webmaster@1
 | 
    19     case 'mysql': | 
| 
webmaster@1
 | 
    20     case 'mysqli': | 
| 
webmaster@1
 | 
    21       $ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''"); | 
| 
webmaster@1
 | 
    22       break; | 
| 
webmaster@1
 | 
    23     case 'pgsql': | 
| 
webmaster@1
 | 
    24       db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''")); | 
| 
webmaster@1
 | 
    25       break; | 
| 
webmaster@1
 | 
    26   } | 
| 
webmaster@1
 | 
    27  | 
| 
webmaster@1
 | 
    28   return $ret; | 
| 
webmaster@1
 | 
    29 } | 
| 
webmaster@1
 | 
    30  | 
| 
webmaster@1
 | 
    31 /** | 
| 
webmaster@1
 | 
    32  * Implementation of hook_uninstall(). | 
| 
webmaster@1
 | 
    33  */ | 
| 
webmaster@1
 | 
    34 function statistics_uninstall() { | 
| 
webmaster@1
 | 
    35   // Remove tables. | 
| 
webmaster@1
 | 
    36   drupal_uninstall_schema('statistics'); | 
| 
webmaster@1
 | 
    37  | 
| 
webmaster@1
 | 
    38   variable_del('statistics_count_content_views'); | 
| 
webmaster@1
 | 
    39   variable_del('statistics_enable_access_log'); | 
| 
webmaster@1
 | 
    40   variable_del('statistics_flush_accesslog_timer'); | 
| 
webmaster@1
 | 
    41   variable_del('statistics_day_timestamp'); | 
| 
webmaster@1
 | 
    42   variable_del('statistics_block_top_day_num'); | 
| 
webmaster@1
 | 
    43   variable_del('statistics_block_top_all_num'); | 
| 
webmaster@1
 | 
    44   variable_del('statistics_block_top_last_num'); | 
| 
webmaster@1
 | 
    45 } | 
| 
webmaster@1
 | 
    46  | 
| 
webmaster@1
 | 
    47 /** | 
| 
webmaster@1
 | 
    48  * Implementation of hook_schema(). | 
| 
webmaster@1
 | 
    49  */ | 
| 
webmaster@1
 | 
    50 function statistics_schema() { | 
| 
webmaster@1
 | 
    51   $schema['accesslog'] = array( | 
| 
franck@19
 | 
    52     'description' => 'Stores site access information for statistics.', | 
| 
webmaster@1
 | 
    53     'fields' => array( | 
| 
webmaster@1
 | 
    54       'aid' => array( | 
| 
webmaster@1
 | 
    55         'type' => 'serial', | 
| 
webmaster@1
 | 
    56         'not null' => TRUE, | 
| 
franck@19
 | 
    57         'description' => 'Primary Key: Unique accesslog ID.', | 
| 
webmaster@1
 | 
    58       ), | 
| 
webmaster@1
 | 
    59       'sid' => array( | 
| 
webmaster@1
 | 
    60         'type' => 'varchar', | 
| 
webmaster@1
 | 
    61         'length' => 64, | 
| 
webmaster@1
 | 
    62         'not null' => TRUE, | 
| 
webmaster@1
 | 
    63         'default' => '', | 
| 
franck@19
 | 
    64         'description' => 'Browser session ID of user that visited page.', | 
| 
webmaster@1
 | 
    65       ), | 
| 
webmaster@1
 | 
    66       'title' => array( | 
| 
webmaster@1
 | 
    67         'type' => 'varchar', | 
| 
webmaster@1
 | 
    68         'length' => 255, | 
| 
webmaster@1
 | 
    69         'not null' => FALSE, | 
| 
franck@19
 | 
    70         'description' => 'Title of page visited.', | 
| 
webmaster@1
 | 
    71       ), | 
| 
webmaster@1
 | 
    72       'path' => array( | 
| 
webmaster@1
 | 
    73         'type' => 'varchar', | 
| 
webmaster@1
 | 
    74         'length' => 255, | 
| 
webmaster@1
 | 
    75         'not null' => FALSE, | 
| 
franck@19
 | 
    76         'description' => 'Internal path to page visited (relative to Drupal root.)', | 
| 
webmaster@1
 | 
    77       ), | 
| 
webmaster@1
 | 
    78       'url' => array( | 
| 
webmaster@1
 | 
    79         'type' => 'varchar', | 
| 
webmaster@1
 | 
    80         'length' => 255, | 
| 
webmaster@1
 | 
    81         'not null' => FALSE, | 
| 
franck@19
 | 
    82         'description' => 'Referrer URI.', | 
| 
webmaster@1
 | 
    83       ), | 
| 
webmaster@1
 | 
    84       'hostname' => array( | 
| 
webmaster@1
 | 
    85         'type' => 'varchar', | 
| 
webmaster@1
 | 
    86         'length' => 128, | 
| 
webmaster@1
 | 
    87         'not null' => FALSE, | 
| 
franck@19
 | 
    88         'description' => 'Hostname of user that visited the page.', | 
| 
webmaster@1
 | 
    89       ), | 
| 
webmaster@1
 | 
    90       'uid' => array( | 
| 
webmaster@1
 | 
    91         'type' => 'int', | 
| 
webmaster@1
 | 
    92         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
    93         'not null' => FALSE, | 
| 
webmaster@1
 | 
    94         'default' => 0, | 
| 
franck@19
 | 
    95         'description' => 'User {users}.uid that visited the page.', | 
| 
webmaster@1
 | 
    96       ), | 
| 
webmaster@1
 | 
    97       'timer' => array( | 
| 
webmaster@1
 | 
    98         'type' => 'int', | 
| 
webmaster@1
 | 
    99         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
   100         'not null' => TRUE, | 
| 
webmaster@1
 | 
   101         'default' => 0, | 
| 
franck@19
 | 
   102         'description' => 'Time in milliseconds that the page took to load.', | 
| 
webmaster@1
 | 
   103       ), | 
| 
webmaster@1
 | 
   104       'timestamp' => array( | 
| 
webmaster@1
 | 
   105         'type' => 'int', | 
| 
webmaster@1
 | 
   106         'unsigned' => TRUE, | 
| 
webmaster@1
 | 
   107         'not null' => TRUE, | 
| 
webmaster@1
 | 
   108         'default' => 0, | 
| 
franck@19
 | 
   109         'description' => 'Timestamp of when the page was visited.', | 
| 
webmaster@1
 | 
   110       ), | 
| 
webmaster@1
 | 
   111     ), | 
| 
webmaster@1
 | 
   112     'indexes' => array( | 
| 
webmaster@1
 | 
   113       'accesslog_timestamp' => array('timestamp'), | 
| 
webmaster@1
 | 
   114       'uid' => array('uid'), | 
| 
webmaster@1
 | 
   115     ), | 
| 
webmaster@1
 | 
   116     'primary key' => array('aid'), | 
| 
webmaster@1
 | 
   117   ); | 
| 
webmaster@1
 | 
   118  | 
| 
webmaster@1
 | 
   119   return $schema; | 
| 
webmaster@1
 | 
   120 } | 
| 
webmaster@1
 | 
   121  |