View source
<?php
function nodeviewcount_schema() {
$schema = array();
$schema['nodeviewcount'] = array(
'description' => 'The count views of node for every user.',
'fields' => array(
'id' => array(
'description' => 'The unique ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nid' => array(
'description' => 'The node ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The user ID who view of node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'timestamp' => array(
'description' => 'The Unix timestamp when the node was view.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'nid_uid' => array(
'uid',
'nid',
),
'timestamp' => array(
'timestamp',
),
),
);
return $schema;
}
function nodeviewcount_install() {
variable_set('nodeviewcount_node_types', array());
variable_set('nodeviewcount_user_roles', array());
variable_set('nodeviewcount_way_counting', NODEVIEWCOUNT_PHP_WAY_COUNT_VIEWS);
variable_set('nodeviewcount_flush_log_timer', 0);
}
function nodeviewcount_uninstall() {
variable_del('nodeviewcount_node_types');
variable_del('nodeviewcount_user_roles');
variable_del('nodeviewcount_way_counting');
variable_del('nodeviewcount_flush_log_timer');
}
function nodeviewcount_update_7211() {
$table = 'nodeviewcount';
$index_name = 'nid';
if (db_table_exists($table)) {
if (!db_index_exists($table, $index_name)) {
db_add_index($table, $index_name, array(
'nid',
));
return t('New index added');
}
else {
return t('Index already exist');
}
}
}