/[drupal]/contributions/modules/tribune/tribune.install
ViewVC logotype

Contents of /contributions/modules/tribune/tribune.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.28 - (show annotations) (download) (as text)
Fri Nov 28 22:30:42 2008 UTC (11 months, 3 weeks ago) by seeschloss
Branch: MAIN
CVS Tags: HEAD
Changes since 1.27: +7 -5 lines
File MIME type: text/x-php
*** empty log message ***
1 <?php
2 // vim:filetype=php expandtab tabstop=2 softtabstop=2 shiftwidth=2 autoindent smartindent
3 // $Id: tribune.install,v 1.27 2008/11/28 12:59:32 seeschloss Exp $
4
5 function tribune_update_6207() {
6 $ret = array();
7
8 $schema['tribune_tribunes'] = array(
9 'description' => t("The table containing all tribunes and their names"),
10 'fields' => array(
11 'nid' => array(
12 'type' => 'int',
13 'not null' => TRUE,
14 'description' => "ID of the corresponding node",
15 ),
16 'banned_useragents' => array(
17 'type' => 'text',
18 'not null' => TRUE,
19 'description' => "List of useragents banned from posting in this tribune",
20 ),
21 'banned_usernames' => array(
22 'type' => 'text',
23 'not null' => TRUE,
24 'description' => "List of usernames banned from posting in this tribune",
25 ),
26 'banned_messages' => array(
27 'type' => 'text',
28 'not null' => TRUE,
29 'description' => "List of strings forbidden in this tribune",
30 ),
31 'max_message_size' => array(
32 'type' => 'int',
33 'not null' => TRUE,
34 'default' => 512,
35 'description' => "Maximum length of a post",
36 ),
37 'history_size' => array(
38 'type' => 'int',
39 'not null' => TRUE,
40 'default' => 25,
41 'description' => "Number of posts displayed in the page view",
42 ),
43 'xml_size' => array(
44 'type' => 'int',
45 'not null' => TRUE,
46 'default' => 100,
47 'description' => "Number of posts displayed in the XML backend",
48 ),
49 'rss_size' => array(
50 'type' => 'int',
51 'not null' => TRUE,
52 'default' => 50,
53 'description' => "Number of posts displayed in the RSS backend",
54 ),
55 'reload_delay' => array(
56 'type' => 'int',
57 'not null' => TRUE,
58 'default' => 15,
59 'description' => "Delay between AJAX reloading of new posts (0 to disable automatic reloading)",
60 ),
61 'flood_protection_delay' => array(
62 'type' => 'int',
63 'not null' => TRUE,
64 'default' => 0,
65 'description' => "Minimum time before someone can post again (0 disables flood protection)",
66 ),
67 'posts_order' => array(
68 'type' => 'int',
69 'not null' => TRUE,
70 'default' => 0,
71 'description' => "Whether new posts are displayed at the top (0) or at the bottom (1) of the page",
72 ),
73 'show_pager' => array(
74 'type' => 'int',
75 'not null' => TRUE,
76 'default' => 0,
77 'description' => "Whether to display a pager or not",
78 ),
79 'enabled_filters' => array(
80 'type' => 'text',
81 'not null' => TRUE,
82 'description' => "Serialized array of enabled filters for this tribune",
83 ),
84 'variables' => array(
85 'type' => 'text',
86 'not null' => TRUE,
87 'description' => "Serialized array of filters settings for this tribune",
88 ),
89 ),
90 'primary key' => array('nid'),
91 );
92 db_create_table($ret, 'tribune_tribunes', $schema['tribune_tribunes']);
93
94 db_add_field($ret, "tribune", "tribune_id",
95 array(
96 'type' => 'int',
97 'unsigned' => TRUE,
98 'not null' => TRUE,
99 'default' => 0,
100 'description' => "ID of the corresponding tribune",
101 ),
102 array(
103 'indexes' => array(
104 'tribune_id' => array('tribune_id'),
105 ),
106 )
107 );
108
109 db_add_field($ret, "tribune", "tribune_post_id",
110 array(
111 'type' => 'int',
112 'unsigned' => TRUE,
113 'not null' => TRUE,
114 'default' => 0,
115 'description' => "Unique and sequential ID per post per tribune",
116 ),
117 array(
118 'indexes' => array(
119 'tribune_post_id' => array('tribune_post_id'),
120 ),
121 )
122 );
123
124 drupal_set_message(t('Your tribune module has been updated. From now, tribunes are nodes instead of just one page, which means you now have to create a tribune node. The !page should take care of everything.', array('!page' => l('migration page', 'admin/settings/tribune/migration'))));
125
126 return $ret;
127 }
128
129 function tribune_update_6206() {
130 $ret = array();
131
132 db_add_field($ret, "tribune", "uid",
133 array(
134 'type' => 'int',
135 'unsigned' => TRUE,
136 'not null' => TRUE,
137 'default' => 0,
138 'description' => "UID of the user who posted this post (0 for anonymous users)",
139 ),
140 array(
141 'indexes' => array(
142 'uid' => array('uid'),
143 ),
144 )
145 );
146
147 db_add_field($ret, "tribune", "sid",
148 array(
149 'type' => 'varchar',
150 'length' => 64,
151 'not null' => TRUE,
152 'default' => '',
153 'description' => "SID of the user who posted this post (for tracking anonymous users)",
154 ),
155 array(
156 'indexes' => array(
157 'sid' => array('sid'),
158 ),
159 )
160 );
161
162 return $ret;
163 }
164
165 function tribune_update_6205() {
166 $schema['tribune_post_references'] = array(
167 'description' => t("The table for storing which post answers which other posts"),
168 'fields' => array(
169 'reference_id' => array(
170 'type' => 'serial',
171 'not null' => TRUE,
172 'description' => "ID of the source/reference row",
173 ),
174 'target_post_id' => array(
175 'type' => 'int',
176 'not null' => TRUE,
177 'description' => "ID of the referenced post",
178 ),
179 'source_post_id' => array(
180 'type' => 'int',
181 'not null' => TRUE,
182 'description' => "ID of the referencing post",
183 ),
184 'ref_clock_id' => array(
185 'type' => 'int',
186 'not null' => TRUE,
187 'description' => "Number of the referencing clock inside the referencing post",
188 ),
189 ),
190 'primary key' => array('reference_id'),
191 'indexes' => array(
192 'source_post_id' => array('source_post_id'),
193 'target_post_id' => array('target_post_id'),
194 'source_clock_id' => array('source_post_id', 'ref_clock_id'),
195 ),
196 );
197 $ret = array();
198 db_create_table($ret, 'tribune_post_references', $schema['tribune_post_references']);
199
200
201 $nb_updated = 0;
202 $r = db_query("SELECT post_id, referenced_by FROM {tribune}");
203 while ($post = db_fetch_array($r)) {
204 $target_post_id = $post['post_id'];
205
206 $clocks = explode("|", $post['referenced_by']);
207 foreach ($clocks as $clock) {
208 $split = explode("#", $clock);
209
210 if (count($split) == 2) {
211 $source_post_id = $split[0];
212 $ref_clock_id = $split[1];
213 db_query("INSERT INTO {tribune_post_references}
214 SET target_post_id = %d,
215 source_post_id = %d,
216 ref_clock_id = %d",
217 $target_post_id,
218 $source_post_id,
219 $ref_clock_id);
220 $nb_updated++;
221 }
222 }
223 }
224
225 if ($nb_updated) {
226 $ret[] = array('success' => TRUE, 'query' => $nb_updated .' post references updated');
227 }
228
229 db_drop_field($ret, 'tribune', 'referenced_by');
230 return $ret;
231 }
232
233 function tribune_update_6204() {
234 $ret = array();
235
236 db_change_field($ret, "tribune", "post_id", "post_id",
237 array(
238 'type' => 'serial',
239 'not null' => TRUE,
240 )
241 );
242
243 db_change_field($ret, "tribune", "login", "login",
244 array(
245 'type' => 'text',
246 'not null' => TRUE,
247 )
248 );
249
250 db_change_field($ret, "tribune", "info", "info",
251 array(
252 'type' => 'text',
253 'not null' => TRUE,
254 )
255 );
256
257 db_change_field($ret, "tribune", "message", "message",
258 array(
259 'type' => 'text',
260 'not null' => TRUE,
261 )
262 );
263
264 db_change_field($ret, "tribune", "post_time", "post_time",
265 array(
266 'type' => 'varchar',
267 'length' => 14,
268 'not null' => TRUE,
269 'default' => ''
270 ),
271 array(
272 'indexes' => array(
273 'post_time' => array('post_time'),
274 ),
275 )
276 );
277
278 db_change_field($ret, "tribune", "is_alone", "is_alone",
279 array(
280 'type' => 'int',
281 'unsigned' => TRUE,
282 'not null' => TRUE,
283 'default' => 0
284 )
285 );
286
287 db_change_field($ret, "tribune", "post_rank", "post_rank",
288 array(
289 'type' => 'int',
290 'unsigned' => TRUE,
291 'not null' => TRUE,
292 'default' => 0
293 )
294 );
295
296 db_change_field($ret, "tribune", "parsed_message", "parsed_message",
297 array(
298 'type' => 'text',
299 'not null' => TRUE,
300 )
301 );
302
303 db_change_field($ret, "tribune", "referenced_by", "referenced_by",
304 array(
305 'type' => 'text',
306 'not null' => TRUE,
307 )
308 );
309
310 db_change_field($ret, "tribune", "last_modified", "last_modified",
311 array(
312 'type' => 'int',
313 'unsigned' => TRUE,
314 'not null' => TRUE,
315 'default' => 0
316 ),
317 array(
318 'indexes' => array(
319 'last_modified' => array('last_modified'),
320 ),
321 )
322 );
323
324 db_change_field($ret, "tribune", "moderated", "moderated",
325 array(
326 'type' => 'int',
327 'unsigned' => TRUE,
328 'not null' => TRUE,
329 'default' => 0
330 )
331 );
332
333 return $ret;
334 }
335
336 function tribune_update_6203() {
337 tribune_parse_last_messages(NULL);
338
339 return array();
340 }
341
342 function tribune_update_6202() {
343 $enabled_filters = variable_get('tribune_enabled_filters', array('totoz' => "totoz", 'url' => "url"));
344 $enabled_filters['url'] = "url";
345 variable_set('tribune_enabled_filters', $enabled_filters);
346
347 return array();
348 }
349
350 function tribune_update_6201() {
351 $enabled_filters = variable_get('tribune_enabled_filters', array('totoz' => "totoz"));
352 $enabled_filters['totoz'] = "totoz";
353 variable_set('tribune_enabled_filters', $enabled_filters);
354
355 tribune_parse_last_messages(NULL);
356
357 return array();
358 }
359
360 function tribune_update_6200() {
361 $ret = array();
362 db_add_field($ret, "tribune", "moderated", array("type" => "int", "size" => "tiny", "not null" => TRUE, "initial" => 0, "default" => 0));
363 return $ret;
364 }
365
366 function tribune_schema() {
367 $schema['tribune'] = array(
368 'description' => t("The table for storing tribune posts"),
369 'fields' => array(
370 'post_id' => array(
371 'type' => 'serial',
372 'not null' => TRUE,
373 'description' => "Unique id of every post",
374 ),
375 'tribune_id' => array(
376 'type' => 'int',
377 'unsigned' => TRUE,
378 'not null' => TRUE,
379 'default' => 0,
380 'description' => "ID of the corresponding tribune",
381 ),
382 'tribune_post_id' => array(
383 'type' => 'int',
384 'unsigned' => TRUE,
385 'not null' => TRUE,
386 'default' => 0,
387 'description' => "Unique and sequential ID per post per tribune",
388 ),
389 'login' => array(
390 'type' => 'text',
391 'not null' => TRUE,
392 'description' => "Username of the author, or nothing for anonymous posts",
393 ),
394 'info' => array(
395 'type' => 'text',
396 'not null' => TRUE,
397 'description' => "Useragent of the author",
398 ),
399 'message' => array(
400 'type' => 'text',
401 'not null' => TRUE,
402 'description' => "Message as it has been posted by the user and after it has been modified by 'before slip' filters",
403 ),
404 'post_time' => array(
405 'type' => 'varchar',
406 'length' => 14,
407 'not null' => TRUE,
408 'default' => '',
409 'description' => "Time of the post, in UTC, formatted as 'YYYYMMDDhhmmss', used for clocks matching",
410 ),
411 'is_alone' => array(
412 'type' => 'int',
413 'unsigned' => TRUE,
414 'not null' => TRUE,
415 'default' => 0,
416 'description' => "Whether other messages where posted at the same second or not",
417 ),
418 'post_rank' => array(
419 'type' => 'int',
420 'unsigned' => TRUE,
421 'not null' => TRUE,
422 'default' => 0,
423 'description' => "If other messages where posted at the same second, indicates the rank of a post. 0 if no other posts exist at the same post_time",
424 ),
425 'parsed_message' => array(
426 'type' => 'text',
427 'not null' => TRUE,
428 'description' => "Message after it has been modified by 'after slip' filters, with tags filters and ready to be safely printed",
429 ),
430 'last_modified' => array(
431 'type' => 'int',
432 'unsigned' => TRUE,
433 'not null' => TRUE,
434 'default' => 0,
435 'description' => "Time of the last modification of a post, used for ajax reloading",
436 ),
437 'moderated' => array(
438 'type' => 'int',
439 'unsigned' => TRUE,
440 'not null' => TRUE,
441 'default' => 0,
442 'description' => "Whether a post is moderated or not, moderated posts will only be seen by moderators",
443 ),
444 'uid' => array(
445 'type' => 'int',
446 'unsigned' => TRUE,
447 'not null' => TRUE,
448 'default' => 0,
449 'description' => "UID of the user who posted this post (0 for anonymous users)",
450 ),
451 'sid' => array(
452 'type' => 'varchar',
453 'length' => 64,
454 'default' => '',
455 'description' => "SID of the user who posted this post (for tracking anonymous users)",
456 ),
457 ),
458 'primary key' => array('post_id'),
459 'indexes' => array(
460 'post_time' => array('post_time'),
461 'last_modified' => array('last_modified'),
462 'uid' => array('uid'),
463 'sid' => array('sid'),
464 'tribune_id' => array('tribune_id'),
465 'tribune_post_id' => array('tribune_post_id'),
466 ),
467 );
468 $schema['tribune_post_references'] = array(
469 'description' => t("The table for storing which post answers which other posts"),
470 'fields' => array(
471 'reference_id' => array(
472 'type' => 'serial',
473 'not null' => TRUE,
474 'description' => "ID of the source/reference row",
475 ),
476 'target_post_id' => array(
477 'type' => 'int',
478 'not null' => TRUE,
479 'description' => "ID of the referenced post",
480 ),
481 'source_post_id' => array(
482 'type' => 'int',
483 'not null' => TRUE,
484 'description' => "ID of the referencing post",
485 ),
486 'ref_clock_id' => array(
487 'type' => 'int',
488 'not null' => TRUE,
489 'description' => "Number of the referencing clock inside the referencing post",
490 ),
491 ),
492 'primary key' => array('reference_id'),
493 'indexes' => array(
494 'source_post_id' => array('source_post_id'),
495 'target_post_id' => array('target_post_id'),
496 'source_clock_id' => array('source_post_id', 'ref_clock_id'),
497 ),
498 );
499 $schema['tribune_tribunes'] = array(
500 'description' => t("The table containing all tribunes and their names"),
501 'fields' => array(
502 'nid' => array(
503 'type' => 'int',
504 'not null' => TRUE,
505 'description' => "ID of the corresponding node",
506 ),
507 'banned_useragents' => array(
508 'type' => 'text',
509 'not null' => TRUE,
510 'description' => "List of useragents banned from posting in this tribune",
511 ),
512 'banned_usernames' => array(
513 'type' => 'text',
514 'not null' => TRUE,
515 'description' => "List of usernames banned from posting in this tribune",
516 ),
517 'banned_messages' => array(
518 'type' => 'text',
519 'not null' => TRUE,
520 'description' => "List of strings forbidden in this tribune",
521 ),
522 'max_message_size' => array(
523 'type' => 'int',
524 'not null' => TRUE,
525 'default' => 512,
526 'description' => "Maximum length of a post",
527 ),
528 'history_size' => array(
529 'type' => 'int',
530 'not null' => TRUE,
531 'default' => 25,
532 'description' => "Number of posts displayed in the page view",
533 ),
534 'xml_size' => array(
535 'type' => 'int',
536 'not null' => TRUE,
537 'default' => 100,
538 'description' => "Number of posts displayed in the XML backend",
539 ),
540 'rss_size' => array(
541 'type' => 'int',
542 'not null' => TRUE,
543 'default' => 50,
544 'description' => "Number of posts displayed in the RSS backend",
545 ),
546 'reload_delay' => array(
547 'type' => 'int',
548 'not null' => TRUE,
549 'default' => 15,
550 'description' => "Delay between AJAX reloading of new posts (0 to disable automatic reloading)",
551 ),
552 'flood_protection_delay' => array(
553 'type' => 'int',
554 'not null' => TRUE,
555 'default' => 0,
556 'description' => "Minimum time before someone can post again (0 disables flood protection)",
557 ),
558 'posts_order' => array(
559 'type' => 'int',
560 'not null' => TRUE,
561 'default' => 0,
562 'description' => "Whether new posts are displayed at the top (0) or at the bottom (1) of the page",
563 ),
564 'show_pager' => array(
565 'type' => 'int',
566 'not null' => TRUE,
567 'default' => 0,
568 'description' => "Whether to display a pager or not",
569 ),
570 'enabled_filters' => array(
571 'type' => 'text',
572 'not null' => TRUE,
573 'description' => "Serialized array of enabled filters for this tribune",
574 ),
575 'variables' => array(
576 'type' => 'text',
577 'not null' => TRUE,
578 'description' => "Serialized array of filters settings for this tribune",
579 ),
580 ),
581 'primary key' => array('nid'),
582 );
583
584 return $schema;
585 }
586
587 function tribune_install() {
588 drupal_install_schema("tribune");
589 }
590
591 function tribune_uninstall() {
592 drupal_uninstall_schema("tribune");
593
594 variable_del('tribune_global_variables');
595 variable_del('tribune_active_users');
596 variable_del('tribune_pager');
597 variable_del('tribune_order');
598 variable_del('tribune_flood_protection_delay');
599 variable_del('tribune_message');
600 variable_del('tribune_name');
601 variable_del('tribune_reload_delay');
602 variable_del('tribune_max_message_size');
603 variable_del('tribune_xml_size');
604 variable_del('tribune_rss_size');
605 variable_del('tribune_history_size');
606 variable_del('tribune_history_block_size');
607 variable_del('tribune_enabled_filters');
608 variable_del('tribune_blocks');
609 }

  ViewVC Help
Powered by ViewVC 1.1.2