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

Contents of /contributions/modules/competition/competition.install

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


Revision 1.15 - (show annotations) (download) (as text)
Mon Jun 2 09:35:38 2008 UTC (17 months, 3 weeks ago) by colan
Branch: MAIN
CVS Tags: HEAD
Changes since 1.14: +4 -9 lines
File MIME type: text/x-php
Created a view for use in the nodereference picker for winners.
1 <?php
2 // $Id: competition.install,v 1.14 2008/05/31 05:07:58 colan Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function competition_install() {
8
9 // Create any content types.
10 $definitions = competition_define_content_types();
11 foreach ($definitions as $definition) {
12 competition_create_content_type($definition);
13 }
14
15 // Do any other setup here.
16
17 }
18
19 /**
20 * Implementation of hook_uninstall().
21 *
22 * @todo
23 * Make sure that all CCK stuff is deleted.
24 */
25 function competition_uninstall() {
26
27 // Delete all variables.
28 variable_del('competition_round');
29 variable_del('competition_phase');
30 variable_del('competition_voting_days');
31 variable_del('competition_state_changed');
32 variable_del('competition_standings_private');
33
34 // Destroy any created content types and fields.
35 node_type_delete('competition');
36 $t_args = array('%name' => 'Competition');
37 drupal_set_message(t('The content type %name has been deleted.', $t_args));
38 watchdog('menu', t('Deleted content type %name.', $t_args), WATCHDOG_NOTICE);
39
40 node_type_delete('competition_entry');
41 $t_args = array('%name' => 'Competition Entry');
42 drupal_set_message(t('The content type %name has been deleted.', $t_args));
43 watchdog('menu', t('Deleted content type %name.', $t_args), WATCHDOG_NOTICE);
44
45 // Rebuild the node types & menu.
46 node_types_rebuild();
47 menu_rebuild();
48
49 // Delete any tables that may be lingering.
50 if (db_table_exists('content_type_competition')) {
51 db_query("DROP TABLE {content_type_competition}");
52 }
53 if (db_table_exists('content_type_competition_entry')) {
54 db_query("DROP TABLE {content_type_competition_entry}");
55 }
56 if (db_table_exists('content_field_competition_content_types')) {
57 db_query("DROP TABLE {content_field_competition_content_types}");
58 }
59 if (db_table_exists('content_field_competition_prizes')) {
60 db_query("DROP TABLE {content_field_competition_prizes}");
61 }
62 if (db_table_exists('content_field_competition_winners')) {
63 db_query("DROP TABLE {content_field_competition_winners}");
64 }
65 if (db_table_exists('content_field_competition_entry_helpers')) {
66 db_query("DROP TABLE {content_field_competition_entry_helpers}");
67 }
68
69 // Do any other takedown here.
70
71 }
72
73 /**
74 * Create a content type.
75 *
76 * See http://groups.drupal.org/node/5272 for details.
77 *
78 * @param $macro
79 * The content type definition from a CCK export.
80 * @return <void>
81 * Nothing is returned, but the content is created.
82 */
83
84 function competition_create_content_type($macro) {
85
86 // Includes some files.
87 include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
88 include_once './'. drupal_get_path('module', 'content') .'/content_admin.inc';
89
90 // Define that which needs to be executed, the content type creation.
91 $values = array();
92 $values['type_name'] ='<create>';
93 $values['macro'] = $macro;
94
95 // Execute the above.
96 drupal_execute("content_copy_import_form", $values);
97 }
98
99 /**
100 * Declare content type definitions.
101 *
102 * @return
103 * An array of CCK type exports in string format.
104 */
105 function competition_define_content_types() {
106 $definitions = array();
107
108 // Define a competition.
109 $definitions[] = <<<COMPETITION
110 \$content[type] = array (
111 'name' => 'Competition',
112 'type' => 'competition',
113 'description' => 'This is a limited-duration competition that allows entrants to compete based on their content submissions.',
114 'title_label' => 'Name',
115 'body_label' => 'Description',
116 'min_word_count' => '0',
117 'help' => '',
118 'node_options' =>
119 array (
120 'status' => true,
121 'promote' => false,
122 'sticky' => false,
123 'revision' => false,
124 ),
125 'comment' => '0',
126 'upload' => '1',
127 'privatemsg_link' =>
128 array (
129 'node' => false,
130 'teaser' => false,
131 'comment' => false,
132 ),
133 'old_type' => 'competition',
134 'orig_type' => '',
135 'module' => 'node',
136 'custom' => '1',
137 'modified' => '1',
138 'locked' => '0',
139 'send_type' => 'competition',
140 'send_competition_fulltext' => '',
141 'send_competition_linktext' => 'send to friend',
142 'send_competition_subject' => 'Send to Friend from Plan Youth',
143 'send_competition_message' => '',
144 'send_competition_template' => '%message
145 %body
146 ',
147 'send_competition' => 0,
148 'send_competition_pernode' => '',
149 );
150 \$content[fields] = array (
151 0 =>
152 array (
153 'widget_type' => 'number',
154 'label' => 'Round',
155 'weight' => '1',
156 'description' => 'This is the site-wide round that the competition is associated with. Each competition must be associated with a particular round, represented by a positive integer.',
157 'default_value_widget' =>
158 array (
159 'field_competition_round' =>
160 array (
161 0 =>
162 array (
163 'value' => '',
164 ),
165 ),
166 ),
167 'default_value_php' => '',
168 'markup' =>
169 array (
170 'prefix' => '',
171 'suffix' => '',
172 ),
173 'group' => false,
174 'required' => '1',
175 'multiple' => '0',
176 'min' => '1',
177 'max' => '',
178 'prefix' => '',
179 'suffix' => '',
180 'allowed_values' => '',
181 'allowed_values_php' => '',
182 'field_name' => 'field_competition_round',
183 'field_type' => 'number_integer',
184 'module' => 'number',
185 'default_value' =>
186 array (
187 0 =>
188 array (
189 'value' => '',
190 ),
191 ),
192 ),
193 1 =>
194 array (
195 'widget_type' => 'date_select',
196 'label' => 'Period',
197 'weight' => '2',
198 'default_value' => 'blank',
199 'default_value_code' => '',
200 'default_value2' => 'same',
201 'default_value_code2' => '',
202 'input_format' => 'Y-m-d H:i:s',
203 'input_format_custom' => '',
204 'year_range' => '-3:+3',
205 'increment' => '1',
206 'advanced' =>
207 array (
208 'label_position' => 'above',
209 'text_parts' =>
210 array (
211 'year' => 0,
212 'month' => 0,
213 'day' => 0,
214 'hour' => 0,
215 'minute' => 0,
216 'second' => 0,
217 ),
218 ),
219 'description' => '',
220 'markup' =>
221 array (
222 'prefix' => '',
223 'suffix' => '',
224 ),
225 'group' => false,
226 'required' => '1',
227 'multiple' => '0',
228 'repeat' => NULL,
229 'todate' => 'required',
230 'granularity' =>
231 array (
232 'year' => true,
233 'month' => true,
234 'day' => true,
235 'hour' => true,
236 'minute' => true,
237 1 => 1,
238 0 => 1,
239 'second' => false,
240 ),
241 'output_format_date' => 'Y-m-d H:i e',
242 'output_format_custom' => '',
243 'output_format_date_long' => 'l, F j, Y - H:i',
244 'output_format_custom_long' => '',
245 'output_format_date_medium' => 'D, Y-m-d H:i',
246 'output_format_custom_medium' => '',
247 'output_format_date_short' => 'Y-m-d H:i',
248 'output_format_custom_short' => '',
249 'tz_handling' => 'site',
250 'timezone_db' => 'UTC',
251 'field_name' => 'field_competition_period',
252 'field_type' => 'date',
253 'module' => 'date',
254 ),
255 2 =>
256 array (
257 'widget_type' => 'options_buttons',
258 'label' => 'Content Types',
259 'weight' => '3',
260 'description' => 'Select the content types that can be entered into this competition.',
261 'default_value_widget' =>
262 array (
263 'field_competition_content_types' =>
264 array (
265 'keys' =>
266 array (
267 'mp_audio' => false,
268 'blog' => false,
269 'group' => false,
270 'competition' => false,
271 'competition_entry' => false,
272 'tv_episode' => false,
273 'event' => false,
274 'forum' => false,
275 'mp_image' => false,
276 'tv_interview' => false,
277 'news' => false,
278 'page' => false,
279 'site_graphic' => false,
280 'story' => false,
281 'mp_video' => false,
282 'vote' => false,
283 ),
284 ),
285 ),
286 'default_value_php' => '',
287 'markup' =>
288 array (
289 'prefix' => '',
290 'suffix' => '',
291 ),
292 'group' => false,
293 'required' => '0',
294 'multiple' => '1',
295 'text_processing' => '0',
296 'max_length' => '',
297 'allowed_values' => '',
298 'allowed_values_php' => 'if (module_exists(\'competition\')) {
299 return competition_node_get_types();
300 }',
301 'field_name' => 'field_competition_content_types',
302 'field_type' => 'text',
303 'module' => 'text, optionwidgets',
304 ),
305 3 =>
306 array (
307 'widget_type' => 'number',
308 'label' => 'Voting Period',
309 'weight' => '4',
310 'description' => 'Users will be allowed to vote on this competition\'s content for the above number of days. If left unset, the site-wide default will be used instead. The site-wide default can be viewed/edited over at <a href="/admin/settings/competition">Competition settings</a>.',
311 'default_value_widget' =>
312 array (
313 'field_competition_voting_days' =>
314 array (
315 0 =>
316 array (
317 'value' => '',
318 ),
319 ),
320 ),
321 'default_value_php' => '',
322 'markup' =>
323 array (
324 'prefix' => '',
325 'suffix' => '',
326 ),
327 'group' => false,
328 'required' => '0',
329 'multiple' => '0',
330 'min' => '1',
331 'max' => '',
332 'prefix' => '',
333 'suffix' => ' day| days',
334 'allowed_values' => '',
335 'allowed_values_php' => '',
336 'field_name' => 'field_competition_voting_days',
337 'field_type' => 'number_integer',
338 'module' => 'number',
339 ),
340 4 =>
341 array (
342 'widget_type' => 'text',
343 'label' => 'Prizes',
344 'weight' => '6',
345 'rows' => '6',
346 'description' => '',
347 'default_value_widget' =>
348 array (
349 'field_competition_prizes' =>
350 array (
351 0 =>
352 array (
353 'value' => '',
354 ),
355 1 =>
356 array (
357 'value' => '',
358 ),
359 2 =>
360 array (
361 'value' => '',
362 ),
363 ),
364 ),
365 'field_competition_prizes' =>
366 array (
367 0 =>
368 array (
369 'format' => 1,
370 ),
371 1 =>
372 array (
373 'format' => 1,
374 ),
375 2 =>
376 array (
377 'format' => 1,
378 ),
379 ),
380 'default_value_php' => '',
381 'markup' =>
382 array (
383 'prefix' => '',
384 'suffix' => '',
385 ),
386 'group' => false,
387 'required' => '0',
388 'multiple' => '1',
389 'text_processing' => '1',
390 'max_length' => '',
391 'allowed_values' => '',
392 'allowed_values_php' => '',
393 'field_name' => 'field_competition_prizes',
394 'field_type' => 'text',
395 'module' => 'text',
396 ),
397 5 =>
398 array (
399 'widget_type' => 'nodereference_autocomplete',
400 'label' => 'Winners',
401 'weight' => '8',
402 'description' => 'Please begin entering the names of the winning entries, and they will be autocompleted as you type.',
403 'default_value_widget' =>
404 array (
405 'field_competition_winners' =>
406 array (
407 0 =>
408 array (
409 'node_name' => '',
410 ),
411 1 =>
412 array (
413 'node_name' => '',
414 ),
415 2 =>
416 array (
417 'node_name' => '',
418 ),
419 ),
420 ),
421 'default_value_php' => '',
422 'markup' =>
423 array (
424 'prefix' => '',
425 'suffix' => '',
426 ),
427 'group' => false,
428 'required' => '0',
429 'multiple' => '1',
430 'referenceable_types' =>
431 array (
432 1 => 1,
433 0 => 1,
434 'mp_audio' => false,
435 'blog' => false,
436 'group' => false,
437 'competition' => false,
438 'competition_entry' => false,
439 'tv_episode' => false,
440 'event' => false,
441 'forum' => false,
442 'mp_image' => false,
443 'tv_interview' => false,
444 'news' => false,
445 'page' => false,
446 'site_graphic' => false,
447 'story' => false,
448 'mp_video' => false,
449 'vote' => false,
450 ),
451 'advanced_view' => 'competition_entries_list',
452 'advanced_view_args' => '',
453 'field_name' => 'field_competition_winners',
454 'field_type' => 'nodereference',
455 'module' => 'nodereference',
456 ),
457 6 =>
458 array (
459 'widget_type' => 'text',
460 'label' => 'Terms and Conditions',
461 'weight' => '10',
462 'rows' => '3',
463 'description' => '',
464 'default_value_widget' =>
465 array (
466 'field_competition_terms' =>
467 array (
468 0 =>
469 array (
470 'value' => '',
471 ),
472 ),
473 ),
474 'field_competition_terms' =>
475 array (
476 0 =>
477 array (
478 'format' => 1,
479 ),
480 ),
481 'default_value_php' => '',
482 'markup' =>
483 array (
484 'prefix' => '',
485 'suffix' => '',
486 ),
487 'group' => false,
488 'required' => '0',
489 'multiple' => '0',
490 'text_processing' => '1',
491 'max_length' => '',
492 'allowed_values' => '',
493 'allowed_values_php' => '',
494 'field_name' => 'field_competition_terms',
495 'field_type' => 'text',
496 'module' => 'text',
497 ),
498 );
499 COMPETITION;
500
501 // Define a competition entry.
502 $definitions[] = <<<COMPETITION_ENTRY
503 \$content[type] = array (
504 'name' => 'Competition Entry',
505 'type' => 'competition_entry',
506 'description' => 'This is an entry that can be submitted to a competition once it has content associated with it.',
507 'title_label' => 'Name',
508 'body_label' => 'Description',
509 'min_word_count' => '10',
510 'help' => '',
511 'jcarousellite' => '0',
512 'node_options' =>
513 array (
514 'status' => true,
515 'promote' => false,
516 'sticky' => false,
517 'revision' => false,
518 ),
519 'comment' => '2',
520 'upload' => '0',
521 'privatemsg_link' =>
522 array (
523 'node' => false,
524 'teaser' => false,
525 'comment' => false,
526 ),
527 'old_type' => 'competition_entry',
528 'orig_type' => '',
529 'module' => 'node',
530 'custom' => '1',
531 'modified' => '1',
532 'locked' => '0',
533 'send_type' => 'competition_entry',
534 'send_competition_entry_fulltext' => '',
535 'send_competition_entry_linktext' => 'send to friend',
536 'send_competition_entry_subject' => 'Send to Friend from Plan Youth',
537 'send_competition_entry_message' => '',
538 'send_competition_entry_template' => '%message
539 %body
540 ',
541 'send_competition_entry' => 0,
542 'send_competition_entry_pernode' => '',
543 );
544 \$content[fields] = array (
545 0 =>
546 array (
547 'widget_type' => 'text',
548 'label' => 'Creator',
549 'weight' => '2',
550 'rows' => '1',
551 'description' => '',
552 'default_value_widget' =>
553 array (
554 'field_competition_entry_creator' =>
555 array (
556 0 =>
557 array (
558 'value' => '',
559 ),
560 ),
561 ),
562 'default_value_php' => 'global \$user;
563
564 return array(
565 0 => array(\'value\' => \$user->name),
566 );',
567 'markup' =>
568 array (
569 'prefix' => '',
570 'suffix' => '',
571 ),
572 'group' => false,
573 'required' => '1',
574 'multiple' => '0',
575 'text_processing' => '0',
576 'max_length' => '',
577 'allowed_values' => '',
578 'allowed_values_php' => '',
579 'field_name' => 'field_competition_entry_creator',
580 'field_type' => 'text',
581 'module' => 'text',
582 'default_value' =>
583 array (
584 ),
585 ),
586 1 =>
587 array (
588 'widget_type' => 'userreference_autocomplete',
589 'label' => 'Collaborators',
590 'weight' => '4',
591 'description' => 'Provide the usernames of the people who helped create this project with you. Each name will be autocompleted as you type.',
592 'default_value_widget' =>
593 array (
594 'field_competition_entry_helpers' =>
595 array (
596 0 =>
597 array (
598 'user_name' => '',
599 ),
600 1 =>
601 array (
602 'user_name' => '',
603 ),
604 2 =>
605 array (
606 'user_name' => '',
607 ),
608 ),
609 ),
610 'default_value_php' => '',
611 'markup' =>
612 array (
613 'prefix' => '',
614 'suffix' => '',
615 ),
616 'group' => false,
617 'required' => '0',
618 'multiple' => '1',
619 'referenceable_roles' =>
620 array (
621 2 => true,
622 0 => 1,
623 3 => false,
624 6 => false,
625 5 => false,
626 4 => false,
627 ),
628 'field_name' => 'field_competition_entry_helpers',
629 'field_type' => 'userreference',
630 'module' => 'userreference',
631 ),
632 2 =>
633 array (
634 'widget_type' => 'nodereference_select',
635 'label' => 'Competition',
636 'weight' => '6',
637 'description' => 'Select the competition that you would like to enter. Once the selected competition has closed, this entry will be automatically submitted and you will no longer be able to edit it.',
638 'default_value_widget' =>
639 array (
640 'field_competition_entry_comp' =>
641 array (
642 'nids' =>
643 array (
644 0 => '0',
645 ),
646 ),
647 ),
648 'default_value_php' => '',
649 'markup' =>
650 array (
651 'prefix' => '',
652 'suffix' => '',
653 ),
654 'group' => false,
655 'required' => '0',
656 'multiple' => '0',
657 'referenceable_types' =>
658 array (
659 'blog' => false,
660 'group' => false,
661 'competition' => false,
662 'competition_entry' => false,
663 'forum' => false,
664 'page' => false,
665 'story' => false,
666 ),
667 'advanced_view' => 'competition_open',
668 'advanced_view_args' => '',
669 'field_name' => 'field_competition_entry_comp',
670 'field_type' => 'nodereference',
671 'module' => 'nodereference',
672 ),
673 3 =>
674 array (
675 'widget_type' => 'options_select',
676 'label' => 'Terms and Conditions',
677 'weight' => '8',
678 'description' => 'You will not be able to submit this entry until you accept the terms and conditions for the competition you are entering.',
679 'default_value_widget' =>
680 array (
681 'field_competition_entry_legal' =>
682 array (
683 'key' => '',
684 ),
685 ),
686 'default_value_php' => '',
687 'markup' =>
688 array (
689 'prefix' => '',
690 'suffix' => '',
691 ),
692 'group' => false,
693 'required' => '1',
694 'multiple' => '0',
695 'min' => '',
696 'max' => '',
697 'prefix' => '',
698 'suffix' => '',
699 'allowed_values' => '|
700 1|I accept this competition\'s terms and conditions',
701 'allowed_values_php' => '',
702 'field_name' => 'field_competition_entry_legal',
703 'field_type' => 'number_integer',
704 'module' => 'number, optionwidgets',
705 ),
706 );
707 COMPETITION_ENTRY;
708
709 return $definitions;
710 }

  ViewVC Help
Powered by ViewVC 1.1.2