|
1 <?php |
|
2 // $Id: xmlsitemap_node.install,v 1.9.2.65 2009/06/10 15:16:55 earnie Exp $ |
|
3 |
|
4 /** |
|
5 * @file |
|
6 * Installation file for XML sitemap node. |
|
7 */ |
|
8 |
|
9 /***************************************************************************** |
|
10 * Drupal hooks. |
|
11 ****************************************************************************/ |
|
12 |
|
13 /** |
|
14 * Implementation of hook_enable(). |
|
15 */ |
|
16 function xmlsitemap_node_enable() { |
|
17 xmlsitemap_flag_sitemap(); |
|
18 } |
|
19 |
|
20 /** |
|
21 * Implementation of hook_disable(). |
|
22 */ |
|
23 function xmlsitemap_node_disable() { |
|
24 xmlsitemap_flag_sitemap(); |
|
25 } |
|
26 |
|
27 /** |
|
28 * Implementation of hook_schema(). |
|
29 */ |
|
30 function xmlsitemap_node_schema() { |
|
31 $schema['xmlsitemap_node'] = array( |
|
32 'description' => 'The base table for xmlsitemap_node.', |
|
33 'fields' => array( |
|
34 'nid' => array( |
|
35 'description' => 'The node ID.', |
|
36 'type' => 'int', |
|
37 'unsigned' => TRUE, |
|
38 'not null' => TRUE, |
|
39 'default' => 0, |
|
40 ), |
|
41 'changed' => array( |
|
42 'description' => 'The Unix timestamp of the last change.', |
|
43 'type' => 'int', |
|
44 'unsigned' => TRUE, |
|
45 'not null' => TRUE, |
|
46 'default' => 0, |
|
47 ), |
|
48 'previously_changed' => array( |
|
49 'description' => 'The Unix timestamp of the previous change.', |
|
50 'type' => 'int', |
|
51 'unsigned' => TRUE, |
|
52 'not null' => TRUE, |
|
53 'default' => 0, |
|
54 ), |
|
55 'comment_ratio' => array( |
|
56 'description' => 'The ratio between the node comments and the maximum number of comments added to a node.', |
|
57 'type' => 'float', |
|
58 'not null' => TRUE, |
|
59 'default' => 0.0, |
|
60 ), |
|
61 'priority_override' => array( |
|
62 'description' => 'The priority of the node in the sitemap.', |
|
63 'type' => 'float', |
|
64 'not null' => TRUE, |
|
65 'default' => -2.0, |
|
66 ), |
|
67 ), |
|
68 'primary key' => array('nid'), |
|
69 ); |
|
70 |
|
71 return $schema; |
|
72 } |
|
73 |
|
74 /** |
|
75 * Implementation of hook_install(). |
|
76 */ |
|
77 function xmlsitemap_node_install() { |
|
78 drupal_install_schema('xmlsitemap_node'); |
|
79 db_query("UPDATE {system} SET weight = 5 WHERE name = 'xmlsitemap_node'"); |
|
80 } |
|
81 |
|
82 /** |
|
83 * Implementation of hook_update_N(). |
|
84 * |
|
85 */ |
|
86 function xmlsitemap_node_update_6100() { |
|
87 $ret = array(); |
|
88 if (db_table_exists('xmlsitemap_node')) { |
|
89 if (db_column_exists('xmlsitemap_node', 'pid')) { |
|
90 $result = array(); |
|
91 @db_drop_index($result, 'xmlsitemap_node', 'pid'); |
|
92 if ($result[0]['success']) { |
|
93 $ret[] = $result[0]; |
|
94 } |
|
95 db_drop_field($ret, 'xmlsitemap_node', 'pid'); |
|
96 } |
|
97 if (db_column_exists('xmlsitemap_node', 'nid')) { |
|
98 $result = array(); |
|
99 @db_drop_primary_key($result, 'xmlsitemap_node'); |
|
100 if ($result[0]['success']) { |
|
101 $ret[] = $result[0]; |
|
102 } |
|
103 db_change_field($ret, 'xmlsitemap_node', 'nid', 'nid', |
|
104 array( |
|
105 'description' => 'The node ID.', |
|
106 'type' => 'int', |
|
107 'unsigned' => TRUE, |
|
108 'not null' => TRUE, |
|
109 'default' => 0, |
|
110 ), |
|
111 array('primary key' => array('nid')) |
|
112 ); |
|
113 } |
|
114 else { |
|
115 db_add_field($ret, 'xmlsitemap_node', 'nid', |
|
116 array( |
|
117 'description' => 'The node ID.', |
|
118 'type' => 'int', |
|
119 'unsigned' => TRUE, |
|
120 'not null' => TRUE, |
|
121 'default' => 0, |
|
122 ), |
|
123 array('primary key' => array('nid')) |
|
124 ); |
|
125 } |
|
126 if (db_column_exists('xmlsitemap_node', 'vid')) { |
|
127 db_drop_field($ret, 'xmlsitemap_node', 'vid'); |
|
128 } |
|
129 if (db_column_exists('xmlsitemap_node', 'last_changed')) { |
|
130 db_change_field($ret, 'xmlsitemap_node', 'last_changed', 'changed', |
|
131 array( |
|
132 'description' => 'The Unix timestamp of the last change.', |
|
133 'type' => 'int', |
|
134 'unsigned' => TRUE, |
|
135 'not null' => TRUE, |
|
136 'default' => 0, |
|
137 ) |
|
138 ); |
|
139 } |
|
140 else { |
|
141 if (db_column_exists('xmlsitemap_node', 'changed')) { |
|
142 db_change_field($ret, 'xmlsitemap_node', 'changed', 'changed', |
|
143 array( |
|
144 'description' => 'The Unix timestamp of the last change.', |
|
145 'type' => 'int', |
|
146 'unsigned' => TRUE, |
|
147 'not null' => TRUE, |
|
148 'default' => 0, |
|
149 ) |
|
150 ); |
|
151 } |
|
152 else { |
|
153 db_add_field($ret, 'xmlsitemap_node', 'changed', |
|
154 array( |
|
155 'description' => 'The Unix timestamp of the last change.', |
|
156 'type' => 'int', |
|
157 'unsigned' => TRUE, |
|
158 'not null' => TRUE, |
|
159 'default' => 0, |
|
160 ) |
|
161 ); |
|
162 } |
|
163 } |
|
164 if (db_column_exists('xmlsitemap_node', 'last_comment')) { |
|
165 db_drop_field($ret, 'xmlsitemap_node', 'last_comment'); |
|
166 } |
|
167 if (db_column_exists('xmlsitemap_node', 'previous_comment')) { |
|
168 db_drop_field($ret, 'xmlsitemap_node', 'previous_comment'); |
|
169 } |
|
170 if (!db_column_exists('xmlsitemap_node', 'comment_ratio')) { |
|
171 db_add_field($ret, 'xmlsitemap_node', 'comment_ratio', |
|
172 array( |
|
173 'description' => 'The ratio between the node comments and the maximum number of comments added to a node.', |
|
174 'type' => 'float', |
|
175 'not null' => TRUE, |
|
176 'default' => 0.0, |
|
177 ) |
|
178 ); |
|
179 } |
|
180 else { |
|
181 db_change_field($ret, 'xmlsitemap_node', 'comment_ratio', 'comment_ratio', |
|
182 array( |
|
183 'description' => 'The ratio between the node comments and the maximum number of comments added to a node.', |
|
184 'type' => 'float', |
|
185 'not null' => TRUE, |
|
186 'default' => 0.0, |
|
187 ) |
|
188 ); |
|
189 } |
|
190 $ret[] = update_sql("UPDATE {xmlsitemap_node} |
|
191 SET priority_override = -2.0 |
|
192 WHERE priority_override IS NULL" |
|
193 ); |
|
194 db_change_field($ret, 'xmlsitemap_node', 'priority_override', 'priority_override', |
|
195 array( |
|
196 'description' => 'The priority of the node in the sitemap.', |
|
197 'type' => 'float', |
|
198 'not null' => TRUE, |
|
199 'default' => -2.0, |
|
200 ) |
|
201 ); |
|
202 } |
|
203 else { |
|
204 db_create_table($ret, 'xmlsitemap_node', |
|
205 array( |
|
206 'description' => 'The base table for xmlsitemap_node.', |
|
207 'fields' => array( |
|
208 'nid' => array( |
|
209 'description' => 'The node ID.', |
|
210 'type' => 'int', |
|
211 'unsigned' => TRUE, |
|
212 'not null' => TRUE, |
|
213 'default' => 0, |
|
214 ), |
|
215 'changed' => array( |
|
216 'description' => 'The Unix timestamp of the last change.', |
|
217 'type' => 'int', |
|
218 'unsigned' => TRUE, |
|
219 'not null' => TRUE, |
|
220 'default' => 0, |
|
221 ), |
|
222 'previously_changed' => array( |
|
223 'description' => 'The Unix timestamp of the previous change.', |
|
224 'type' => 'int', |
|
225 'unsigned' => TRUE, |
|
226 'not null' => TRUE, |
|
227 'default' => 0, |
|
228 ), |
|
229 'comment_ratio' => array( |
|
230 'description' => 'The ratio between the node comments and the maximum number of comments added to a node.', |
|
231 'type' => 'float', |
|
232 'not null' => TRUE, |
|
233 'default' => 0.0, |
|
234 ), |
|
235 'priority_override' => array( |
|
236 'description' => 'The priority of the node in the sitemap.', |
|
237 'type' => 'float', |
|
238 'not null' => TRUE, |
|
239 'default' => -2.0, |
|
240 ), |
|
241 ), |
|
242 'primary key' => array('nid'), |
|
243 ) |
|
244 ); |
|
245 } |
|
246 if (variable_get('xmlsitemap_node_comment_priority', 0.5) == 0.5) { |
|
247 variable_set('xmlsitemap_node_comment_priority', 0.2); |
|
248 $ret[] = array( |
|
249 'success' => TRUE, |
|
250 'query' => 'UPDATE MODULE SETTINGS', |
|
251 ); |
|
252 } |
|
253 return $ret; |
|
254 } |
|
255 |
|
256 /** |
|
257 * Implementation of hook_update_N(). |
|
258 * |
|
259 */ |
|
260 function xmlsitemap_node_update_6106() { |
|
261 $ret[] = update_sql("UPDATE {system} SET weight = 5 WHERE name = 'xmlsitemap_node'"); |
|
262 return $ret; |
|
263 } |
|
264 |
|
265 /** |
|
266 * Implementation of hook_uninstall(). |
|
267 */ |
|
268 function xmlsitemap_node_uninstall() { |
|
269 drupal_uninstall_schema('xmlsitemap_node'); |
|
270 db_query("DELETE FROM {variable} WHERE name LIKE 'xmlsitemap\_node\_%'"); |
|
271 } |