/[drupal]/contributions/profiles/drupalorg_testing/drupalorg_testing.profile
ViewVC logotype

Contents of /contributions/profiles/drupalorg_testing/drupalorg_testing.profile

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


Revision 1.65 - (show annotations) (download) (as text)
Tue Mar 24 07:40:10 2009 UTC (8 months ago) by dww
Branch: MAIN
Changes since 1.64: +2 -2 lines
File MIME type: text/x-php
Enable views_ui by default.
1 <?php
2
3 // $Id: drupalorg_testing.profile,v 1.64 2009/03/24 07:28:09 dww Exp $
4
5 /**
6 * @file
7 * Installation profile that configures a site to mimic drupal.org,
8 * especially the project management and issue tracking functionality,
9 * to facilitate testing. More information can be found in the
10 * README.txt file.
11 *
12 * Some of the constants at the top of this file can be changed to
13 * customize the profile for your site (names, passwords, domains, etc).
14 */
15
16 //----------------------------------------
17 // Settings you probably want to customize
18 //----------------------------------------
19
20 /// The initial password for all of the well-known users created.
21 define('D_O_PASSWORD', 'a');
22
23 /// Name to be used for the user 1 (full admin) account.
24 define('D_O_USER1', 'a');
25
26 /// Domain to use for all user e-mail addresses.
27 define('D_O_DOMAIN', 'example.com');
28
29
30 //----------------------------------------
31 // Settings you might want to customize
32 //----------------------------------------
33
34 /// E-mail address to use for the site itself.
35 define('D_O_SITE_MAIL', D_O_USER1 .'@'. D_O_DOMAIN);
36
37 /// Number of users per role the profile will create.
38 define('D_O_NUM_USERS_PER_ROLE', 2);
39
40 /**
41 * Number of users per role the profile will create CVS accounts for.
42 *
43 * By default, each role gets 2 users (e.g. "auth1" and "auth2"), but
44 * only one of them gets a CVS account (e.g. "auth1"). This is useful
45 * for testing to see how things on the site behave for people in
46 * various roles with and without CVS accounts.
47 */
48 define('D_O_NUM_CVS_USERS_PER_ROLE', 1);
49
50
51 //----------------------------------------
52 // Settings you should not change
53 //----------------------------------------
54
55 define('D_O_ROLE_ANONYMOUS', 1);
56 define('D_O_ROLE_AUTHENTICATED', 2);
57 define('D_O_ROLE_ADMINISTRATOR', 3);
58 define('D_O_ROLE_CVS_ADMIN', 4);
59 define('D_O_ROLE_DOC_MAINTAINER', 5);
60 define('D_O_ROLE_SITE_MAINTAINER', 6);
61 define('D_O_ROLE_USER_ADMIN', 7);
62 define('D_O_ROLE_SWITCH', 8);
63
64
65 //----------------------------------------
66 // Profile code
67 //----------------------------------------
68
69 function drupalorg_testing_profile_modules() {
70 return array(
71 // core, required
72 'block', 'filter', 'node', 'system', 'user',
73 // core, optional as per http://drupal.org/node/27367
74 'taxonomy', // NOTE: taxonomy needs to be first in the list or other modules bomb.
75 'aggregator', 'book', 'comment', 'contact', 'dblog', 'forum', 'help',
76 'path', 'profile', 'menu', 'search', 'statistics',
77 'tracker', 'upload',
78 // contrib modules
79 'install_profile_api',
80 'codefilter', 'cvs', 'devel', 'project', 'project_issue', 'project_release',
81 'comment_upload', 'comment_alter_taxonomy', 'views', 'views_ui',
82 );
83 }
84
85 function drupalorg_testing_profile_details() {
86 return array(
87 'name' => 'Drupal.org Testing',
88 'description' => 'Install profile to setup a Drupal.org test site suitable for evaluating project module patches.',
89 );
90 }
91
92 /**
93 * Implementation of hook_form_alter().
94 *
95 * Allows the profile to alter the site-configuration form. This is
96 * called through custom invocation, so $form_state is not populated.
97 */
98 function drupalorg_testing_form_alter(&$form, $form_state, $form_id) {
99 if ($form_id == 'install_configure') {
100 $form['site_information']['site_name']['#default_value'] = 'Drupal.org testing site';
101 $form['site_information']['site_mail']['#default_value'] = D_O_SITE_MAIL;
102 $form['admin_account']['account']['name']['#default_value'] = D_O_USER1;
103 $form['admin_account']['account']['mail']['#default_value'] = D_O_SITE_MAIL;
104 $form['server_settings']['update_status_module']['#default_value'] = array();
105 }
106 }
107
108 function drupalorg_testing_profile_task_list() {
109 return array('drupalorg-testing-batch' => t('Configure drupal.org settings'));
110 }
111
112 function drupalorg_testing_profile_tasks(&$task, $url) {
113
114 switch ($task) {
115 case 'profile':
116 // If the files directory isn't writable, then exit because several of the
117 // following steps depend on the server being able to create files and
118 // directories within the files directory.
119 if (_drupalorg_testing_configure_files()) {
120 // Start a batch, switch to 'drupalorg-testing-batch' task. We need to
121 // set the variable here, because batch_process() redirects.
122 variable_set('install_task', 'drupalorg-testing-batch');
123 _drupalorg_testing_set_batch($task, $url);
124 }
125 // Files directory creation failed, skip the rest of the setup.
126 else {
127 $task = 'profile-finished';
128 }
129 break;
130 case 'drupalorg-testing-batch':
131 // We are running a batch install of the profile.
132 // This might run in multiple HTTP requests, constantly redirecting
133 // to the same address, until the batch finished callback is invoked
134 // and the task advances to 'profile-finished'.
135 include_once 'includes/batch.inc';
136 $output = _batch_page();
137 return $output;
138 break;
139 }
140 }
141
142 /**
143 * Sets up the batch processing of the install profile tasks.
144 */
145 function _drupalorg_testing_set_batch(&$task, $url) {
146 $batch = array(
147 'operations' => array(
148 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_node_types', array())),
149 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_site', array())),
150 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_theme', array())),
151 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_comment', array())),
152 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_attachments', array())),
153 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_roles', array())),
154 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_users', array())),
155 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_devel_module', array())),
156 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_cvs_module', array())),
157 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_project_terms', array())),
158 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_issue_tags', array())),
159 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_project_settings', array())),
160 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_content', array())),
161 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_content_project', array())),
162 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_content_project_release', array())),
163 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_issues', array())),
164 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_create_menus', array())),
165 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_configure_blocks', array())),
166 array('_drupalorg_testing_batch_dispatch', array('_drupalorg_testing_rebuild_menu', array())),
167 ),
168 'title' => t('Setting up drupal.org testing site...'),
169 'finished' => '_drupalorg_testing_batch_finished',
170 );
171 batch_set($batch);
172 batch_process($url, $url);
173 }
174
175 /**
176 * Dispatch function for the batch processing. This allows us to do some
177 * consistent setup across page loads while breaking up the tasks.
178 *
179 * @param $function
180 * The function to dispatch to.
181 * @param $args
182 * Any args passed to the function from the batch.
183 * @param $context
184 * The batch context.
185 */
186 function _drupalorg_testing_batch_dispatch($function, $args, &$context) {
187 // If not in 'safe mode', increase the maximum execution time:
188 if (!ini_get('safe_mode')) {
189 set_time_limit(0);
190 }
191 install_include(drupalorg_testing_profile_modules());
192 $function($args, $context);
193 }
194
195 /**
196 * Batch 'finished' callback
197 */
198 function _drupalorg_testing_batch_finished($success, $results, $operations) {
199 if ($success) {
200 // Here we do something meaningful with the results.
201 $message = count($results) .' actions processed.';
202 $message .= theme('item_list', $results);
203 $type = 'status';
204 }
205 else {
206 // An error occurred.
207 // $operations contains the operations that remained unprocessed.
208 $error_operation = reset($operations);
209 $message = 'An error occurred while processing '. $error_operation[0] .' with arguments :'. print_r($error_operation[0], TRUE);
210 $type = 'error';
211 }
212
213 // Clear out any status messages that modules may have thrown, as we're
214 // setting our own for the profile. Leave error messages, however.
215 drupal_get_messages('status');
216 drupal_set_message($message, $type);
217
218 // Advance the installer task.
219 variable_set('install_task', 'profile-finished');
220 }
221
222 function _drupalorg_testing_create_node_types($args, &$context) {
223 $types = array(
224 array(
225 'type' => 'page',
226 'name' => st('Page'),
227 'module' => 'node',
228 'description' => st('If you want to add a static page, like a contact page or an about page, use a page.'),
229 'custom' => TRUE,
230 'modified' => TRUE,
231 'locked' => FALSE,
232 ),
233 array(
234 'type' => 'story',
235 'name' => st('Story'),
236 'module' => 'node',
237 '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.'),
238 'custom' => TRUE,
239 'modified' => TRUE,
240 'locked' => FALSE,
241 ),
242 );
243 foreach ($types as $type) {
244 $type = (object) _node_type_set_defaults($type);
245 node_type_save($type);
246 // Store some result for post-processing in the finished callback.
247 $context['results'][] = t('Set up node type %type.', array('%type' => $type->name));
248 }
249
250 // Default page to not be promoted.
251 variable_set('node_options_page', array('status'));
252 $context['message'] = t('Set up basic node types');
253 }
254
255 function _drupalorg_testing_configure_site($args, &$context) {
256 variable_set('cache', CACHE_NORMAL);
257 $context['results'][] = t('Configured site settings.');
258 $context['message'] = t('Configured site settings');
259 }
260
261 function _drupalorg_testing_configure_theme($args, &$context) {
262 // Don't display date and author information for page nodes by default.
263 $theme_settings = variable_get('theme_settings', array());
264 $theme_settings['toggle_node_info_page'] = FALSE;
265 variable_set('theme_settings', $theme_settings);
266 $context['results'][] = t('Configured default theme.');
267 $context['message'] = t('Configured default theme');
268 }
269
270 function _drupalorg_testing_configure_comment($args, &$context) {
271
272 $types = array(
273 'book',
274 'forum',
275 'story',
276 'project_issue',
277 );
278
279 foreach ($types as $type) {
280 variable_set('comment_' . $type, COMMENT_NODE_READ_WRITE);
281 variable_set('comment_preview_' . $type, COMMENT_PREVIEW_OPTIONAL);
282 variable_set('comment_default_order_' . $type, COMMENT_ORDER_OLDEST_FIRST);
283 }
284 variable_set('comment_form_location_project_issue', COMMENT_FORM_BELOW);
285
286 $types = array(
287 'page',
288 'project_project',
289 'project_release',
290 );
291 foreach ($types as $type) {
292 variable_set('comment_' . $type, COMMENT_NODE_DISABLED);
293 }
294
295 $context['results'][] = t('Configured comment settings.');
296 $context['message'] = t('Configured comment settings');
297 }
298
299 function _drupalorg_testing_configure_attachments($args, &$context) {
300
301 // upload module
302 $types = array(
303 'book',
304 'forum',
305 'page',
306 'story',
307 'project_issue',
308 );
309 foreach ($types as $type) {
310 variable_set('upload_' . $type, 1);
311 }
312
313 $types = array(
314 'project_project',
315 'project_release',
316 );
317 foreach ($types as $type) {
318 variable_set('upload_' . $type, 0);
319 }
320
321 // Allow archives since it's a testing site.
322 variable_set('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp tar gz tgz');
323
324 // comment_upload module
325 $types = array(
326 'project_issue',
327 );
328 foreach ($types as $type) {
329 variable_set('comment_upload_' . $type, 1);
330 }
331
332 $types = array(
333 'book',
334 'forum',
335 'page',
336 'story',
337 'project_project',
338 'project_release',
339 );
340 foreach ($types as $type) {
341 variable_set('comment_upload_' . $type, 0);
342 }
343
344 $context['results'][] = t('Configured attachment settings.');
345 $context['message'] = t('Configured attachment settings');
346 }
347
348 function _drupalorg_testing_configure_devel_module($args, &$context) {
349 variable_set('dev_query', 1);
350 variable_set('devel_query_display', 1);
351 variable_set('dev_timer', 1);
352 // variable_set('devel_redirect_page', 1);
353
354 // Save any old SMTP library
355 if (variable_get('smtp_library', '') != '' && variable_get('smtp_library', '') != drupal_get_filename('module', 'devel')) {
356 variable_set('devel_old_smtp_library', variable_get('smtp_library', ''));
357 }
358 variable_set('smtp_library', drupal_get_filename('module', 'devel'));
359 variable_set('devel_switch_user_list_size', 12);
360
361 $context['results'][] = t('Configured devel module settings.');
362 $context['message'] = t('Configured devel module');
363 }
364
365 function _drupalorg_testing_configure_cvs_module($args, &$context) {
366 $repos = array(
367 'drupal' => array(
368 'name' => t('Drupal'),
369 'modules' => 'drupal',
370 ),
371 'contributions' => array(
372 'name' => t('Contributions'),
373 'modules' => 'contributions',
374 ),
375 );
376 $repo_info = array(
377 'root' => file_directory_temp() . "/testrepos",
378 'diffurl' => '',
379 'newurl' => '',
380 'trackerurl' => '',
381 'method' => '1',
382 );
383
384
385 foreach ($repos as $repo => $info) {
386 $form_state = array();
387 $form_state['values'] = array_merge($repo_info, $info);;
388 // Dunno why CVS module is checking this button for submit,
389 // but it has to be included here for the form to process
390 // properly.
391 $form_state['clicked_button']['#id'] = 'edit-submit';
392 cvs_repository_form_submit(array(), $form_state);
393 $context['results'][] = t('Configured CVS repository %repo.', array('%repo' => $info['name']));
394 }
395
396 // Set the branch/tag release messages to match drupal.org.
397 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.'));
398 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.'));
399
400 // Create a CVS account for the admin user.
401 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);
402
403 $context['results'][] = t('Configured CVS settings.');
404 $context['message'] = t('Configured CVS module');
405 }
406
407 /**
408 * Setup roles and permissions to mimic drupal.org.
409 * This creates an additional role, "user switcher", that has the
410 * "swtich user" permission from the devel.module.
411 */
412 function _drupalorg_testing_create_roles($args, &$context) {
413 // Map role names to role ID constants.
414 $roles = array(
415 D_O_ROLE_ANONYMOUS => 'anonymous',
416 D_O_ROLE_AUTHENTICATED => 'authenticated',
417 D_O_ROLE_ADMINISTRATOR => 'administrator',
418 D_O_ROLE_CVS_ADMIN => 'CVS administrator',
419 D_O_ROLE_DOC_MAINTAINER => 'documentation maintainer',
420 D_O_ROLE_SITE_MAINTAINER => 'site maintainer',
421 D_O_ROLE_USER_ADMIN => 'user administrator',
422 D_O_ROLE_SWITCH => 'user switcher',
423 );
424
425 // Define permissions for each role ID.
426 $permissions = array(
427 D_O_ROLE_ANONYMOUS => array(
428 // aggregator
429 'access news feeds',
430 // comment
431 'access comments',
432 // comment_upload module
433 'view files uploaded to comments',
434 // contact
435 'access site-wide contact form',
436 // cvs
437 'access CVS messages',
438 // node
439 'access content',
440 // project
441 'access projects',
442 // project_issue
443 'access project issues',
444 // project_usage module
445 'view project usage',
446 // search
447 'search content',
448 'use advanced search',
449 // upload
450 'view uploaded files',
451 // user
452 'access user profiles',
453 ),
454 D_O_ROLE_AUTHENTICATED => array(
455 // aggregator
456 'access news feeds',
457 // book
458 'access printer-friendly version',
459 'add content to books',
460 // comment
461 'access comments',
462 'post comments',
463 'post comments without approval',
464 // comment_alter_taxonomy module
465 'alter taxonomy on project_issue content',
466 // comment_upload module
467 'upload files to comments',
468 'view files uploaded to comments',
469 // contact
470 'access site-wide contact form',
471 // cvs
472 'access CVS messages',
473 // forum
474 'create forum topics',
475 'edit own forum topics',
476 // node
477 'access content',
478 'create book content',
479 'edit any book content',
480 'view revisions',
481 // project
482 'access projects',
483 'browse project listings',
484 'maintain projects',
485 // project_issue module
486 'access project issues',
487 'create project issues',
488 'set issue status active',
489 'set issue status by design',
490 'set issue status closed',
491 'set issue status duplicate',
492 'set issue status fixed',
493 'set issue status needs review',
494 'set issue status needs work',
495 'set issue status patch (to be ported)',
496 'set issue status postponed',
497 'set issue status postponed (maintainer needs more info)',
498 'set issue status reviewed & tested by the community',
499 'set issue status wont fix',
500 // project_usage module
501 'view project usage',
502 // search
503 'search content',
504 'use advanced search',
505 // upload
506 'view uploaded files',
507 'upload files',
508 // user
509 'access user profiles',
510 'change own username',
511 ),
512 D_O_ROLE_ADMINISTRATOR => array(
513 // aggregator module
514 'access news feeds',
515 'administer news feeds',
516 // block module
517 'administer blocks',
518 // book module
519 'access printer-friendly version',
520 'add content to books',
521 'administer book outlines',
522 'create new books',
523 // comment module
524 'access comments',
525 'administer comments',
526 'post comments',
527 'post comments without approval',
528 // contact module
529 'access site-wide contact form',
530 'administer site-wide contact form',
531 // cvs module
532 'access CVS messages',
533 'administer CVS',
534 // filter module
535 'administer filters',
536 // forum module
537 'administer forums',
538 'create forum topics',
539 'delete any forum topic',
540 'delete own forum topics',
541 'edit any forum topic',
542 'edit own forum topics',
543 // menu module
544 'administer menu',
545 // node module
546 'access content',
547 'administer content types',
548 'administer nodes',
549 'create book content',
550 'create page content',
551 'create story content',
552 'delete any book content',
553 'delete any page content',
554 'delete any story content',
555 'delete own book content',
556 'delete own page content',
557 'delete own story content',
558 'edit any book content',
559 'edit any page content',
560 'edit any story content',
561 'edit own book content',
562 'edit own page content',
563 'edit own story content',
564 'revert revisions',
565 'view revisions',
566 // path module
567 'administer url aliases',
568 'create url aliases',
569 // project module
570 'administer projects',
571 'browse project listings',
572 'delete any projects',
573 // search module
574 'administer search',
575 // system module
576 'access administration pages',
577 'access site reports',
578 'administer actions',
579 'administer files',
580 'administer site configuration',
581 // taxonomy module
582 'administer taxonomy',
583 // upload module',
584 'upload files',
585 'view uploaded files',
586 // user module
587 'access user profiles',
588 'administer permissions',
589 'administer users',
590 'change own username',
591 // views module
592 'administer views',
593 ),
594 D_O_ROLE_CVS_ADMIN => array(
595 // cvs
596 'administer CVS',
597 // project
598 'administer projects',
599 // system
600 'access administration pages',
601 ),
602 D_O_ROLE_DOC_MAINTAINER => array(
603 // book
604 'add content to books',
605 // node
606 'create book content',
607 'edit any book content',
608 'revert revisions',
609 ),
610 D_O_ROLE_SITE_MAINTAINER => array(
611 // aggregator
612 'administer news feeds',
613 // book module
614 'administer book outlines',
615 'create new books',
616 // comment
617 'administer comments',
618 // node
619 'administer nodes',
620 'revert revisions',
621 // system
622 'access administration pages',
623 // taxonomy module
624 'administer taxonomy',
625 // upload
626 'upload files',
627 ),
628 D_O_ROLE_USER_ADMIN => array(
629 // system
630 'access administration pages',
631 // user
632 'administer users',
633 ),
634 D_O_ROLE_SWITCH => array(
635 // devel
636 'switch users',
637 'access devel information',
638 ),
639 );
640
641 // Delete current roles and permissions and re-populate them.
642 db_query('TRUNCATE {role}');
643 db_query('TRUNCATE {permission}');
644
645 foreach ($roles as $rid => $name) {
646 db_query("INSERT INTO {role} (rid, name) VALUES (%d, '%s')", $rid, $name);
647 }
648 $context['results'][] = t('Created roles.');
649 foreach ($permissions as $rid => $perms) {
650 db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', 0)", $rid, implode(', ', $perms));
651 }
652 $context['results'][] = t('Set role permissions.');
653 $context['message'] = t('Created roles and set permissions');
654 }
655
656 function _drupalorg_testing_create_users($args, &$context) {
657 // Define some well-known users in each of the roles. All of these will
658 // have the same password (see D_O_PASSWORD at the top of this file), and
659 // will also belong to the 'User switchers' role to be able to easily switch
660 // between them.
661 $users = array(
662 'admin' => array(D_O_ROLE_ADMINISTRATOR),
663 'site' => array(D_O_ROLE_SITE_MAINTAINER),
664 'doc' => array(D_O_ROLE_DOC_MAINTAINER),
665 'cvs' => array(D_O_ROLE_CVS_ADMIN),
666 'auth' => array(), // no extra roles
667 );
668
669 // Create a dummy user object for user_save().
670 $account = new stdClass();
671 $account->uid = 0;
672
673 // Now, generate our well-known users.
674 foreach ($users as $name => $roles) {
675 $edit = array();
676
677 // All the well-known users have the same password.
678 $edit['pass'] = D_O_PASSWORD;
679 $edit['status'] = 1;
680
681 // Put all of these custom users into the 'User switchers' role, too.
682 // We have to flip the roles array here, because that's what user_save() is expecting.
683 $edit['roles'] = array_flip(array_merge(array(D_O_ROLE_SWITCH), $roles));
684
685 for ($i = 1; $i <= D_O_NUM_USERS_PER_ROLE; $i++) {
686 $edit['name'] = $name . $i;
687 $edit['mail'] = $edit['name'] .'@'. D_O_DOMAIN;
688 user_save($account, $edit);
689 $context['results'][] = t('Created user %name.', array('%name' => $edit['name']));
690 }
691 for ($i = 1; $i <= D_O_NUM_CVS_USERS_PER_ROLE; $i++) {
692 $user_name = $name . $i;
693 $user = user_load(array('name' => $user_name));
694 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);
695 }
696 }
697
698 // Create a simple 'System Message' user for issue auto-followups.
699 $edit = array();
700 $edit['pass'] = D_O_PASSWORD;
701 $edit['status'] = 1;
702 $edit['name'] = t('System Message');
703 $edit['mail'] = 'system-message@'. D_O_DOMAIN;
704 user_save($account, $edit);
705 $context['results'][] = t('Created user %name.', array('%name' => $edit['name']));
706
707 // Create 50 random users.
708 module_load_include('inc', 'devel', 'devel_generate');
709 devel_create_users(50, FALSE);
710 $context['results'][] = t('Created 50 random users.');
711 $context['message'] = t('Created users');
712 }
713
714 /**
715 * Auto-generates project-related terms from drupal.org.
716 */
717 function _drupalorg_testing_create_project_terms($args, &$context) {
718 // Add top-level project terms.
719 $project_vid = _project_get_vid();
720 $terms = array(
721 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.'),
722 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).'),
723 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.'),
724 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.'),
725 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.'),
726 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>.'),
727 );
728
729 foreach ($terms as $name => $description) {
730 install_taxonomy_add_term($project_vid, $name, $description);
731 $context['results'][] = t('Created project category %term.', array('%term' => $name));
732 }
733
734 // Add module categories.
735 $modules_tid = install_taxonomy_get_tid(t('Modules'));
736 $terms = array(
737 t('Administration'),
738 t('CCK'),
739 t('Commerce / advertising'),
740 t('Community'),
741 t('Content'),
742 t('Content display'),
743 t('Developer'),
744 t('e-Commerce'),
745 t('Evaluation/rating'),
746 t('Event'),
747 t('File management'),
748 t('Filters/editors'),
749 t('Games and Amusements'),
750 t('Import/export'),
751 t('Javascript Utilities'),
752 t('Location'),
753 t('Mail'),
754 t('Media'),
755 t('Multilingual'),
756 t('Organic Groups'),
757 t('Paging'),
758 t('Performance and Scalability'),
759 t('RDF'),
760 t('Search'),
761 t('Security'),
762 t('Site navigation'),
763 t('Statistics'),
764 t('Syndication'),
765 t('Taxonomy'),
766 t('Theme related'),
767 t('Third-party party integration'),
768 t('User access/authentication'),
769 t('User management'),
770 t('Utility'),
771 t('Views'),
772 );
773
774 foreach ($terms as $name) {
775 install_taxonomy_add_term($project_vid, $name, '', array('parent' => array($modules_tid)));
776 $context['results'][] = t('Created project Modules category %term.', array('%term' => $name));
777 }
778
779 // Add release versions.
780 $release_vid = _project_release_get_api_vid();
781 $terms = array(
782 '4.0.x', '4.1.x', '4.2.x', '4.3.x',
783 '4.4.x', '4.5.x', '4.6.x', '4.7.x', '5.x', '6.x', '7.x',
784 );
785 $weight = 10;
786 // For releases to be properly ordered in the download tables, the oldest taxonomy
787 // terms must have the heaviest weights.
788 foreach ($terms as $name) {
789 install_taxonomy_add_term($release_vid, $name, '', array('weight' => $weight));
790 $weight--;
791 $context['results'][] = t('Created release version %term.', array('%term' => $name));
792 }
793
794 // Add release types.
795 $release_type_vid = install_taxonomy_add_vocabulary(t('Release type'), array('project_release' => 'project_release'), array('multiple' => TRUE));
796 $terms = array(
797 t('Security update'),
798 t('Bug fixes'),
799 t('New features'),
800 );
801
802 foreach ($terms as $name) {
803 install_taxonomy_add_term($release_type_vid, $name);
804 $context['results'][] = t('Created release type %term.', array('%term' => $name));
805 }
806
807 $context['message'] = t('Created project taxonomy');
808 }
809
810 /**
811 * Configure the "Issue tags" vocabulary and comment_alter_taxonomy.
812 */
813 function _drupalorg_testing_configure_issue_tags($args, &$context) {
814 $vocab_properties = array(
815 'multiple' => TRUE,
816 'tags' => TRUE,
817 'help' => t('Do <strong>NOT</strong> use tags for duplicating the "Assigned" or "Component" fields. Separate terms with a comma, not a space.'),
818 );
819 $issue_tags_vid = install_taxonomy_add_vocabulary(t('Issue tags'), array('project_issue' => 'project_issue'), $vocab_properties);
820
821 $terms = array(
822 t('Accessibility'),
823 t('Bikeshed'),
824 t('DX'),
825 t('Needs documentation'),
826 t('Needs benchmarking'),
827 t('Needs code style'),
828 t('Needs tests'),
829 t('Novice'),
830 t('Performance'),
831 t('Usability'),
832 );
833 foreach ($terms as $name) {
834 install_taxonomy_add_term($issue_tags_vid, $name);
835 $context['results'][] = t('Created Issue tag %term.', array('%term' => $name));
836 }
837
838 // Configure Comment alter taxonomy
839 variable_set('comment_alter_taxonomy_legacy_issue_paths', TRUE);
840 variable_set('comment_alter_taxonomy_vocabularies', array($issue_tags_vid => $issue_tags_vid));
841
842 $context['message'] = t('Created "Issue tags" vocabulary and configured Comment alter taxonomy');
843 }
844
845 function _drupalorg_testing_create_content($args, &$context) {
846 // Create a bunch of test content with the devel generate script.
847 module_load_include('inc', 'devel', 'devel_generate');
848
849 // Create 100 pseudo-random nodes.
850 $form_state['values'] = array(
851 'add_statistics' => 1,
852 'max_comments' => '10',
853 'node_types' => array('page' => 'page', 'story' => 'story', 'forum' => 'forum', 'book' => 'book'),
854 'num_nodes' => '100',
855 'time_range' => '604800',
856 'title_length' => '8',
857 );
858 devel_generate_content($form_state);
859 $context['results'][] = t('Created 100 random nodes.');
860 $context['message'] = t('Created dummy content');
861 }
862
863 /**
864 * Configures variables for project* modules.
865 */
866 function _drupalorg_testing_configure_project_settings($args, &$context) {
867 // TODO: there's currently so default sort method for
868 // projects in 6.x, so fix this when it appears.
869
870 $types = array(
871 t('Drupal Project') => array('name'),
872 t('Installation profiles') => array('name', 'date'),
873 t('Modules') => array('name', 'date', 'category'),
874 t('Theme engines') => array('name'),
875 t('Themes') => array('name', 'date'),
876 t('Translations') => array('name'),
877 );
878
879 foreach ($types as $type => $settings) {
880 $tid = install_taxonomy_get_tid($type);
881 // TODO: there's currently do method for per-term sorting
882 // in 6.x, so fix this when it appears...
883 }
884
885 // Settings for project_release.module.
886 variable_set('project_release_default_version_format', '!api#major%patch#extra');
887 variable_set('project_release_overview', '-1');
888 variable_set('project_release_browse_versions', '1');
889
890 $active_tids = array();
891 $active_terms = array('7.x', '6.x', '5.x');
892 foreach ($active_terms as $term) {
893 $tid = install_taxonomy_get_tid($term);
894 $active_tids[$tid] = $tid;
895 }
896 variable_set('project_release_active_compatibility_tids', $active_tids);
897 $context['results'][] = t('Configured project release settings.');
898
899 // Settings for project_issue.module.
900 variable_set('project_directory_issues', 'issues');
901 variable_set('project_issue_autocomplete', '1');
902 $account = user_load(array('name' => t('System Message')));
903 variable_set('project_issue_followup_user', $account->uid);
904
905 // Add custom statuses
906 $form_state = array();
907 $form_state['values']['status'] = array();
908 $form_state['values']['status_add'] = array(
909 'name' => t('patch (to be ported)'),
910 'weight' => -4,
911 'author_has' => 0,
912 'default_query' => 1,
913 );
914 project_issue_admin_states_form_submit(array(), $form_state);
915
916 $form_state = array();
917 $form_state['values']['status'] = array();
918 $form_state['values']['status_add'] = array(
919 'name' => t('postponed (maintainer needs more info)'),
920 'weight' => -10,
921 'author_has' => 0,
922 'default_query' => 1,
923 );
924 project_issue_admin_states_form_submit(array(), $form_state);
925
926 // Now set up the issue states from scratch for existing statuses.
927 $status = array();
928 $status[1] = array(
929 'name' => t('active'),
930 'weight' => -13,
931 'author_has' => 0,
932 'default_query' => 1,
933 );
934 $status[8] = array(
935 'name' => t('needs review'),
936 'weight' => -8,
937 'author_has' => 0,
938 'default_query' => 1,
939 );
940 $status[13] = array(
941 'name' => t('needs work'),
942 'weight' => -7,
943 'author_has' => 0,
944 'default_query' => 1,
945 );
946 $status[14] = array(
947 'name' => t('reviewed & tested by the community'),
948 'weight' => -6,
949 'author_has' => 0,
950 'default_query' => 1,
951 );
952 $status[2] = array(
953 'name' => t('fixed'),
954 'weight' => 1,
955 'author_has' => 0,
956 'default_query' => 1,
957 );
958 $status[3] = array(
959 'name' => t('duplicate'),
960 'weight' => 4,
961 'author_has' => 0,
962 'default_query' => 0,
963 );
964 $status[4] = array(
965 'name' => t('postponed'),
966 'weight' => 6,
967 'author_has' => 0,
968 'default_query' => 1,
969 );
970 $status[5] = array(
971 'name' => t("won't fix"),
972 'weight' => 9,
973 'author_has' => 0,
974 'default_query' => 0,
975 );
976 $status[6] = array(
977 'name' => t('by design'),
978 'weight' => 11,
979 'author_has' => 0,
980 'default_query' => 0,
981 );
982 $status[7] = array(
983 'name' => t('closed'),
984 'weight' => 13,
985 'author_has' => 1,
986 'default_query' => 0,
987 );
988
989 $form_state = array();
990 $form_state['values']['status'] = $status;
991 $form_state['values']['default_state'] = '1';
992 project_issue_admin_states_form_submit(array(), $form_state);
993
994 $context['results'][] = t('Configured project issue settings.');
995 $context['message'] = t('Configured project settings');
996 }
997
998 /**
999 * Generates sample issues and issue comments.
1000 */
1001 function _drupalorg_testing_create_issues($args, &$context) {
1002 if (module_load_include('inc', 'project_issue_generate') !== FALSE) {
1003 project_issue_generate_issues(50);
1004 if (function_exists('project_issue_generate_issue_comments')) {
1005 project_issue_generate_issue_comments(100);
1006 }
1007 }
1008 $context['results'][] = t('Generated 50 random issues, and 100 random issue followups.');
1009 $context['message'] = t('Created dummy issues');
1010 }
1011
1012 /**
1013 * Generates sample project content.
1014 *
1015 * NOTE: If you add other projects here that might ever have releases,
1016 * you should update the $projects array near the top of
1017 * drupalorg_testing_build_releases.php.
1018 */
1019 function _drupalorg_testing_create_content_project($args, &$context) {
1020 // First, add one of each type of project.
1021 $values[t('Drupal project')] = array(
1022 'title' => t('Drupal'),
1023 'body' => t('Drupal is an open-source platform and content management system for building dynamic web sites offering a broad range of features and services including user administration, publishing workflow, discussion capabilities, news aggregation, metadata functionalities using controlled vocabularies and XML publishing for content sharing purposes. Equipped with a powerful blend of features and configurability, Drupal can support a diverse range of web projects ranging from personal weblogs to large community-driven sites.'),
1024 'project' => array('uri' => 'drupal'),
1025 'name' => D_O_USER1,
1026 'cvs' => array(
1027 'repository' => 1,
1028 'directory' => '/',
1029 ),
1030 );
1031 $values[t('Installation profiles')] = array(
1032 'title' => t('Drupal.org Testing'),
1033 'body' => t('This profile installs a site with the structure, content, permissions, etc of Drupal.org to facilitate the reproduction of bugs and testing of patches for the project modules.'),
1034 'project' => array('uri' => 'drupalorg_testing'),
1035 'name' => 'site1',
1036 'cvs' => array(
1037 'repository' => 2,
1038 'directory' => '/profiles/drupalorg_testing/',
1039 ),
1040 );
1041 $values[t('Theme engines')] = array(
1042 'title' => t('PHPTAL theme engine'),
1043 'body' => t('This is a theme engine for Drupal 5.x, which allows the use of templates written in the PHPTAL language. This engine does most of its work by calls to the <a href="/node/11810">PHPtemplate engine</a>, just replacing the underlying template engine with the one from phptal.sourceforge.net.'),
1044 'project' => array('uri' => 'phptal'),
1045 'name' => 'auth1',
1046 'cvs' => array(
1047 'repository' => 2,
1048 'directory' => '/theme-engines/phptal/',
1049 ),
1050 );
1051 $values[t('Themes')] = array(
1052 'title' => t('Zen'),
1053 'body' => t('Zen is the ultimate <em>starting theme</em> for Drupal 5. If you are building your own standards-compliant theme, you will find it much easier to start with Zen than to start with Garland or Bluemarine. This theme has LOTs of documentation in the form of code comments for both the PHP (template.php) and HTML (page.tpl.php, node.tpl.php).'),
1054 'project' => array('uri' => 'zen'),
1055 'name' => 'doc1',
1056 'cvs' => array(
1057 'repository' => 2,
1058 'directory' => '/themes/zen/',
1059 ),
1060 );
1061 $values[t('Translations')] = array(
1062 'title' => t('Afrikaans Translation'),
1063 'body' => t("This page is the official translation of Drupal core into Afrikaans. This translation is currently available for Drupal 4.6's and Drupal 4.7's (cvs) core. Modules are being added as we progress with the translation effort."),
1064 'project' => array('uri' => 'af'),
1065 'name' => 'auth1',
1066 'cvs' => array(
1067 'repository' => 2,
1068 'directory' => '/translations/af/',
1069 ),
1070 );
1071 foreach ($values as $category => $project) {
1072 $project['project_type'] = install_taxonomy_get_tid($category);
1073 $project['mail'] = variable_get('site_mail', D_O_SITE_MAIL);
1074 $project['type'] = 'project_project';
1075 $node = install_save_node($project);
1076
1077 // Fix the version format string for core.
1078 if ($project['project']['uri'] == 'drupal') {
1079 db_query("UPDATE {project_release_projects} SET version_format = '%s' WHERE nid = %d", '!major%minor%patch#extra', $node->nid);
1080 }
1081
1082 $context['results'][] = t('Created project %name.', array('%name' => $project['title']));
1083 }
1084
1085 // Modules... let's start with some developer modules so we have a few in
1086 // the same category.
1087 $values = array();
1088 $values[] = array(
1089 'title' => t('Project'),
1090 'body' => t('This module provides project management for Drupal sites. Projects are generally assumed to represent software that has source code, releases, and so on. This module provides advanced functionality for browsing projects, optionally classifying them with a special taxonomy, and managing downloads of different versions of the software represented by the projects. It is used to provide the <a href="/project">downloads pages</a> for Drupal.org.'),
1091 'project' => array('uri' => 'project'),
1092 'categories' => array(t('Developer')),
1093 'name' => 'site1',
1094 'cvs' => array(
1095 'repository' => 2,
1096 'directory' => '/modules/project/',
1097 ),
1098 );
1099 $values[] = array(
1100 'title' => t('Project issue tracking'),
1101 'body' => t('This module provides issue tracking for projects created with the <a href="/project/project">project module</a>. <!--break-->It allows users to submit issues (bug reports, feature requests, tasks, etc) and enables teams to track their progress. It provides e-mail notifications to members about updates to items. Similar to many issue tracking systems. You can see it in action at <a href="/project/issues">http://drupal.org/project/issues</a>.'),
1102 'project' => array('uri' => 'project_issue'),
1103 'categories' => array(t('Developer')),
1104 'name' => 'site1',
1105 'cvs' => array(
1106 'repository' => 2,
1107 'directory' => '/modules/project_issue/',
1108 ),
1109 );
1110 $values[] = array(
1111 'title' => t('CVS integration'),
1112 'body' => t('A module that lets you track CVS commit messages. You can see it in action at http://drupal.org/cvs/. Interfaces with the project module to make releases via specific CVS branches and tags, and provides per-project source code access control.'),
1113 'project' => array('uri' => 'cvslog'),
1114 'categories' => array(t('Developer')),
1115 'name' => 'cvs1',
1116 'cvs' => array(
1117 'repository' => 2,
1118 'directory' => '/modules/cvslog/',
1119 ),
1120 );
1121 // Subscribe module, because its menu path and project/subscribe hate
1122 // each other. ;)
1123 $values[] = array(
1124 'title' => t('Subscribe'),
1125 'body' => t('The subscribe module allows you to subscribe to channels which other Drupal sites publish using the publish module. Both push and pull publishing models are supported. Communication between the publishing and subscribing sites is accomplished via XML-RPC.
1126
1127 This module is under development but testing and feedback are welcome.'),
1128 'project' => array('uri' => 'subscribe'),
1129 'categories' => array(t('Content')),
1130 'name' => 'doc1',
1131 'cvs' => array(
1132 'repository' => 2,
1133 'directory' => '/modules/subscribe/',
1134 ),
1135 );
1136 // User status module, because it's in more than one category.
1137 $values[] = array(
1138 'title' => t('User status change notifications'),
1139 'body' => t('This module enables sites to automatically send customized email notifications on the following events:
1140 <ul>
1141 <li>account activated</li>
1142 <li>account blocked</li>
1143 <li>account deleted</li>
1144 </ul>
1145 The first case is especially useful for sites that are configured to require administrator approval for new account requests.'),
1146 'project' => array('uri' => 'user_status'),
1147 'categories' => array(t('Administration'), t('Mail'), t('User management')),
1148 'name' => 'admin1',
1149 'cvs' => array(
1150 'repository' => 2,
1151 'directory' => '/modules/user_status/',
1152 ),
1153 );
1154
1155 $modules_tid = install_taxonomy_get_tid(t('Modules'));
1156 foreach ($values as $project) {
1157 $project['project_type'] = $modules_tid;
1158 $categories = array();
1159 foreach ($project['categories'] as $category) {
1160 $categories[] = install_taxonomy_get_tid($category);
1161 }
1162 $project["tid_$modules_tid"] = drupal_map_assoc($categories);
1163 $project['mail'] = variable_get('site_mail', D_O_SITE_MAIL);
1164 $project['type'] = 'project_project';
1165 $node = install_save_node($project);
1166
1167
1168 $context['results'][] = t('Created project %name.', array('%name' => $project['title']));
1169 }
1170
1171 // Setup some other projects under "Drupal project" that aren't in CVS.
1172 $values = array();
1173 $values[] = array(
1174 'title' => t('Drupal.org webmasters'),
1175 'body' => t('Drupal mailing lists, web site, forums, etc.') ."\n\n".
1176 t('A project with issue tracker that you can use to report spam, broken links, user account problems, or outdated documentation.') ."\n\n".
1177 t('If you want to report a problem with the Apache and MySQL installation on drupal.org, the Mailman mailing lists, the CVS repositories, and the various Drupal installations on the drupal.org domain, please use the <a href="@url">Drupal.org infrastructure project</a> instead.', array('@url' => url('project/infrastructure'))) ."\n",
1178 'project' => array('uri' => 'webmasters'),
1179 'name' => 'a',
1180 );
1181 $values[] = array(
1182 'title' => t('Drupal.org infrastructure'),
1183 'body' => t('An issue tracker for everything related to the Drupal.org servers. This includes the Apache and MySQL installation, the Mailman mailing lists, the CVS repositories, and the various Drupal installations on the drupal.org domain.') ."\n\n".
1184 t('If you want to report spam, broken links, user account problems, or outdated documentation, please use the <a href="@url">Drupal.org webmasters issue