|
1 <?php |
|
2 // $Id: xmlsitemap_user.install,v 1.6.2.61 2009/06/16 14:10:43 earnie Exp $ |
|
3 |
|
4 /** |
|
5 * @file |
|
6 * Installation file for XML sitemap user. |
|
7 */ |
|
8 |
|
9 /***************************************************************************** |
|
10 * Drupal hooks. |
|
11 ****************************************************************************/ |
|
12 |
|
13 /** |
|
14 * Implementation of hook_enable(). |
|
15 */ |
|
16 function xmlsitemap_user_enable() { |
|
17 xmlsitemap_flag_sitemap(); |
|
18 } |
|
19 |
|
20 /** |
|
21 * Implementation of hook_disable(). |
|
22 */ |
|
23 function xmlsitemap_user_disable() { |
|
24 xmlsitemap_flag_sitemap(); |
|
25 } |
|
26 |
|
27 /** |
|
28 * Implementation of hook_schema(). |
|
29 */ |
|
30 function xmlsitemap_user_schema() { |
|
31 $schema['xmlsitemap_user'] = array( |
|
32 'description' => 'The base table for xmlsitemap_user.', |
|
33 'fields' => array( |
|
34 'uid' => array( |
|
35 'description' => 'The user 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 'comments' => array( |
|
56 'description' => 'The number of comments authored from the user.', |
|
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('uid'), |
|
70 ); |
|
71 $schema['xmlsitemap_user_role'] = array( |
|
72 'description' => 'The user roles settings table.', |
|
73 'fields' => array( |
|
74 'rid' => array( |
|
75 'description' => 'The role ID.', |
|
76 'type' => 'int', |
|
77 'unsigned' => TRUE, |
|
78 'not null' => TRUE, |
|
79 'default' => 0, |
|
80 ), |
|
81 'priority' => array( |
|
82 'description' => 'The priority assigned to the role.', |
|
83 'type' => 'float', |
|
84 'not null' => TRUE, |
|
85 'default' => 0.5, |
|
86 ), |
|
87 ), |
|
88 'primary key' => array('rid'), |
|
89 ); |
|
90 return $schema; |
|
91 } |
|
92 |
|
93 /** |
|
94 * Implementation of hook_install(). |
|
95 */ |
|
96 function xmlsitemap_user_install() { |
|
97 drupal_install_schema('xmlsitemap_user'); |
|
98 db_query("UPDATE {system} SET weight = 10 WHERE name = 'xmlsitemap_user'"); |
|
99 } |
|
100 |
|
101 /** |
|
102 * Implementation of hook_update_N(). |
|
103 */ |
|
104 function xmlsitemap_user_update_6100() { |
|
105 $ret = array(); |
|
106 if (db_table_exists('xmlsitemap_user')) { |
|
107 if (db_column_exists('xmlsitemap_user', 'pid')) { |
|
108 $result = array(); |
|
109 @db_drop_index($result, 'xmlsitemap_user', 'pid'); |
|
110 if ($result[0]['success']) { |
|
111 $ret = $result[0]; |
|
112 } |
|
113 db_drop_field($ret, 'xmlsitemap_user', 'pid'); |
|
114 } |
|
115 if (db_column_exists('xmlsitemap_user', 'uid')) { |
|
116 $result = array(); |
|
117 @db_drop_primary_key($result, 'xmlsitemap_user'); |
|
118 if ($result[0]['success']) { |
|
119 $ret[] = $result[0]; |
|
120 } |
|
121 db_change_field($ret, 'xmlsitemap_user', 'uid', 'uid', |
|
122 array( |
|
123 'description' => 'The user ID.', |
|
124 'type' => 'int', |
|
125 'unsigned' => TRUE, |
|
126 'not null' => TRUE, |
|
127 'default' => 0, |
|
128 ), |
|
129 array('primary key' => array('uid')) |
|
130 ); |
|
131 } |
|
132 if (db_column_exists('xmlsitemap_user', 'last_changed')) { |
|
133 db_change_field($ret, 'xmlsitemap_user', 'last_changed', 'changed', |
|
134 array( |
|
135 'description' => 'The Unix timestamp of the last change.', |
|
136 'type' => 'int', |
|
137 'unsigned' => TRUE, |
|
138 'not null' => TRUE, |
|
139 'default' => 0, |
|
140 ) |
|
141 ); |
|
142 } |
|
143 else { |
|
144 if (db_column_exists('xmlsitemap_user', 'changed')) { |
|
145 db_change_field($ret, 'xmlsitemap_user', 'changed', 'changed', |
|
146 array( |
|
147 'description' => 'The Unix timestamp of the last change.', |
|
148 'type' => 'int', |
|
149 'unsigned' => TRUE, |
|
150 'not null' => TRUE, |
|
151 'default' => 0, |
|
152 ) |
|
153 ); |
|
154 } |
|
155 else { |
|
156 db_add_field($ret, 'xmlsitemap_user', 'changed', |
|
157 array( |
|
158 'description' => 'The Unix timestamp of the last change.', |
|
159 'type' => 'int', |
|
160 'unsigned' => TRUE, |
|
161 'not null' => TRUE, |
|
162 'default' => 0, |
|
163 ) |
|
164 ); |
|
165 } |
|
166 } |
|
167 if (!db_column_exists('xmlsitemap_user', 'comments')) { |
|
168 db_add_field($ret, 'xmlsitemap_user', 'comments', |
|
169 array( |
|
170 'description' => 'The number of comments authored from the user.', |
|
171 'type' => 'int', |
|
172 'unsigned' => TRUE, |
|
173 'not null' => TRUE, |
|
174 'default' => 0, |
|
175 ) |
|
176 ); |
|
177 } |
|
178 $ret[] = update_sql("UPDATE {xmlsitemap_user} |
|
179 SET priority_override = -2.0 |
|
180 WHERE priority_override IS NULL" |
|
181 ); |
|
182 db_change_field($ret, 'xmlsitemap_user', 'priority_override', 'priority_override', |
|
183 array( |
|
184 'description' => 'The priority of the term in the sitemap.', |
|
185 'type' => 'float', |
|
186 'not null' => TRUE, |
|
187 'default' => -2.0, |
|
188 ) |
|
189 ); |
|
190 } |
|
191 else { |
|
192 db_create_table($ret, 'xmlsitemap_user', |
|
193 array( |
|
194 'description' => 'The base table for xmlsitemap_user.', |
|
195 'fields' => array( |
|
196 'uid' => array( |
|
197 'description' => 'The user ID.', |
|
198 'type' => 'int', |
|
199 'unsigned' => TRUE, |
|
200 'not null' => TRUE, |
|
201 'default' => 0, |
|
202 ), |
|
203 'changed' => array( |
|
204 'description' => 'The Unix timestamp of the last change.', |
|
205 'type' => 'int', |
|
206 'unsigned' => TRUE, |
|
207 'not null' => TRUE, |
|
208 'default' => 0, |
|
209 ), |
|
210 'previously_changed' => array( |
|
211 'description' => 'The Unix timestamp of the previous change.', |
|
212 'type' => 'int', |
|
213 'unsigned' => TRUE, |
|
214 'not null' => TRUE, |
|
215 'default' => 0, |
|
216 ), |
|
217 'comments' => array( |
|
218 'description' => 'The number of comments authored from the user.', |
|
219 'type' => 'int', |
|
220 'unsigned' => TRUE, |
|
221 'not null' => TRUE, |
|
222 'default' => 0, |
|
223 ), |
|
224 'priority_override' => array( |
|
225 'description' => 'The priority of the term in the sitemap.', |
|
226 'type' => 'float', |
|
227 'not null' => TRUE, |
|
228 'default' => -2.0, |
|
229 ), |
|
230 ), |
|
231 'primary key' => array('uid'), |
|
232 ) |
|
233 ); |
|
234 } |
|
235 if (db_table_exists('xmlsitemap_user_role')) { |
|
236 if (db_column_exists('xmlsitemap_user_role', 'pid')) { |
|
237 $result = array(); |
|
238 @db_drop_index($result, 'xmlsitemap_user_role', 'pid'); |
|
239 if ($result[0]['success']) { |
|
240 $ret = $result[0]; |
|
241 } |
|
242 db_drop_field($ret, 'xmlsitemap_user_role', 'pid'); |
|
243 } |
|
244 $result = array(); |
|
245 @db_drop_primary_key($result, 'xmlsitemap_user_role'); |
|
246 if ($result[0]['success']) { |
|
247 $ret[] = $result[0]; |
|
248 } |
|
249 db_change_field($ret, 'xmlsitemap_user_role', 'rid', 'rid', |
|
250 array( |
|
251 'description' => 'The role ID.', |
|
252 'type' => 'int', |
|
253 'unsigned' => TRUE, |
|
254 'not null' => TRUE, |
|
255 'default' => 0, |
|
256 ), |
|
257 array('primary key' => array('rid')) |
|
258 ); |
|
259 $ret[] = update_sql("UPDATE {xmlsitemap_user_role} |
|
260 SET priority = 0.5 |
|
261 WHERE priority IS NULL" |
|
262 ); |
|
263 db_change_field($ret, 'xmlsitemap_user_role', 'priority', 'priority', |
|
264 array( |
|
265 'description' => t('The priority assigned to the role.'), |
|
266 'type' => 'float', |
|
267 'not null' => TRUE, |
|
268 'default' => 0.5, |
|
269 ) |
|
270 ); |
|
271 db_change_field($ret, 'xmlsitemap_user_role', 'priority', 'priority', |
|
272 array( |
|
273 'description' => t('The priority assigned to the role.'), |
|
274 'type' => 'float', |
|
275 'not null' => TRUE, |
|
276 'default' => 0.5, |
|
277 ) |
|
278 ); |
|
279 } |
|
280 else { |
|
281 db_create_table($ret, 'xmlsitemap_user_role', |
|
282 array( |
|
283 'description' => 'The base table for xmlsitemap.', |
|
284 'fields' => array( |
|
285 'rid' => array( |
|
286 'description' => 'The role ID.', |
|
287 'type' => 'int', |
|
288 'unsigned' => TRUE, |
|
289 'not null' => TRUE, |
|
290 'default' => 0, |
|
291 ), |
|
292 'priority' => array( |
|
293 'description' => t('The priority assigned to the role.'), |
|
294 'type' => 'float', |
|
295 'not null' => TRUE, |
|
296 'default' => 0.5, |
|
297 ), |
|
298 ), |
|
299 'primary key' => array('rid'), |
|
300 ) |
|
301 ); |
|
302 } |
|
303 return $ret; |
|
304 } |
|
305 |
|
306 /** |
|
307 * Implementation of hook_update_N(). |
|
308 * |
|
309 */ |
|
310 function xmlsitemap_user_update_6113() { |
|
311 $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'xmlsitemap_user'"); |
|
312 return $ret; |
|
313 } |
|
314 |
|
315 /** |
|
316 * Implementation of hook_uninstall(). |
|
317 */ |
|
318 function xmlsitemap_user_uninstall() { |
|
319 drupal_uninstall_schema('xmlsitemap_user'); |
|
320 } |