? dot_generate_releases.patch Index: drupalorg_testing.profile =================================================================== RCS file: /cvs/drupal-contrib/contributions/profiles/drupalorg_testing/drupalorg_testing.profile,v retrieving revision 1.39 diff -u -p -r1.39 drupalorg_testing.profile --- drupalorg_testing.profile 26 Jan 2008 04:54:46 -0000 1.39 +++ drupalorg_testing.profile 9 Mar 2008 18:04:34 -0000 @@ -569,6 +569,7 @@ function _drupalorg_testing_create_conte devel_generate_content(100, 200, 8, TRUE, array('page', 'story', 'forum')); _drupalorg_testing_create_content_project(); + _drupalorg_testing_create_content_project_release(); } /** @@ -673,11 +674,9 @@ function _drupalorg_testing_create_issue * Generates sample project content. */ function _drupalorg_testing_create_content_project() { - // Disable comments and file attachments on project_project and project_release nodes. + // Disable comments and file attachments on project_project nodes. variable_set('comment_project_project', COMMENT_NODE_DISABLED); variable_set('upload_project_project', 0); - variable_set('comment_project_release', COMMENT_NODE_DISABLED); - variable_set('upload_project_release', 0); // First, add one of each type of project. $values[t('Drupal project')] = array( @@ -813,6 +812,121 @@ The first case is especially useful for } /** + * Generates sample project release nodes. + */ +function _drupalorg_testing_create_content_project_release() { + // Disable comments and file attachments on project_release nodes. + variable_set('comment_project_release', COMMENT_NODE_DISABLED); + variable_set('upload_project_release', 0); + + // Retrieve a list of projects on the site. + $result = db_query("SELECT n.nid, pp.uri FROM {node} n INNER JOIN {project_projects} pp ON n.nid = pp.nid WHERE n.type = 'project_project'"); + $projects = array(); + while ($project = db_fetch_array($result)) { + $projects[$project['uri']] = $project['nid']; + } + + // Create some releases + $values = array(); + $values[] = array( + 'title' => t('Drupal 4.7.9'), + 'version' => '4.7.x-4.7.9', + 'pid' => $projects['drupal'], + 'major' => '4', + 'minor' => '7', + 'patch' => '9', + 'extra' => NULL, + 'body' => t('The ninth maintenance and security release of the Drupal 4.7 series. Only fixes for security vulnerabilities and other bugs have been committed. New features are only being added to the forthcoming Drupal 6.0 release.'), + 'categories' => array(t('4.7.x')), + 'name' => 'site1', + 'tag' => 'DRUPAL-4-7-9', + 'rebuild' => 0, + 'file_path' => 'files/project/drupal-4.7.9.tar.gz', + 'file_hash' => 'da399626f9ea43e3cd4f235582aa80c0', + 'file_date' => '1196889614', + ); + $values[] = array( + 'title' => t('Drupal 5.6'), + 'version' => '5.x-5.6', + 'pid' => $projects['drupal'], + 'major' => '5', + 'minor' => NULL, + 'patch' => '6', + 'extra' => '', + 'body' => t('The sixth maintenance and security release of the Drupal 5 series. Only fixes for security vulnerabilities and other bugs have been committed. New features are only being added to the forthcoming Drupal 7.0 release.'), + 'categories' => array(t('5.x')), + 'name' => 'site2', + 'tag' => 'DRUPAL-5-6', + 'rebuild' => 0, + 'file_path' => 'files/project/drupal-5.6.tar.gz', + 'file_hash' => 'da399626f9ea43e3cd4f235582aa80c0', + 'file_date' => '1200003605', + ); + $values[] = array( + 'title' => t('Drupal 5.7'), + 'version' => '5.x-5.7', + 'pid' => $projects['drupal'], + 'major' => '5', + 'minor' => NULL, + 'patch' => '7', + 'extra' => NULL, + 'body' => t('The seventh maintenance and security release of the Drupal 5 series. Only fixes for security vulnerabilities and other bugs have been committed. New features are only being added to the forthcoming Drupal 7.0 release.'), + 'categories' => array(t('5.x')), + 'name' => 'cvs1', + 'tag' => 'DRUPAL-5-7', + 'rebuild' => 0, + 'file_path' => 'files/project/drupal-5.7.tar.gz', + 'file_hash' => 'da399626f9ea43e3cd4f235582aa80c0', + 'file_date' => '1201565405', + ); + + $values[] = array( + 'title' => t('Drupal 6.1'), + 'version' => '6.x-6.1', + 'pid' => $projects['drupal'], + 'major' => '6', + 'minor' => NULL, + 'patch' => '1', + 'extra' => NULL, + 'categories' => array(t('6.x')), + 'name' => 'cvs2', + 'body' => t('The first maintenance and security release of the Drupal 6 series. Only fixes for security vulnerabilities and other bugs have been committed. New features are only being added to the forthcoming Drupal 7.0 release.'), + 'tag' => 'DRUPAL-6-1', + 'rebuild' => 0, + 'file_path' => 'files/project/drupal-6.1.tar.gz', + 'file_hash' => 'da399626f9ea43e3cd4f235582aa80c0', + 'file_date' => '1204142109', + ); + + $bug_fix_tid = _drupalorg_testing_get_tid_by_term('Bug fixes'); + foreach ($values as $release) { + $release['release_type'] = $bug_fix_tid; + $categories = array(); + foreach ($release['categories'] as $category) { + $categories[] = _drupalorg_testing_get_tid_by_term($category); + } + $release['type'] = 'project_release'; + drupal_execute('project_release_node_form', $release, $release); + // CHEESY HACK: Because Drupal is not fully bootstrapped at install time, + // we have to do raw DB manipulation to add the terms and cvs related stuff. Sigh... + $node = node_load(array('title' => $release['title'])); + db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $release['release_type']); + foreach ($categories as $tid) { + db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $tid); + // If this major version does not already have a row in {project_release_supported_versions}, add one. + if (!db_result(db_query('SELECT COUNT(*) FROM {project_release_supported_versions} WHERE nid = %d AND tid = %d and major = %d', $release['pid'], $tid, $release['major']))) { + db_query('INSERT INTO {project_release_supported_versions} (nid, tid, major, supported, recommended, snapshot) VALUES (%d, %d, %d, %d, %d, %d)', $release['pid'], $tid, $release['major'], 1, 1, 1); + } + } + // Put an entry for this tag/branch in {cvs_tags} + db_query("INSERT INTO {cvs_tags} (nid, tag, branch) VALUES (%d, '%s', %d)", $node->nid, $release['tag'], $release['rebuild']); + + // Manually put file and version info into db since I can't get that working via drupal_execute(). + db_query("UPDATE {project_release_nodes} SET file_path = '%s', file_date = %d, file_hash = '%s', version_major = %d, version_minor = %d, version_patch = %d, version_extra = '%s' WHERE nid = %d", $release['file_path'], $release['file_date'], $release['file_hash'], $release['major'], $release['minor'], $release['patch'], $release['extra'], $node->nid); + } +} + +/** * Setup menus to match drupal.org. */ function _drupalorg_testing_create_menus() {