2006-07-13 13:14:25 +00:00
|
|
|
<?php
|
|
|
|
|
2009-05-13 19:42:18 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2012-08-07 19:49:48 +00:00
|
|
|
* Install and update functions for the Statistics module.
|
2009-05-13 19:42:18 +00:00
|
|
|
*/
|
|
|
|
|
2012-11-09 22:30:28 +00:00
|
|
|
/**
|
|
|
|
* Implements hook_uninstall().
|
|
|
|
*/
|
|
|
|
function statistics_uninstall() {
|
|
|
|
// Remove states.
|
|
|
|
state()->delete('statistics.node_counter_scale');
|
|
|
|
state()->delete('statistics.day_timestamp');
|
|
|
|
}
|
|
|
|
|
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() {
|
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',
|
2012-10-04 20:27:03 +00:00
|
|
|
'unsigned' => TRUE,
|
2009-04-24 08:23:02 +00:00
|
|
|
'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;
|
|
|
|
}
|
2012-08-07 19:49:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves statistics settings from variables to config.
|
|
|
|
*
|
|
|
|
* @ingroup config_upgrade
|
|
|
|
*/
|
|
|
|
function statistics_update_8000() {
|
|
|
|
update_variables_to_config('statistics.settings', array(
|
|
|
|
'statistics_count_content_views' => 'count_content_views',
|
|
|
|
'statistics_block_top_day_num' => 'block.popular.top_day_limit',
|
|
|
|
'statistics_block_top_all_num' => 'block.popular.top_all_limit',
|
|
|
|
'statistics_block_top_last_num' => 'block.popular.top_recent_limit',
|
|
|
|
));
|
|
|
|
}
|
2012-10-04 20:27:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Make *id fields unsigned.
|
|
|
|
*/
|
|
|
|
function statistics_update_8001() {
|
|
|
|
db_drop_primary_key('node_counter');
|
|
|
|
db_change_field('node_counter', 'nid', 'nid',
|
|
|
|
array(
|
|
|
|
'description' => 'The {node}.nid for these statistics.',
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
),
|
|
|
|
array('primary key' => array('nid'))
|
|
|
|
);
|
|
|
|
}
|
2012-11-09 22:30:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert variables to state.
|
|
|
|
*/
|
|
|
|
function statistics_update_8002() {
|
|
|
|
update_variables_to_state(array(
|
|
|
|
'node_cron_views_scale' => 'statistics.node_counter_scale',
|
|
|
|
'statistics_day_timestamp' => 'statistics.day_timestamp',
|
|
|
|
));
|
|
|
|
}
|