-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrupalorg_testing.profile
1479 lines (1341 loc) · 55.1 KB
/
drupalorg_testing.profile
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
// $Id$
/**
* @file
* Installation profile that configures a site to mimic drupal.org,
* especially the project management and issue tracking functionality,
* to facilitate testing. More information can be found in the
* README.txt file.
*
* Some of the constants at the top of this file can be changed to
* customize the profile for your site (names, passwords, domains, etc).
*/
//----------------------------------------
// Settings you probably want to customize
//----------------------------------------
/// The initial password for all of the well-known users created.
define('D_O_PASSWORD', 'a');
/// Name to be used for the user 1 (full admin) account.
define('D_O_USER1', 'a');
/// Domain to use for all user e-mail addresses.
define('D_O_DOMAIN', 'example.com');
//----------------------------------------
// Settings you might want to customize
//----------------------------------------
/// E-mail address to use for the site itself.
define('D_O_SITE_MAIL', D_O_USER1 .'@'. D_O_DOMAIN);
/// Number of users per role the profile will create.
define('D_O_NUM_USERS_PER_ROLE', 2);
/**
* Number of users per role the profile will create CVS accounts for.
*
* By default, each role gets 2 users (e.g. "auth1" and "auth2"), but
* only one of them gets a CVS account (e.g. "auth1"). This is useful
* for testing to see how things on the site behave for people in
* various roles with and without CVS accounts.
*/
define('D_O_NUM_CVS_USERS_PER_ROLE', 1);
//----------------------------------------
// Settings you should not change
//----------------------------------------
define('D_O_ROLE_ANONYMOUS', 1);
define('D_O_ROLE_AUTHENTICATED', 2);
define('D_O_ROLE_ADMINISTRATOR', 3);
define('D_O_ROLE_CVS_ADMIN', 4);
define('D_O_ROLE_DOC_MAINTAINER', 5);
define('D_O_ROLE_SITE_MAINTAINER', 6);
define('D_O_ROLE_USER_ADMIN', 7);
define('D_O_ROLE_SWITCH', 8);
//----------------------------------------
// Profile code
//----------------------------------------
function drupalorg_testing_profile_modules() {
return array(
// core, required
'block', 'filter', 'node', 'system', 'user',
// core, optional as per http://drupal.org/node/27367
'taxonomy', // NOTE: taxonomy needs to be first in the list or other modules bomb.
'aggregator', 'book', 'comment', 'contact', 'dblog', 'forum', 'help',
'path', 'profile', 'menu', 'search', 'statistics',
'tracker', 'upload',
// contrib modules
'install_profile_api',
'codefilter', 'cvs', 'devel', 'project', 'project_issue', 'project_release',
'comment_upload', 'comment_alter_taxonomy', 'views', 'views_ui', 'ctools',
// VC modules
'autoload', 'dbtng', 'versioncontrol', 'versioncontrol_git',
// Repo auth related modules
// 'beanstalkd', // beanstalkd is crashing site
'sshkey', 'project_git_auth', 'drupal_queue',
// Extra modules
'simpletest',
);
}
function drupalorg_testing_profile_details() {
return array(
'name' => 'Drupal.org Testing',
'description' => 'Install profile to setup a Drupal.org test site suitable for evaluating project module patches.',
);
}
/**
* Implementation of hook_form_alter().
*
* Allows the profile to alter the site-configuration form. This is
* called through custom invocation, so $form_state is not populated.
*/
function drupalorg_testing_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'install_configure') {
$form['site_information']['site_name']['#default_value'] = 'Drupal.org testing site';
$form['site_information']['site_mail']['#default_value'] = D_O_SITE_MAIL;
$form['admin_account']['account']['name']['#default_value'] = D_O_USER1;
$form['admin_account']['account']['mail']['#default_value'] = D_O_SITE_MAIL;
$form['server_settings']['update_status_module']['#default_value'] = array();
}
}
function drupalorg_testing_profile_task_list() {
return array('drupalorg-testing-batch' => t('Configure drupal.org settings'));
}
function drupalorg_testing_profile_tasks(&$task, $url) {
switch ($task) {
case 'profile':
// If the files directory isn't writable, then exit because several of the
// following steps depend on the server being able to create files and
// directories within the files directory.
if (_drupalorg_testing_configure_files()) {
// Start a batch, switch to 'drupalorg-testing-batch' task. We need to
// set the variable here, because batch_process() redirects.
variable_set('install_task', 'drupalorg-testing-batch');
_drupalorg_testing_set_batch($task, $url);
}
// Files directory creation failed, skip the rest of the setup.
else {
$task = 'profile-finished';
}
break;
case 'drupalorg-testing-batch':
// We are running a batch install of the profile.
// This might run in multiple HTTP requests, constantly redirecting
// to the same address, until the batch finished callback is invoked
// and the task advances to 'profile-finished'.
include_once 'includes/batch.inc';
$output = _batch_page();
return $output;
break;
}
}
/**
* Sets up the batch processing of the install profile tasks.
*/
function _drupalorg_testing_set_batch(&$task, $url) {
$batch = array(
'operations' => array(
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_node_types', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_site', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_theme', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_comment', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_attachments', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_roles', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_users', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_devel_module', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_cvs_module', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_project_terms', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_issue_tags', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_project_settings', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_content', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_content_project', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_content_project_release', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_issues', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_menus', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_blocks', array())),
array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_rebuild_menu', array())),
),
'title' => t('Setting up drupal.org testing site...'),
'finished' => '_drupalorg_testing_batch_finished',
);
batch_set($batch);
batch_process($url, $url);
}
/**
* Dispatch function for the batch processing. This allows us to do some
* consistent setup across page loads while breaking up the tasks.
*
* @param $function
* The function to dispatch to.
* @param $args
* Any args passed to the function from the batch.
* @param $context
* The batch context.
*/
function _drupalorg_testing_batch_dispatch($function, $args, &$context) {
// If not in 'safe mode', increase the maximum execution time:
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
install_include(drupalorg_testing_profile_modules());
$function($args, $context);
}
/**
* Batch 'finished' callback
*/
function _drupalorg_testing_batch_finished($success, $results, $operations) {
if ($success) {
// Here we do something meaningful with the results.
$message = count($results) .' actions processed.';
$message .= theme('item_list', $results);
$type = 'status';
}
else {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
$message = 'An error occurred while processing '. $error_operation[0] .' with arguments :'. print_r($error_operation[0], TRUE);
$type = 'error';
}
// Clear out any status messages that modules may have thrown, as we're
// setting our own for the profile. Leave error messages, however.
drupal_get_messages('status');
drupal_set_message($message, $type);
// Advance the installer task.
variable_set('install_task', 'profile-finished');
}
function _drupalorg_testing_create_node_types($args, &$context) {
$types = array(
array(
'type' => 'page',
'name' => st('Page'),
'module' => 'node',
'description' => st('If you want to add a static page, like a contact page or an about page, use a page.'),
'custom' => TRUE,
'modified' => TRUE,
'locked' => FALSE,
),
array(
'type' => 'story',
'name' => st('Story'),
'module' => 'node',
'description' => st('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extended by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.'),
'custom' => TRUE,
'modified' => TRUE,
'locked' => FALSE,
),
);
foreach ($types as $type) {
$type = (object) _node_type_set_defaults($type);
node_type_save($type);
// Store some result for post-processing in the finished callback.
$context['results'][] = t('Set up node type %type.', array('%type' => $type->name));
}
// Default page to not be promoted.
variable_set('node_options_page', array('status'));
$context['message'] = t('Set up basic node types');
}
function _drupalorg_testing_configure_site($args, &$context) {
variable_set('cache', CACHE_NORMAL);
$context['results'][] = t('Configured site settings.');
$context['message'] = t('Configured site settings');
}
function _drupalorg_testing_configure_theme($args, &$context) {
// Don't display date and author information for page nodes by default.
$theme_settings = variable_get('theme_settings', array());
$theme_settings['toggle_node_info_page'] = FALSE;
variable_set('theme_settings', $theme_settings);
$context['results'][] = t('Configured default theme.');
$context['message'] = t('Configured default theme');
}
function _drupalorg_testing_configure_comment($args, &$context) {
$types = array(
'book',
'forum',
'story',
'project_issue',
);
foreach ($types as $type) {
variable_set('comment_' . $type, COMMENT_NODE_READ_WRITE);
variable_set('comment_preview_' . $type, COMMENT_PREVIEW_OPTIONAL);
variable_set('comment_default_order_' . $type, COMMENT_ORDER_OLDEST_FIRST);
}
variable_set('comment_form_location_project_issue', COMMENT_FORM_BELOW);
$types = array(
'page',
'project_project',
'project_release',
);
foreach ($types as $type) {
variable_set('comment_' . $type, COMMENT_NODE_DISABLED);
}
$context['results'][] = t('Configured comment settings.');
$context['message'] = t('Configured comment settings');
}
function _drupalorg_testing_configure_attachments($args, &$context) {
// upload module
$types = array(
'book',
'forum',
'page',
'story',
'project_issue',
);
foreach ($types as $type) {
variable_set('upload_' . $type, 1);
}
$types = array(
'project_project',
'project_release',
);
foreach ($types as $type) {
variable_set('upload_' . $type, 0);
}
// Allow archives since it's a testing site.
variable_set('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp tar gz tgz');
// comment_upload module
$types = array(
'project_issue',
);
foreach ($types as $type) {
variable_set('comment_upload_' . $type, 1);
}
$types = array(
'book',
'forum',
'page',
'story',
'project_project',
'project_release',
);
foreach ($types as $type) {
variable_set('comment_upload_' . $type, 0);
}
$context['results'][] = t('Configured attachment settings.');
$context['message'] = t('Configured attachment settings');
}
function _drupalorg_testing_configure_devel_module($args, &$context) {
variable_set('dev_query', 1);
variable_set('devel_query_display', 1);
variable_set('dev_timer', 1);
// variable_set('devel_redirect_page', 1);
// Save any old SMTP library
if (variable_get('smtp_library', '') != '' && variable_get('smtp_library', '') != drupal_get_filename('module', 'devel')) {
variable_set('devel_old_smtp_library', variable_get('smtp_library', ''));
}
variable_set('smtp_library', drupal_get_filename('module', 'devel'));
variable_set('devel_switch_user_list_size', 12);
$context['results'][] = t('Configured devel module settings.');
$context['message'] = t('Configured devel module');
}
function _drupalorg_testing_configure_cvs_module($args, &$context) {
$repos = array(
'drupal' => array(
'name' => t('Drupal'),
'modules' => 'drupal',
),
'contributions' => array(
'name' => t('Contributions'),
'modules' => 'contributions',
),
);
$repo_info = array(
'root' => file_directory_temp() . "/testrepos",
'diffurl' => '',
'newurl' => '',
'trackerurl' => '',
'method' => '1',
);
foreach ($repos as $repo => $info) {
$form_state = array();
$form_state['values'] = array_merge($repo_info, $info);;
// Dunno why CVS module is checking this button for submit,
// but it has to be included here for the form to process
// properly.
$form_state['clicked_button']['#id'] = 'edit-submit';
cvs_repository_form_submit(array(), $form_state);
$context['results'][] = t('Configured CVS repository %repo.', array('%repo' => $info['name']));
}
// Set the branch/tag release messages to match drupal.org.
variable_set('cvs_message_new_release_branch', t('Your development snapshot release has been added. However, a downloadable package will not be available and this release will not be published until the packaging scripts run again. These scripts only make new development snapshot releases every 12 hours, so please be patient.'));
variable_set('cvs_message_new_release_tag', t('Your official release has been added. A downloadable package will not be available and this release will not be published until the packaging scripts run again. These scripts run every 5 minutes for official releases, so it should be available soon. Once it has been published, this release will be available in the list of choices for the "Default version" selector on your project\'s edit tab.'));
// Create a CVS account for the admin user.
db_query("INSERT INTO {cvs_accounts} (uid, cvs_user, pass, motivation, status) VALUES (%d, '%s', '%s', '%s', %d)", 1, D_O_USER1, crypt(D_O_PASSWORD), '', CVS_APPROVED);
$context['results'][] = t('Configured CVS settings.');
$context['message'] = t('Configured CVS module');
}
/**
* Setup roles and permissions to mimic drupal.org.
* This creates an additional role, "user switcher", that has the
* "swtich user" permission from the devel.module.
*/
function _drupalorg_testing_create_roles($args, &$context) {
// Map role names to role ID constants.
$roles = array(
D_O_ROLE_ANONYMOUS => 'anonymous',
D_O_ROLE_AUTHENTICATED => 'authenticated',
D_O_ROLE_ADMINISTRATOR => 'administrator',
D_O_ROLE_CVS_ADMIN => 'CVS administrator',
D_O_ROLE_DOC_MAINTAINER => 'documentation maintainer',
D_O_ROLE_SITE_MAINTAINER => 'site maintainer',
D_O_ROLE_USER_ADMIN => 'user administrator',
D_O_ROLE_SWITCH => 'user switcher',
);
// Define permissions for each role ID.
$permissions = array(
D_O_ROLE_ANONYMOUS => array(
// aggregator
'access news feeds',
// comment
'access comments',
// comment_upload module
'view files uploaded to comments',
// contact
'access site-wide contact form',
// cvs
'access CVS messages',
// node
'access content',
// project
'access projects',
// project_issue
'access project issues',
// project_usage module
'view project usage',
// search
'search content',
'use advanced search',
// upload
'view uploaded files',
// user
'access user profiles',
),
D_O_ROLE_AUTHENTICATED => array(
// aggregator
'access news feeds',
// book
'access printer-friendly version',
'add content to books',
// comment
'access comments',
'post comments',
'post comments without approval',
// comment_alter_taxonomy module
'alter taxonomy on project_issue content',
// comment_upload module
'upload files to comments',
'view files uploaded to comments',
// contact
'access site-wide contact form',
// cvs
'access CVS messages',
// forum
'create forum topics',
'edit own forum topics',
// node
'access content',
'create book content',
'edit any book content',
'view revisions',
// project
'access projects',
'browse project listings',
'maintain projects',
// project_issue module
'access project issues',
'create project issues',
'set issue status active',
'set issue status by design',
'set issue status closed',
'set issue status duplicate',
'set issue status fixed',
'set issue status needs review',
'set issue status needs work',
'set issue status patch (to be ported)',
'set issue status postponed',
'set issue status postponed (maintainer needs more info)',
'set issue status reviewed & tested by the community',
'set issue status wont fix',
// project_usage module
'view project usage',
// search
'search content',
'use advanced search',
// upload
'view uploaded files',
'upload files',
// user
'access user profiles',
'change own username',
),
D_O_ROLE_ADMINISTRATOR => array(
// aggregator module
'access news feeds',
'administer news feeds',
// block module
'administer blocks',
// book module
'access printer-friendly version',
'add content to books',
'administer book outlines',
'create new books',
// comment module
'access comments',
'administer comments',
'post comments',
'post comments without approval',
// contact module
'access site-wide contact form',
'administer site-wide contact form',
// cvs module
'access CVS messages',
'administer CVS',
// filter module
'administer filters',
// forum module
'administer forums',
'create forum topics',
'delete any forum topic',
'delete own forum topics',
'edit any forum topic',
'edit own forum topics',
// menu module
'administer menu',
// node module
'access content',
'administer content types',
'administer nodes',
'create book content',
'create page content',
'create story content',
'delete any book content',
'delete any page content',
'delete any story content',
'delete own book content',
'delete own page content',
'delete own story content',
'edit any book content',
'edit any page content',
'edit any story content',
'edit own book content',
'edit own page content',
'edit own story content',
'revert revisions',
'view revisions',
// path module
'administer url aliases',
'create url aliases',
// project module
'administer projects',
'browse project listings',
'delete any projects',
// search module
'administer search',
// system module
'access administration pages',
'access site reports',
'administer actions',
'administer files',
'administer site configuration',
// taxonomy module
'administer taxonomy',
// upload module',
'upload files',
'view uploaded files',
// user module
'access user profiles',
'administer permissions',
'administer users',
'change own username',
// views module
'administer views',
),
D_O_ROLE_CVS_ADMIN => array(
// cvs
'administer CVS',
// project
'administer projects',
// system
'access administration pages',
),
D_O_ROLE_DOC_MAINTAINER => array(
// book
'add content to books',
// node
'create book content',
'edit any book content',
'revert revisions',
),
D_O_ROLE_SITE_MAINTAINER => array(
// aggregator
'administer news feeds',
// book module
'administer book outlines',
'create new books',
// comment
'administer comments',
// node
'administer nodes',
'revert revisions',
// system
'access administration pages',
// taxonomy module
'administer taxonomy',
// upload
'upload files',
),
D_O_ROLE_USER_ADMIN => array(
// system
'access administration pages',
// user
'administer users',
),
D_O_ROLE_SWITCH => array(
// devel
'switch users',
'access devel information',
),
);
// Delete current roles and permissions and re-populate them.
db_query('TRUNCATE {role}');
db_query('TRUNCATE {permission}');
foreach ($roles as $rid => $name) {
db_query("INSERT INTO {role} (rid, name) VALUES (%d, '%s')", $rid, $name);
}
$context['results'][] = t('Created roles.');
foreach ($permissions as $rid => $perms) {
db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', 0)", $rid, implode(', ', $perms));
}
$context['results'][] = t('Set role permissions.');
$context['message'] = t('Created roles and set permissions');
}
function _drupalorg_testing_create_users($args, &$context) {
// Define some well-known users in each of the roles. All of these will
// have the same password (see D_O_PASSWORD at the top of this file), and
// will also belong to the 'User switchers' role to be able to easily switch
// between them.
$users = array(
'admin' => array(D_O_ROLE_ADMINISTRATOR),
'site' => array(D_O_ROLE_SITE_MAINTAINER),
'doc' => array(D_O_ROLE_DOC_MAINTAINER),
'cvs' => array(D_O_ROLE_CVS_ADMIN),
'auth' => array(), // no extra roles
);
// Create a dummy user object for user_save().
$account = new stdClass();
$account->uid = 0;
// Now, generate our well-known users.
foreach ($users as $name => $roles) {
$edit = array();
// All the well-known users have the same password.
$edit['pass'] = D_O_PASSWORD;
$edit['status'] = 1;
// Put all of these custom users into the 'User switchers' role, too.
// We have to flip the roles array here, because that's what user_save() is expecting.
$edit['roles'] = array_flip(array_merge(array(D_O_ROLE_SWITCH), $roles));
for ($i = 1; $i <= D_O_NUM_USERS_PER_ROLE; $i++) {
$edit['name'] = $name . $i;
$edit['mail'] = $edit['name'] .'@'. D_O_DOMAIN;
user_save($account, $edit);
$context['results'][] = t('Created user %name.', array('%name' => $edit['name']));
}
for ($i = 1; $i <= D_O_NUM_CVS_USERS_PER_ROLE; $i++) {
$user_name = $name . $i;
$user = user_load(array('name' => $user_name));
db_query("INSERT INTO {cvs_accounts} (uid, cvs_user, pass, motivation, status) VALUES (%d, '%s', '%s', '%s', %d)", $user->uid, $user_name, crypt(D_O_PASSWORD), '', CVS_APPROVED);
}
}
// Create a simple 'System Message' user for issue auto-followups.
$edit = array();
$edit['pass'] = D_O_PASSWORD;
$edit['status'] = 1;
$edit['name'] = t('System Message');
$edit['mail'] = 'system-message@'. D_O_DOMAIN;
user_save($account, $edit);
$context['results'][] = t('Created user %name.', array('%name' => $edit['name']));
// Create 50 random users.
module_load_include('inc', 'devel', 'devel_generate');
devel_create_users(50, FALSE);
$context['results'][] = t('Created 50 random users.');
$context['message'] = t('Created users');
}
/**
* Auto-generates project-related terms from drupal.org.
*/
function _drupalorg_testing_create_project_terms($args, &$context) {
// Add top-level project terms.
$project_vid = _project_get_vid();
$terms = array(
t('Drupal project') => t('Get started by downloading the official Drupal core files. These official releases come bundled with a variety of modules and themes to give you a good starting point to help build your site. Drupal core includes basic community features like blogging, forums, and contact forms, and can be easily extended by downloading other contributed modules and themes.'),
t('Installation profiles') => t('Installation profiles are a feature in Drupal core that was added in the 5.x series. The new Drupal installer allows you to specify an installation profile which defines which modules should be enabled, and can customize the new installation after they have been installed. This will allow customized "distributions" that enable and configure a set of modules that work together for a specific kind of site (Drupal for bloggers, Drupal for musicians, Drupal for developers, and so on).'),
t('Modules') => t('Modules are plugins for Drupal that extend its core functionality. Only use matching versions of modules with Drupal. Modules released for Drupal 4.7.x will not work for Drupal 5.x. These contributed modules are not part of any official release and may not be optimized or work correctly.'),
t('Theme engines') => t('Theme engines control how certain themes interact with Drupal. Most users will want to stick with the default included with Drupal core. These contributed theme engines are not part of any official release and may not work correctly. Only use matching versions of theme engines with Drupal. Theme engines released for Drupal 4.7.x will not work for Drupal 5.x.'),
t('Themes') => t('Themes allow you to change the look and feel of your Drupal site. These contributed themes are not part of any official release and may not work correctly. Only use matching versions of themes with Drupal. Themes released for Drupal 4.7.x will not work for Drupal 5.x.'),
t('Translations') => t('Drupal uses English by default, but may be translated to many other languages. To install these translations, unzip them and import the .po file through Drupal\'s administration interface for localization. You will need to turn on the locale module if it\'s not already enabled. You can check the completeness of translations on the translations <a href="/translation-status">status page</a>.'),
);
foreach ($terms as $name => $description) {
install_taxonomy_add_term($project_vid, $name, $description);
$context['results'][] = t('Created project category %term.', array('%term' => $name));
}
// Add module categories.
$modules_tid = install_taxonomy_get_tid(t('Modules'));
$terms = array(
t('Administration'),
t('CCK'),
t('Commerce / advertising'),
t('Community'),
t('Content'),
t('Content display'),
t('Developer'),
t('e-Commerce'),
t('Evaluation/rating'),
t('Event'),
t('File management'),
t('Filters/editors'),
t('Games and Amusements'),
t('Import/export'),
t('Javascript Utilities'),
t('Location'),
t('Mail'),
t('Media'),
t('Multilingual'),
t('Organic Groups'),
t('Paging'),
t('Performance and Scalability'),
t('RDF'),
t('Search'),
t('Security'),
t('Site navigation'),
t('Statistics'),
t('Syndication'),
t('Taxonomy'),
t('Theme related'),
t('Third-party party integration'),
t('User access/authentication'),
t('User management'),
t('Utility'),
t('Views'),
);
foreach ($terms as $name) {
install_taxonomy_add_term($project_vid, $name, '', array('parent' => array($modules_tid)));
$context['results'][] = t('Created project Modules category %term.', array('%term' => $name));
}
// Add release versions.
$release_vid = _project_release_get_api_vid();
$terms = array(
'4.0.x', '4.1.x', '4.2.x', '4.3.x',
'4.4.x', '4.5.x', '4.6.x', '4.7.x', '5.x', '6.x', '7.x',
);
$weight = 10;
// For releases to be properly ordered in the download tables, the oldest taxonomy
// terms must have the heaviest weights.
foreach ($terms as $name) {
install_taxonomy_add_term($release_vid, $name, '', array('weight' => $weight));
$weight--;
$context['results'][] = t('Created release version %term.', array('%term' => $name));
}
// Add release types.
$release_type_vid = install_taxonomy_add_vocabulary(t('Release type'), array('project_release' => 'project_release'), array('multiple' => TRUE));
$terms = array(
t('Security update'),
t('Bug fixes'),
t('New features'),
);
foreach ($terms as $name) {
install_taxonomy_add_term($release_type_vid, $name);
$context['results'][] = t('Created release type %term.', array('%term' => $name));
}
$context['message'] = t('Created project taxonomy');
}
/**
* Configure the "Issue tags" vocabulary and comment_alter_taxonomy.
*/
function _drupalorg_testing_configure_issue_tags($args, &$context) {
$vocab_properties = array(
'multiple' => TRUE,
'tags' => TRUE,
'help' => t('Do <strong>NOT</strong> use tags for duplicating the "Assigned" or "Component" fields. Separate terms with a comma, not a space.'),
);
$issue_tags_vid = install_taxonomy_add_vocabulary(t('Issue tags'), array('project_issue' => 'project_issue'), $vocab_properties);
$terms = array(
t('Accessibility'),
t('Bikeshed'),
t('DX'),
t('Needs documentation'),
t('Needs benchmarking'),
t('Needs code style'),
t('Needs tests'),
t('Novice'),
t('Performance'),
t('Usability'),
);
foreach ($terms as $name) {
install_taxonomy_add_term($issue_tags_vid, $name);
$context['results'][] = t('Created Issue tag %term.', array('%term' => $name));
}
// Configure Comment alter taxonomy
variable_set('comment_alter_taxonomy_legacy_issue_paths', TRUE);
variable_set('comment_alter_taxonomy_vocabularies', array($issue_tags_vid => $issue_tags_vid));
$context['message'] = t('Created "Issue tags" vocabulary and configured Comment alter taxonomy');
}
function _drupalorg_testing_create_content($args, &$context) {
// Create a bunch of test content with the devel generate script.
module_load_include('inc', 'devel', 'devel_generate');
// Create 100 pseudo-random nodes.
$form_state['values'] = array(
'add_statistics' => 1,
'max_comments' => '10',
'node_types' => array('page' => 'page', 'story' => 'story', 'forum' => 'forum', 'book' => 'book'),
'num_nodes' => '100',
'time_range' => '604800',
'title_length' => '8',
);
devel_generate_content($form_state);
$context['results'][] = t('Created 100 random nodes.');
$context['message'] = t('Created dummy content');
}
/**
* Configures variables for project* modules.
*/
function _drupalorg_testing_configure_project_settings($args, &$context) {
// TODO: there's currently so default sort method for
// projects in 6.x, so fix this when it appears.
$types = array(
t('Drupal Project') => array('name'),
t('Installation profiles') => array('name', 'date'),
t('Modules') => array('name', 'date', 'category'),
t('Theme engines') => array('name'),
t('Themes') => array('name', 'date'),
t('Translations') => array('name'),
);
foreach ($types as $type => $settings) {
$tid = install_taxonomy_get_tid($type);
// TODO: there's currently do method for per-term sorting
// in 6.x, so fix this when it appears...
}
// Settings for project_release.module.
variable_set('project_release_default_version_format', '!api#major%patch#extra');
variable_set('project_release_overview', '-1');
variable_set('project_release_browse_versions', '1');
$active_tids = array();
$active_terms = array('7.x', '6.x', '5.x');
foreach ($active_terms as $term) {
$tid = install_taxonomy_get_tid($term);
$active_tids[$tid] = $tid;
}
variable_set('project_release_active_compatibility_tids', $active_tids);
$context['results'][] = t('Configured project release settings.');
// Settings for project_issue.module.
variable_set('project_directory_issues', 'issues');
variable_set('project_issue_autocomplete', '1');
$account = user_load(array('name' => t('System Message')));
variable_set('project_issue_followup_user', $account->uid);
// Add custom statuses
// TODO: this is lame -- we should have an API to add a new status.
module_load_include('inc', 'project_issue', 'includes/admin.issue_status');
$form_state = array();
$form_state['values']['status'] = array();
$form_state['values']['status_add'] = array(
'name' => t('patch (to be ported)'),
'weight' => -4,
'author_has' => 0,
'default_query' => 1,
);
project_issue_admin_states_form_submit(array(), $form_state);
$form_state = array();
$form_state['values']['status'] = array();
$form_state['values']['status_add'] = array(
'name' => t('postponed (maintainer needs more info)'),
'weight' => -10,
'author_has' => 0,
'default_query' => 1,
);
project_issue_admin_states_form_submit(array(), $form_state);
// Now set up the issue states from scratch for existing statuses.
$status = array();
$status[1] = array(
'name' => t('active'),
'weight' => -13,
'author_has' => 0,
'default_query' => 1,
);
$status[8] = array(
'name' => t('needs review'),
'weight' => -8,
'author_has' => 0,
'default_query' => 1,
);
$status[13] = array(
'name' => t('needs work'),
'weight' => -7,
'author_has' => 0,
'default_query' => 1,
);
$status[14] = array(
'name' => t('reviewed & tested by the community'),
'weight' => -6,
'author_has' => 0,
'default_query' => 1,
);
$status[2] = array(
'name' => t('fixed'),
'weight' => 1,
'author_has' => 0,
'default_query' => 1,
);
$status[3] = array(
'name' => t('duplicate'),
'weight' => 4,
'author_has' => 0,
'default_query' => 0,
);
$status[4] = array(
'name' => t('postponed'),
'weight' => 6,
'author_has' => 0,
'default_query' => 1,
);
$status[5] = array(
'name' => t("won't fix"),
'weight' => 9,
'author_has' => 0,
'default_query' => 0,
);
$status[6] = array(
'name' => t('by design'),
'weight' => 11,
'author_has' => 0,
'default_query' => 0,
);
$status[7] = array(
'name' => t('closed'),
'weight' => 13,
'author_has' => 1,
'default_query' => 0,
);
$form_state = array();
$form_state['values']['status'] = $status;