2006-07-13 13:14:25 +00:00
|
|
|
<?php
|
2006-07-14 01:05:10 +00:00
|
|
|
// $Id$
|
2006-07-13 13:14:25 +00:00
|
|
|
|
2009-05-13 19:42:18 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Install, update and uninstall functions for the statistics module.
|
|
|
|
*/
|
|
|
|
|
2006-09-01 07:40:08 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_uninstall().
|
2006-09-01 07:40:08 +00:00
|
|
|
*/
|
|
|
|
function statistics_uninstall() {
|
2009-04-24 08:23:02 +00:00
|
|
|
// Remove variables.
|
2006-09-01 07:40:08 +00:00
|
|
|
variable_del('statistics_count_content_views');
|
|
|
|
variable_del('statistics_enable_access_log');
|
|
|
|
variable_del('statistics_flush_accesslog_timer');
|
|
|
|
variable_del('statistics_day_timestamp');
|
|
|
|
variable_del('statistics_block_top_day_num');
|
|
|
|
variable_del('statistics_block_top_all_num');
|
|
|
|
variable_del('statistics_block_top_last_num');
|
|
|
|
}
|
2007-10-05 14:43:26 +00:00
|
|
|
|
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_schema().
|
2007-10-05 14:43:26 +00:00
|
|
|
*/
|
|
|
|
function statistics_schema() {
|
|
|
|
$schema['accesslog'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores site access information for statistics.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'aid' => array(
|
|
|
|
'type' => 'serial',
|
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Primary Key: Unique accesslog ID.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'sid' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 64,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Browser session ID of user that visited page.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'title' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Title of page visited.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'path' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Internal path to page visited (relative to Drupal root.)',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'url' => array(
|
2008-12-03 19:22:09 +00:00
|
|
|
'type' => 'text',
|
2007-10-10 11:39:35 +00:00
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Referrer URI.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'hostname' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 128,
|
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Hostname of user that visited the page.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'uid' => array(
|
2007-10-12 14:10:18 +00:00
|
|
|
'type' => 'int',
|
2007-10-10 11:39:35 +00:00
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => FALSE,
|
|
|
|
'default' => 0,
|
2009-02-26 07:30:29 +00:00
|
|
|
'description' => 'User {users}.uid that visited the page.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'timer' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Time in milliseconds that the page took to load.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'timestamp' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Timestamp of when the page was visited.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
),
|
2007-12-18 12:59:22 +00:00
|
|
|
'indexes' => array(
|
|
|
|
'accesslog_timestamp' => array('timestamp'),
|
|
|
|
'uid' => array('uid'),
|
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
'primary key' => array('aid'),
|
2009-06-01 22:07:10 +00:00
|
|
|
'foreign keys' => array(
|
|
|
|
'uid' => array('users' => 'uid'),
|
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
);
|
|
|
|
|
2009-04-24 08:23:02 +00:00
|
|
|
$schema['node_counter'] = array(
|
|
|
|
'description' => 'Access statistics for {node}s.',
|
|
|
|
'fields' => array(
|
|
|
|
'nid' => array(
|
|
|
|
'description' => 'The {node}.nid for these statistics.',
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
),
|
|
|
|
'totalcount' => array(
|
|
|
|
'description' => 'The total number of times the {node} has been viewed.',
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
'size' => 'big',
|
|
|
|
),
|
|
|
|
'daycount' => array(
|
|
|
|
'description' => 'The total number of times the {node} has been viewed today.',
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
'size' => 'medium',
|
|
|
|
),
|
|
|
|
'timestamp' => array(
|
|
|
|
'description' => 'The most recent time the {node} has been viewed.',
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'primary key' => array('nid'),
|
|
|
|
);
|
|
|
|
|
2007-10-05 14:43:26 +00:00
|
|
|
return $schema;
|
|
|
|
}
|
|
|
|
|
2009-04-24 08:23:02 +00:00
|
|
|
/**
|
2009-10-17 12:07:31 +00:00
|
|
|
* @defgroup updates-6.x-extra Extra statistics updates for 6.x
|
2009-04-24 08:23:02 +00:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2008-12-03 19:22:09 +00:00
|
|
|
/**
|
|
|
|
* Allow longer referrers.
|
|
|
|
*/
|
2009-10-17 12:07:31 +00:00
|
|
|
function statistics_update_6000() {
|
2009-09-29 15:13:57 +00:00
|
|
|
db_change_field('accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
|
2008-12-03 19:22:09 +00:00
|
|
|
}
|
2009-04-24 08:23:02 +00:00
|
|
|
|
2009-10-17 12:07:31 +00:00
|
|
|
/**
|
|
|
|
* @} End of "defgroup updates-6.x-extra"
|
|
|
|
* The next series of updates should start at 7000.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup updates-6.x-to-7.x statistics updates from 6.x to 7.x
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-04-24 08:23:02 +00:00
|
|
|
/**
|
|
|
|
* @} End of "defgroup updates-6.x-to-7.x"
|
|
|
|
* The next series of updates should start at 8000.
|
|
|
|
*/
|