comparison modules/statistics/statistics.install @ 0:ff03f76ab3fe

initial version
author danieleb <danielebarchiesi@me.com>
date Wed, 21 Aug 2013 18:51:11 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ff03f76ab3fe
1 <?php
2
3 /**
4 * @file
5 * Install, update, and uninstall functions for the Statistics module.
6 */
7
8 /**
9 * Implements hook_uninstall().
10 */
11 function statistics_uninstall() {
12 // Remove variables.
13 variable_del('statistics_count_content_views');
14 variable_del('statistics_enable_access_log');
15 variable_del('statistics_flush_accesslog_timer');
16 variable_del('statistics_day_timestamp');
17 variable_del('statistics_block_top_day_num');
18 variable_del('statistics_block_top_all_num');
19 variable_del('statistics_block_top_last_num');
20 }
21
22 /**
23 * Implements hook_schema().
24 */
25 function statistics_schema() {
26 $schema['accesslog'] = array(
27 'description' => 'Stores site access information for statistics.',
28 'fields' => array(
29 'aid' => array(
30 'type' => 'serial',
31 'not null' => TRUE,
32 'description' => 'Primary Key: Unique accesslog ID.',
33 ),
34 'sid' => array(
35 'type' => 'varchar',
36 'length' => 128,
37 'not null' => TRUE,
38 'default' => '',
39 'description' => 'Browser session ID of user that visited page.',
40 ),
41 'title' => array(
42 'type' => 'varchar',
43 'length' => 255,
44 'not null' => FALSE,
45 'description' => 'Title of page visited.',
46 ),
47 'path' => array(
48 'type' => 'varchar',
49 'length' => 255,
50 'not null' => FALSE,
51 'description' => 'Internal path to page visited (relative to Drupal root.)',
52 ),
53 'url' => array(
54 'type' => 'text',
55 'not null' => FALSE,
56 'description' => 'Referrer URI.',
57 ),
58 'hostname' => array(
59 'type' => 'varchar',
60 'length' => 128,
61 'not null' => FALSE,
62 'description' => 'Hostname of user that visited the page.',
63 ),
64 'uid' => array(
65 'type' => 'int',
66 'unsigned' => TRUE,
67 'not null' => FALSE,
68 'default' => 0,
69 'description' => 'User {users}.uid that visited the page.',
70 ),
71 'timer' => array(
72 'type' => 'int',
73 'unsigned' => TRUE,
74 'not null' => TRUE,
75 'default' => 0,
76 'description' => 'Time in milliseconds that the page took to load.',
77 ),
78 'timestamp' => array(
79 'type' => 'int',
80 'unsigned' => TRUE,
81 'not null' => TRUE,
82 'default' => 0,
83 'description' => 'Timestamp of when the page was visited.',
84 ),
85 ),
86 'indexes' => array(
87 'accesslog_timestamp' => array('timestamp'),
88 'uid' => array('uid'),
89 ),
90 'primary key' => array('aid'),
91 'foreign keys' => array(
92 'visitor' => array(
93 'table' => 'users',
94 'columns' => array('uid' => 'uid'),
95 ),
96 ),
97 );
98
99 $schema['node_counter'] = array(
100 'description' => 'Access statistics for {node}s.',
101 'fields' => array(
102 'nid' => array(
103 'description' => 'The {node}.nid for these statistics.',
104 'type' => 'int',
105 'not null' => TRUE,
106 'default' => 0,
107 ),
108 'totalcount' => array(
109 'description' => 'The total number of times the {node} has been viewed.',
110 'type' => 'int',
111 'unsigned' => TRUE,
112 'not null' => TRUE,
113 'default' => 0,
114 'size' => 'big',
115 ),
116 'daycount' => array(
117 'description' => 'The total number of times the {node} has been viewed today.',
118 'type' => 'int',
119 'unsigned' => TRUE,
120 'not null' => TRUE,
121 'default' => 0,
122 'size' => 'medium',
123 ),
124 'timestamp' => array(
125 'description' => 'The most recent time the {node} has been viewed.',
126 'type' => 'int',
127 'unsigned' => TRUE,
128 'not null' => TRUE,
129 'default' => 0,
130 ),
131 ),
132 'primary key' => array('nid'),
133 );
134
135 return $schema;
136 }
137
138 /**
139 * @addtogroup updates-6.x-to-7.x
140 * @{
141 */
142
143 /**
144 * Update the {accesslog}.sid column to match the length of {sessions}.sid
145 */
146 function statistics_update_7000() {
147 db_change_field('accesslog', 'sid', 'sid', array(
148 'type' => 'varchar',
149 'length' => 128,
150 'not null' => TRUE,
151 'default' => '',
152 'description' => 'Browser session ID of user that visited page.',
153 ));
154 }
155
156 /**
157 * @} End of "addtogroup updates-6.x-to-7.x".
158 */