? 143804_dot_generate_forums_5.patch
? 143806_dot_contact_form_3.patch
? 151976_dot_non_release_projects_4.patch
? 320150_dot_cache_tids.patch
? do_testing_non_cvs_projects.patch.txt
Index: /Applications/MAMP/htdocs/dot/drupal/profiles/drupalorg_testing/drupalorg_testing.profile
===================================================================
RCS file: /cvs/drupal-contrib/contributions/profiles/drupalorg_testing/drupalorg_testing.profile,v
retrieving revision 1.45
diff -u -p -r1.45 drupalorg_testing.profile
--- drupalorg_testing.profile 12 Oct 2008 15:45:23 -0000 1.45
+++ drupalorg_testing.profile 12 Oct 2008 20:15:31 -0000
@@ -103,6 +103,7 @@ function drupalorg_testing_profile_final
_drupalorg_testing_create_roles();
_drupalorg_testing_create_users();
_drupalorg_testing_create_project_terms();
+ _drupalorg_testing_create_forums();
_drupalorg_testing_create_content();
_drupalorg_testing_configure_project_settings();
_drupalorg_testing_create_issues();
@@ -580,12 +581,133 @@ function _drupalorg_testing_create_proje
}
}
+/**
+ * Create the forum containers and forums. Then create forum nodes.
+ */
+function _drupalorg_testing_create_forums() {
+ // Create forum containers.
+ $vid = _forum_get_vid();
+ $containers = array();
+ $containers[] = array(
+ 'name' => t('Support'),
+ 'description' => t('Try searching the forums first or a specific project\'s bug reports.'),
+ 'vid' => $vid,
+ 'weight' => -5,
+ );
+ $containers[] = array(
+ 'name' => t('General'),
+ 'description' => t('News and announcement and other general community discussions. Important: no support questions here!'),
+ 'vid' => $vid,
+ 'weight' => -3,
+ );
+ foreach ($containers as $container) {
+ drupal_execute('forum_form_container', $container, $vid);
+ }
+
+ // Create the forums.
+ $forums = array();
+
+ // Support forums.
+ $parent_tid = _drupalorg_testing_get_tid_by_term(t('Support'));
+ $forums[] = array(
+ 'name' => t('Post installation'),
+ 'description' => t('Drupal is up and running but how do I ...?'),
+ 'parent' => $parent_tid,
+ 'vid' => $vid,
+ 'weight' => -5,
+ );
+ $forums[] = array(
+ 'name' => t('Before you start'),
+ 'description' => t('Is Drupal a viable solution for my website? Please see the documentation Before you start before posting.'),
+ 'parent' => $parent_tid,
+ 'vid' => $vid,
+ 'weight' => -3,
+ );
+
+ // General forums.
+ $parent_tid = _drupalorg_testing_get_tid_by_term(t('General'));
+ $forums[] = array(
+ 'name' => t('News and announcements'),
+ 'description' => t('For news and announcements to the Drupal community at large.'),
+ 'parent' => $parent_tid,
+ 'vid' => $vid,
+ 'weight' => -5,
+ );
+ $forums[] = array(
+ 'name' => t('General discussion'),
+ 'description' => t('For less technical discussions about the Drupal project. Not for support questions!'),
+ 'parent' => $parent_tid,
+ 'vid' => $vid,
+ 'weight' => -3,
+ );
+
+ foreach ($forums as $forum) {
+ // Note: Ideally, we would execute the forum_form_forum form instead of
+ // the taxonomy_form_term. However, this won't work. The reason is that
+ // in the options for the parent select box are determined in _forum_parent_select(),
+ // which calls taxonomy_get_tree(), which statically caches the results. Since
+ // taxonomy_get_tree() has been previously called when creating the forum containers
+ // above, the new forum container terms will never be returned from
+ // taxonomy_get_tree(), and thus the 'parent' => $parent_tid found above
+ // will cause FAPI to create a form error because of an invalid choice.
+ // See http://drupal.org/comment/reply/106015 for more information.
+ //
+ // Now, the astute programmer will point out that taxonomy_form_term()
+ // *also* gets the list of options for its parent select box in the exact
+ // same way, and so the choice should also appear to be invalid.
+ // But, due to the fact that the forms that have already been
+ // validated are statically cached in drupal_validate_form(), and because
+ // the taxonomy term has already been validated, FAPI doesn't set a form
+ // error this time even though technically speaking, 'parent' will also
+ // be an invalid choice for the select box.
+ //
+ // Clearly, FAPI was not really designed with drupal_execute() in mind.
+ //
+ // Fortunately, executing taxonomy_form_term instead of forum_form_forum seems
+ // to work just fine here.
+ drupal_execute('taxonomy_form_term', $forum, $vid);
+ }
+
+ require_once(drupal_get_path('module', 'devel') .'/devel_generate.inc');
+
+ // Create 50 pseudo-random forum nodes, and 100 pseudo-random comments.
+ devel_generate_content(100, 200, 8, TRUE, array('forum'));
+
+ // Note: devel_generate_content() doesn't quite generate forum nodes properly.
+ // It creates the node itself just fine, but doesn't set {forum}.tid, so all
+ // forums end up having a lot of posts that appear to have been moved to a
+ // different forum.
+ // So, we need to get a list of all forums (but not containers), and then
+ // randomly assign the forum nodes that were created above to these
+ // forums.
+ // See http://drupal.org/node/317441 for more details.
+ //
+ // @TODO Drupal 6 port: Apparently this is no longer a problem in
+ // the Druapl 6 version of the devel module, so we should be able
+ // to remove this code.
+
+ // It would be nice to use taxonomy_get_tree($vid) here, but, again, that function
+ // statically caches the tree and does not provide a way to reset the cache.
+ $forums = array();
+ $result = db_query('SELECT td.tid FROM {term_data} td INNER JOIN {term_hierarchy} th ON th.tid = td.tid WHERE td.vid = %d AND th.parent <> 0', $vid);
+ while ($forum = db_fetch_object($result)) {
+ $forums[$forum->tid] = $forum->tid;
+ }
+
+ $result = db_query('SELECT nid FROM {forum}');
+ while ($topic = db_fetch_object($result)) {
+ $tid = array_rand($forums);
+ db_query('UPDATE {forum} SET tid = %d WHERE nid = %d', $tid, $topic->nid);
+ db_query('UPDATE {term_node} SET tid = %d WHERE nid = %d', $tid, $topic->nid);
+ }
+}
+
function _drupalorg_testing_create_content() {
// #5) Create a bunch of test content with the devel generate script.
require_once(drupal_get_path('module', 'devel') .'/devel_generate.inc');
// Create 100 pseudo-random nodes, and 200 pseudo-random comments.
- devel_generate_content(100, 200, 8, TRUE, array('page', 'story', 'forum'));
+ devel_generate_content(100, 200, 8, TRUE, array('page', 'story'));
_drupalorg_testing_create_content_project();
_drupalorg_testing_create_content_project_release();