-
Notifications
You must be signed in to change notification settings - Fork 0
/
ableorganizer.install
1532 lines (1366 loc) · 45.7 KB
/
ableorganizer.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @file
* Install, update and uninstall functions for the installation profile.
*/
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function ableorganizer_install() {
$t = get_t();
// Add text formats.
$filtered_html_format = array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// HTML filter.
'filter_html' => array(
'weight' => 1,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 2,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 3,
'status' => 1,
),
'media_filter' => array(
'weight' => 4,
'status' => 1,
),
'pathologic' => array(
'weight' => 5,
'status' => 1,
),
),
);
$filtered_html_format = (object) $filtered_html_format;
filter_format_save($filtered_html_format);
$full_html_format = array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 1,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 2,
'status' => 1,
),
'media_filter' => array(
'weight' => 3,
'status' => 1,
),
'pathologic' => array(
'weight' => 4,
'status' => 1,
),
),
);
$full_html_format = (object) $full_html_format;
filter_format_save($full_html_format);
// Define default node types.
$types = array(
array(
'type' => 'page',
'name' => $t('Basic page'),
'base' => 'node_content',
'description' => $t("Use <em>basic pages</em> for your static content, such as an 'About us' page."),
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
array(
'type' => 'article',
'name' => $t('Article'),
'base' => 'node_content',
'description' => $t('Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.'),
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
);
// Create default node types.
foreach ($types as $type) {
$type = node_type_set_defaults($type);
node_type_save($type);
node_add_body_field($type);
}
// Insert default pre-defined RDF mapping into the database.
$rdf_mappings = array(
array(
'type' => 'node',
'bundle' => 'page',
'mapping' => array(
'rdftype' => array('foaf:Document'),
),
),
array(
'type' => 'node',
'bundle' => 'article',
'mapping' => array(
'field_image' => array(
'predicates' => array('og:image', 'rdfs:seeAlso'),
'type' => 'rel',
),
'field_tags' => array(
'predicates' => array('dc:subject'),
'type' => 'rel',
),
),
),
);
foreach ($rdf_mappings as $rdf_mapping) {
rdf_mapping_save($rdf_mapping);
}
// Default "Basic page" to not be promoted and have comments disabled.
variable_set('node_options_page', array('status'));
variable_set('comment_page', COMMENT_NODE_HIDDEN);
// Don't display date and author information for "Basic page" nodes.
variable_set('node_submitted_page', FALSE);
// Enable user picture support and set the default to a square thumbnail.
variable_set('user_pictures', '1');
variable_set('user_picture_dimensions', '1024x1024');
variable_set('user_picture_file_size', '800');
variable_set('user_picture_style', 'thumbnail');
// Allow visitor account creation with administrative approval.
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
// Create a default vocabulary named "Tags", enabled for articles.
$description = $t('Use tags to group articles on similar topics into categories.');
$help = $t('Enter a comma-separated list of words to describe your content.');
$vocabulary = (object) array(
'name' => $t('Tags'),
'description' => $description,
'machine_name' => 'tags',
'help' => $help,
);
taxonomy_vocabulary_save($vocabulary);
$field = array(
'field_name' => 'field_' . $vocabulary->machine_name,
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $vocabulary->machine_name,
'parent' => 0,
),
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_' . $vocabulary->machine_name,
'entity_type' => 'node',
'label' => 'Tags',
'bundle' => 'article',
'description' => $vocabulary->help,
'widget' => array(
'type' => 'taxonomy_autocomplete',
'weight' => -4,
),
'display' => array(
'default' => array(
'type' => 'taxonomy_term_reference_link',
'weight' => 10,
),
'teaser' => array(
'type' => 'taxonomy_term_reference_link',
'weight' => 10,
),
),
);
field_create_instance($instance);
// Add image to article.
$field = array(
'field_name' => 'field_image',
'type' => 'image',
'cardinality' => 1,
'locked' => FALSE,
'indexes' => array('fid' => array('fid')),
'settings' => array(
'uri_scheme' => 'public',
'default_image' => FALSE,
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
),
);
field_create_field($field);
// Many of the following values will be defaulted, they're included here as
// an illustrative examples.
// See http://api.drupal.org/api/function/field_create_instance/7
$instance = array(
'field_name' => 'field_image',
'entity_type' => 'node',
'label' => 'Image',
'bundle' => 'article',
'description' => $t('Upload an image to go with this article.'),
'required' => FALSE,
'settings' => array(
'file_directory' => 'field/image',
'file_extensions' => 'png gif jpg jpeg',
'max_filesize' => '',
'max_resolution' => '',
'min_resolution' => '',
'alt_field' => TRUE,
'title_field' => '',
),
'widget' => array(
'type' => 'image_image',
'settings' => array(
'progress_indicator' => 'throbber',
'preview_image_style' => 'thumbnail',
),
'weight' => -1,
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'image',
'settings' => array('image_style' => 'large', 'image_link' => ''),
'weight' => -1,
),
'teaser' => array(
'label' => 'hidden',
'type' => 'image',
'settings' => array(
'image_style' => 'medium',
'image_link' => 'content',
),
'weight' => -1,
),
),
);
field_create_instance($instance);
// Enable default permissions for system roles.
$filtered_html_permission = filter_permission_name($filtered_html_format);
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
'access content',
'access comments',
$filtered_html_permission,
));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
'access content',
'access comments',
'post comments',
'skip comment approval',
$filtered_html_permission,
));
// Create a default role for site administrators, with all available
// permissions assigned.
$admin_role = new stdClass();
$admin_role->name = 'administrator';
$admin_role->weight = 2;
user_role_save($admin_role);
user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
// Set this as the administrator role.
variable_set('user_admin_role', $admin_role->rid);
// Assign user 1 the "administrator" role.
db_insert('users_roles')
->fields(array('uid' => 1, 'rid' => $admin_role->rid))
->execute();
// Enable the admin theme.
variable_set('admin_theme', 'seven');
variable_set('node_admin_theme', '0');
// Enable the template theme for ableorganizer.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', 'ao_frontend_template')
->execute();
variable_set('theme_default', 'ao_frontend_template');
// Configure CRM Core Contact matching rules.
// Enable the default engine.
db_insert('crm_core_match_engines')
->fields(array(
'machine_name' => 'default_matching_engine',
'weight' => 10,
'status' => 1,
))
->execute();
// Enable the default match engine for contacts of type "individual".
db_insert('crm_core_match_contact_types')
->fields(array(
'contact_type' => 'individual',
'threshold' => 30,
'status' => 1,
'strict' => 0,
'return_order' => 'created',
))
->execute();
// Add contact name and email matching rules for individuals.
$contact_type_rules = array(
array(
'individual',
'contact_name',
'name',
'given',
'equals',
10,
1,
-25,
),
array(
'individual',
'contact_name',
'name',
'family',
'equals',
20,
1,
-24,
),
array(
'individual',
'field_ao_email_address',
'email',
'email',
'equals',
30,
1,
-23,
),
);
$query = db_insert('crm_core_match_contact_type_rules')
->fields(array(
'contact_type',
'field_name',
'field_type',
'field_item',
'operator',
'score',
'status',
'weight',
));
foreach ($contact_type_rules as $contact_type_rule) {
$query->values($contact_type_rule);
}
$query->execute();
// Set CRM Core user sync defaults (authenticated users to individuals).
variable_set('crm_core_user_sync_rules', array(
0 => array(
'rid' => '2',
'contact_type' => 'individual',
'weight' => '0',
'enabled' => 1,
),
));
// Configure CRM Core primary fields.
$individual_contact_type = crm_core_contact_type_load('individual');
$individual_contact_type->primary_fields = array(
'email' => 'field_ao_email_address',
'address' => 'field_ao_home_address',
'phone' => 'field_ao_primary_telephone',
);
crm_core_contact_type_save($individual_contact_type);
// Setup mimemail format and off mimemail sitestyle.
variable_set('mimemail_format', 'full_html');
variable_set('mimemail_sitestyle', 0);
// Setting default theme for CRM Core.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', 'ao_contact_management')
->execute();
variable_set('crm_core_theme_enabled', 1);
variable_set('crm_core_theme', 'ao_contact_management');
// Now set CRM Core to use the CRM Core menu.
variable_set('crm_core_theme_replace_links', 1);
// Now turn on the dashboard.
variable_set('crm_core_dashboard_enabled', 1);
variable_set('crm_core_dashboard_path', 'crm-core/ableorganizer_dashboard');
$item = array(
'link_path' => 'crm-core/dashboard',
'link_title' => 'Dashboard',
'menu_name' => 'crm-core-menu',
'weight' => 0,
);
menu_link_save($item);
// Now set the default logo.
$theme_name = 'ao_contact_management';
$var_name = 'theme_' . $theme_name . '_settings';
$new_path = 'profiles/ableorganizer/images/ao-logo.png';
$settings = variable_get($var_name, array());
$settings['logo_path'] = $new_path;
variable_set($var_name, $settings);
// Now set the default user picture.
variable_set("user_pictures", 1);
variable_set("user_picture_default", "profiles/ableorganizer/images/user-pic-default.png");
// Compact forms settings.
variable_set('compact_forms_ids', "user-login-form
crm-core-profile-entry-form-ao-annual-appeal-form
crm-core-profile-entry-form-ao-fundraiser-form
crm-core-profile-entry-form-ao-donation-form
crm-core-profile-entry-form-ao-cmcev-simple-single-form
crm-core-profile-entry-form-ao-cmcev-simple-quantity-form
crm-core-profile-entry-form-ao-cmcev-simple-many-form
crm-core-profile-entry-form-ao-cmcev-simple-reg-form
crm-core-profile-entry-form-short-petition-with-message
crm-core-profile-entry-form-canvass-signatures
crm-core-profile-entry-form-short-online-petition
crm-core-profile-entry-form-signature-drive
crm-core-profile-entry-form-ao-volunteer-commitment-form-2
crm-core-profile-entry-form-ao-volunteer-commitment-form");
variable_set("compact_forms_field_size", "");
variable_set("compact_forms_descriptions", 1);
variable_set("compact_forms_stars ", "2");
// Ensure submitted information is off for the major content types.
variable_set("node_submitted_cmcd_page", 0);
variable_set("node_submitted_cmcev_event", 0);
variable_set("node_submitted_cmcp_petition", 0);
variable_set("node_submitted_cmcv_volunteer", 0);
variable_set("node_submitted_page", 0);
variable_set("node_submitted_article", 0);
// Enable blocks.
// This must be done after the theme has been installed.
// TODO: add CRM Core in the header.
$default_theme = variable_get('theme_default', 'ao_frontend_template');
$admin_theme = 'seven';
$blocks = array(
array(
'module' => 'menu',
'delta' => 'crm-core-menu',
'theme' => $default_theme,
'status' => 1,
'weight' => 0,
'region' => 'header',
'pages' => '',
'cache' => -1,
'title' => 'Contact Management',
),
array(
'module' => 'system',
'delta' => 'main',
'theme' => $default_theme,
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
'title' => '',
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => $default_theme,
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
'title' => '',
),
array(
'module' => 'crm_core_profile',
'delta' => 'crm_core_profile_form_viewer',
'theme' => $default_theme,
'status' => 1,
'weight' => 10,
'region' => 'sidebar_second',
'pages' => '',
'cache' => -1,
'title' => '',
),
array(
'module' => 'system',
'delta' => 'main',
'theme' => $admin_theme,
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
'title' => '',
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => $admin_theme,
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1,
'title' => '',
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'ao_contact_management',
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
'title' => '',
),
);
$query = db_insert('block')->fields(array(
'module',
'delta',
'theme',
'status',
'weight',
'region',
'pages',
'cache',
'title',
));
foreach ($blocks as $block) {
$query->values($block);
}
$query->execute();
// Set permissions for the crm core menu.
// This should only be available to administrators by default.
db_insert('block_role')
->fields(
array(
'module' => 'menu',
'delta' => 'crm-core-menu',
'rid' => 3,
)
)
->execute();
// We need this to clear node_load cache after importing sample content in
// order to prevent 'Notice: Undefined property: stdClass::$changed' msg.
variable_set('search_active_modules', array('ableorganizer', 'node', 'user'));
$saved_fonts = array(
'Cabin 500 (latin)' => array(
'name' => 'Cabin 500 (latin)',
'enabled' => 1,
'url' => 'http://www.google.com/webfonts/family?family=Cabin&subset=latin#500',
'provider' => 'google_fonts_api',
'css_selector' => 'h1, h2, h3, h4, h5, h6',
'css_family' => 'Cabin',
'css_style' => 'normal',
'css_weight' => 500,
'css_fallbacks' => '',
'foundry' => '',
'foundry_url' => '',
'license' => '',
'license_url' => '',
'designer' => '',
'designer_url' => '',
'metadata' => 'a:2:{s:4:"path";s:9:"Cabin:500";s:6:"subset";s:5:"latin";}',
),
'Cabin regular (latin)' => array(
'name' => 'Cabin regular (latin)',
'enabled' => 1,
'url' => 'http://www.google.com/webfonts/family?family=Cabin&subset=latin#regular',
'provider' => 'google_fonts_api',
'css_selector' => 'body',
'css_family' => 'Cabin',
'css_style' => 'normal',
'css_weight' => 'normal',
'css_fallbacks' => '',
'foundry' => '',
'foundry_url' => '',
'license' => '',
'license_url' => '',
'designer' => '',
'designer_url' => '',
'metadata' => 'a:2:{s:4:"path";s:13:"Cabin:regular";s:6:"subset";s:5:"latin";}',
),
);
foreach ($saved_fonts as $key => $font) {
$font = (object) $font;
$font->tags = array();
$saved = fontyourface_save_font($font, TRUE);
}
}
/**
* Force-set a theme at any point during the execution of the request.
*
* Drupal doesn't give us the option to set the theme during the installation
* process and forces enable the maintenance theme too early in the request
* for us to modify it in a clean way.
*/
function _ableorganizer_set_theme($target_theme) {
if ($GLOBALS['theme'] != $target_theme) {
unset($GLOBALS['theme']);
drupal_static_reset();
$GLOBALS['conf']['maintenance_theme'] = $target_theme;
_drupal_maintenance_theme();
}
}
/**
* Implements hook_install_tasks_alter().
*/
function ableorganizer_install_tasks_alter(&$tasks, $install_state) {
$t = get_t();
// Set the installation theme.
_ableorganizer_set_theme('ao_contact_management');
// Remove some profile steps.
$tasks['install_select_profile']['display'] = FALSE;
if (!empty($install_state['parameters']['locale'])) {
$tasks['install_select_locale']['display'] = FALSE;
}
if ($install_state['interactive']) {
// Display a welcome message.
$new_task = array();
$new_task['ableorganizer_welcome'] = array(
'display' => TRUE,
'display_name' => $t('Welcome'),
'type' => 'form',
'run' => isset($install_state['parameters']['welcome']) ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_REACHED,
);
$tasks = $new_task + $tasks;
}
$new_tasks = array();
// Configure features.
$new_tasks['ableorganizer_features'] = array(
'display' => TRUE,
'display_name' => $t('Select features'),
'type' => 'form',
'run' => isset($install_state['parameters']['features']) ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_REACHED,
);
// Configure profile settings.
$new_tasks['ableorganizer_profile_settings'] = array(
'display' => TRUE,
'display_name' => $t('Messaging and currency settings'),
'type' => 'form',
'run' => isset($install_state['parameters']['profile_settings']) ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_REACHED,
);
// Select sample content.
$new_tasks['ableorganizer_sample_content'] = array(
'display' => TRUE,
'display_name' => $t('Sample content and data'),
'type' => 'form',
'run' => isset($install_state['parameters']['sample_content']) ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_REACHED,
);
// Select sample content.
$new_tasks['ableorganizer_install_sample_content'] = array(
'display' => TRUE,
'display_name' => $t('Install sample content and data'),
'type' => 'batch',
'run' => isset($install_state['parameters']['install_sample_content']) ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_REACHED,
);
$tasks = array_slice($tasks, 0, 11) + $new_tasks + array_slice($tasks, 11);
// Change the name of the other install profile step.
$tasks['install_profile_modules']['display_name'] = $t('Install modules');
}
/**
* Task callback: shows the welcome screen.
*/
function ableorganizer_welcome($form, &$form_state, &$install_state) {
$t = get_t();
drupal_set_title($t('Welcome to AbleOrganizer'));
$message = '';
$message .= '<p>' . $t('This Drupal distribution includes powerful features for tracking information about people, activities and relationships built with CRM Core.') . '</p>';
$message .= '<p>' . $t('The following features are included as part of this distro:') . '</p>';
$message .= '<ul>';
$message .= '<li>' . $t('Donations: donation pages, source tracking and reports.');
$message .= '<li>' . $t('Events: event registration, attendance and reports.');
$message .= '<li>' . $t('Petitions: signature gathering, targeted emails and reports.');
$message .= '<li>' . $t('Volunteer: volunteer management and reports.');
$message .= '</ul>';
$form = array();
$form['welcome_message'] = array(
'#markup' => $message,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $t("Get started!"),
'#weight' => 10,
);
return $form;
}
/**
* Install welcome submission handler.
*/
function ableorganizer_welcome_submit($form, &$form_state) {
global $install_state;
$install_state['parameters']['welcome'] = 'done';
}
/**
* Implements hook_form_FORM_ID_alter().
*
* Clears any unneeded status messages after modules are installed.
*/
function ableorganizer_form_install_configure_form_alter(&$form, &$form_state, $form_id) {
drupal_get_messages('status');
}
/**
* Task callback.
*
* Select the features you are going to install with AbleOrganizer
*/
function ableorganizer_features($form, &$form_state, &$install_state) {
$t = get_t();
// This is the page where we select the features to be installed.
drupal_set_title($t('Select features'));
$form = array();
$form['basic_desc'] = array(
'#markup' => $t('<h2>AbleOrganizer features</h2>AbleOrganizer includes a variety of tools for interacting with your community. Select the ones that are right for your site.'),
);
$form['settings_wrapper'] = array(
'#type' => 'fieldset',
'#title' => $t('Features'),
);
$form['settings_wrapper']['desc'] = array(
'#markup' => $t('Select the tools you would like to install.'),
);
// Donations.
$form['settings_wrapper']['install_donations'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
'#title' => $t('Donations'),
'#description' => $t('Includes donation pages, source tracking, and reports.'),
);
// Events.
$form['settings_wrapper']['install_events'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
'#title' => $t('Events'),
'#description' => $t('Includes event registration, attendance and reports.'),
);
// Petitions.
$form['settings_wrapper']['install_petitions'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
'#title' => $t('Petitions'),
'#description' => $t('Includes signature gathering, targeted emails and reports.'),
);
// Volunteer.
$form['settings_wrapper']['install_volunteer'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
'#title' => $t('Volunteer'),
'#description' => $t('Includes volunteer management and reports.'),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $t('Continue'),
'#weight' => 15,
);
return $form;
}
/**
* Features submission handler.
*/
function ableorganizer_features_submit($form, &$form_state) {
global $install_state;
$modules = array();
// Default settings.
variable_set('donations_enabled', 0);
variable_set('events_enabled', 0);
variable_set('petitions_enabled', 0);
variable_set('volunteer_enabled', 0);
// This is where we turn on various features.
if (!empty($form_state['values']['install_donations'])) {
$modules[] = 'crm_core_donation';
variable_set('donations_enabled', 1);
// Set default colors for reports.
variable_set('crm_core_donation_background_color', 'rgba(148, 186, 101, 0.4)
rgba(148, 186, 101, 0)');
variable_set('crm_core_donation_chart_color', 'rgba(255,255,255,1)');
variable_set('crm_core_donation_column_width', '0.8');
variable_set('crm_core_donation_display_labels', '0');
variable_set('crm_core_donation_height', '200');
variable_set('crm_core_donation_include_legend', '0');
variable_set('crm_core_donation_line_color', 'rgba(148, 186, 101, 1)');
variable_set('crm_core_donation_series_colors', 'rgba(49, 165, 189, 1)
rgba(148, 186, 101, 1)
rgba(207, 68, 68, 1)
rgba(155, 89, 168, 1)
rgba(49, 81, 189, 1)');
variable_set('crm_core_donation_xaxis_tickmarks', '7');
}
if (!empty($form_state['values']['install_events'])) {
$modules[] = 'crm_core_event';
variable_set('events_enabled', 1);
// Set defaults for reports.
variable_set('crm_core_event_background_color', 'rgba(49, 165, 189, 0.4)
rgba(49, 165, 189, 0)');
variable_set('crm_core_event_chart_color', 'rgba(255,255,255,1)');
variable_set('crm_core_event_column_width', '0.8');
variable_set('crm_core_event_display_labels', '0');
variable_set('crm_core_event_height', '200');
variable_set('crm_core_event_include_legend', '0');
variable_set('crm_core_event_line_color', 'rgba(49, 165, 189, 1)');
variable_set('crm_core_event_series_colors', 'rgba(49, 165, 189, 1)
rgba(207, 68, 68, 1)
rgba(148, 186, 101, 1)
rgba(155, 89, 168, 1)
rgba(49, 81, 189, 1)');
variable_set('crm_core_event_xaxis_tickmarks', '7');
}
if (!empty($form_state['values']['install_petitions'])) {
$modules[] = 'crm_core_petition';
variable_set('petitions_enabled', 1);
// Report defaults.
variable_set('crm_core_petition_background_color', 'rgba(49, 81, 189, 0.4)
rgba(49, 81, 189, 0)');
variable_set('crm_core_petition_chart_color', 'rgba(255,255,255,1)');
variable_set('crm_core_petition_column_width', '0.8');
variable_set('crm_core_petition_display_labels', '0');
variable_set('crm_core_petition_height', '200');
variable_set('crm_core_petition_include_legend', '0');
variable_set('crm_core_petition_line_color', 'rgba(49, 81, 189, 1)');
variable_set('crm_core_petition_series_colors', 'rgba(49, 81, 189, 1)
rgba(49, 165, 189, 1)
rgba(207, 68, 68, 1)
rgba(148, 186, 101, 1)
rgba(155, 89, 168, 1)');
variable_set('crm_core_petition_show_counter', '1');
variable_set('crm_core_petition_xaxis_tickmarks', '7');
}
if (!empty($form_state['values']['install_volunteer'])) {
$modules[] = 'crm_core_volunteer';
variable_set('volunteer_enabled', 1);
// Report defaults.
variable_set('crm_core_volunteer_background_color', 'rgba(207, 68, 68, 0.4)
rgba(207, 68, 68, 0)');
variable_set('crm_core_volunteer_chart_color', 'rgba(255,255,255,1)');
variable_set('crm_core_volunteer_chart_height', '200');
variable_set('crm_core_volunteer_column_width', '0.8');
variable_set('crm_core_volunteer_display_labels', '0');
variable_set('crm_core_volunteer_include_legend', '0');
variable_set('crm_core_volunteer_line_color', 'rgba(207, 68, 68, 1)');
variable_set('crm_core_volunteer_series_colors', 'rgba(207, 68, 68, 1)
rgba(49, 165, 189, 1)
rgba(148, 186, 101, 1)
rgba(155, 89, 168, 1)
rgba(49, 81, 189, 1)');
variable_set('crm_core_volunteer_xaxis_tickmarks', '7');
}
$modules[] = 'menu_token';
module_enable($modules);
// Flush caches to initialize features.
features_flush_caches();
$install_state['parameters']['features'] = 'done';
}
/**
* Task callback.
*
* Profile settings.
*/
function ableorganizer_profile_settings($form, &$form_state, &$install_state) {
$t = get_t();
drupal_set_title($t('Configure profile settings'));
// Check to make sure we have at least one feature enabled.
if (variable_get('donations_enabled', 0) == 1 || variable_get('events_enabled', 0) == 1 || variable_get('petitions_enabled', 0) == 1 || variable_get('volunteer_enabled', 0) == 1) {
$form['basic_desc'] = array(
'#markup' => $t('<h2>AbleOrganizer messaging</h2>Most of the features in AbleOrganizer are configured to send HTML emails. Select the kinds of communications you would like your site to generate.'),
);
$form['settings_wrapper'] = array(
'#type' => 'fieldset',
'#title' => $t('Message settings'),
);
$form['settings_wrapper']['starter_message'] = array(
'#markup' => $t('Select message settings.'),
);
}
// This should house the email settings for each feature.
// Starting with donations.
if (variable_get('donations_enabled', 0) == 1) {
$form['settings_wrapper']['donation_emails'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
'#title' => $t('Donations'),
'#description' => $t('Check this box to send thank you messages each time a donation is received.'),
);
}
// Next do events.
if (variable_get('events_enabled', 0) == 1) {
$form['settings_wrapper']['event_emails'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
'#title' => $t('Events'),