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