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