1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implementation of hook_install(). |
---|
5 | */ |
---|
6 | function statistics_install() { |
---|
7 | // Create tables. |
---|
8 | drupal_install_schema('statistics'); |
---|
9 | } |
---|
10 | |
---|
11 | /** |
---|
12 | * Changes session ID field to VARCHAR(64) to add support for SHA-1 hashes. |
---|
13 | */ |
---|
14 | function statistics_update_1000() { |
---|
15 | $ret = array(); |
---|
16 | |
---|
17 | switch ($GLOBALS['db_type']) { |
---|
18 | case 'mysql': |
---|
19 | case 'mysqli': |
---|
20 | $ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''"); |
---|
21 | break; |
---|
22 | case 'pgsql': |
---|
23 | db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''")); |
---|
24 | break; |
---|
25 | } |
---|
26 | |
---|
27 | return $ret; |
---|
28 | } |
---|
29 | |
---|
30 | /** |
---|
31 | * Implementation of hook_uninstall(). |
---|
32 | */ |
---|
33 | function statistics_uninstall() { |
---|
34 | // Remove tables. |
---|
35 | drupal_uninstall_schema('statistics'); |
---|
36 | |
---|
37 | variable_del('statistics_count_content_views'); |
---|
38 | variable_del('statistics_enable_access_log'); |
---|
39 | variable_del('statistics_flush_accesslog_timer'); |
---|
40 | variable_del('statistics_day_timestamp'); |
---|
41 | variable_del('statistics_block_top_day_num'); |
---|
42 | variable_del('statistics_block_top_all_num'); |
---|
43 | variable_del('statistics_block_top_last_num'); |
---|
44 | } |
---|
45 | |
---|
46 | /** |
---|
47 | * Implementation of hook_schema(). |
---|
48 | */ |
---|
49 | function statistics_schema() { |
---|
50 | $schema['accesslog'] = array( |
---|
51 | 'description' => 'Stores site access information for statistics.', |
---|
52 | 'fields' => array( |
---|
53 | 'aid' => array( |
---|
54 | 'type' => 'serial', |
---|
55 | 'not null' => TRUE, |
---|
56 | 'description' => 'Primary Key: Unique accesslog ID.', |
---|
57 | ), |
---|
58 | 'sid' => array( |
---|
59 | 'type' => 'varchar', |
---|
60 | 'length' => 64, |
---|
61 | 'not null' => TRUE, |
---|
62 | 'default' => '', |
---|
63 | 'description' => 'Browser session ID of user that visited page.', |
---|
64 | ), |
---|
65 | 'title' => array( |
---|
66 | 'type' => 'varchar', |
---|
67 | 'length' => 255, |
---|
68 | 'not null' => FALSE, |
---|
69 | 'description' => 'Title of page visited.', |
---|
70 | ), |
---|
71 | 'path' => array( |
---|
72 | 'type' => 'varchar', |
---|
73 | 'length' => 255, |
---|
74 | 'not null' => FALSE, |
---|
75 | 'description' => 'Internal path to page visited (relative to Drupal root.)', |
---|
76 | ), |
---|
77 | 'url' => array( |
---|
78 | 'type' => 'text', |
---|
79 | 'not null' => FALSE, |
---|
80 | 'description' => 'Referrer URI.', |
---|
81 | ), |
---|
82 | 'hostname' => array( |
---|
83 | 'type' => 'varchar', |
---|
84 | 'length' => 128, |
---|
85 | 'not null' => FALSE, |
---|
86 | 'description' => 'Hostname of user that visited the page.', |
---|
87 | ), |
---|
88 | 'uid' => array( |
---|
89 | 'type' => 'int', |
---|
90 | 'unsigned' => TRUE, |
---|
91 | 'not null' => FALSE, |
---|
92 | 'default' => 0, |
---|
93 | 'description' => 'User {users}.uid that visited the page.', |
---|
94 | ), |
---|
95 | 'timer' => array( |
---|
96 | 'type' => 'int', |
---|
97 | 'unsigned' => TRUE, |
---|
98 | 'not null' => TRUE, |
---|
99 | 'default' => 0, |
---|
100 | 'description' => 'Time in milliseconds that the page took to load.', |
---|
101 | ), |
---|
102 | 'timestamp' => array( |
---|
103 | 'type' => 'int', |
---|
104 | 'unsigned' => TRUE, |
---|
105 | 'not null' => TRUE, |
---|
106 | 'default' => 0, |
---|
107 | 'description' => 'Timestamp of when the page was visited.', |
---|
108 | ), |
---|
109 | ), |
---|
110 | 'indexes' => array( |
---|
111 | 'accesslog_timestamp' => array('timestamp'), |
---|
112 | 'uid' => array('uid'), |
---|
113 | ), |
---|
114 | 'primary key' => array('aid'), |
---|
115 | ); |
---|
116 | |
---|
117 | return $schema; |
---|
118 | } |
---|
119 | |
---|
120 | /** |
---|
121 | * @addtogroup updates-6.x-extra |
---|
122 | * @{ |
---|
123 | */ |
---|
124 | |
---|
125 | /** |
---|
126 | * Allow longer referrers. |
---|
127 | */ |
---|
128 | function statistics_update_6000() { |
---|
129 | $ret = array(); |
---|
130 | db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE)); |
---|
131 | return $ret; |
---|
132 | } |
---|
133 | |
---|
134 | /** |
---|
135 | * @} End of "addtogroup updates-6.x-extra". |
---|
136 | * The next series of updates should start at 7000. |
---|
137 | */ |
---|