Index: release/package-release-nodes.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/release/package-release-nodes.php,v
retrieving revision 1.68
diff -u -p -r1.68 package-release-nodes.php
--- release/package-release-nodes.php	30 Jul 2010 20:42:27 -0000	1.68
+++ release/package-release-nodes.php	24 Dec 2010 15:13:48 -0000
@@ -356,7 +356,7 @@ function package_release_core($type, $ni
   if (!drupal_exec("$tar -c --file=- $release_file_id | $gzip -9 --no-name > $full_dest_tgz")) {
     return 'error';
   }
-  $files[] = $file_path_tgz;
+  $files[$file_path_tgz] = 0;
 
   // As soon as the tarball exists, we want to update the DB about it.
   package_release_update_node($nid, $files);
@@ -468,7 +468,7 @@ function package_release_contrib($type, 
   if (!drupal_exec("$tar -ch --file=- $to_tar | $gzip -9 --no-name > $full_dest_tgz")) {
     return 'error';
   }
-  $files[] = $file_path_tgz;
+  $files[$file_path_tgz] = 0;
 
   // Start with no package contents, since this is only valid for profiles.
   $package_contents = array();
@@ -486,7 +486,12 @@ function package_release_contrib($type, 
     $drupalorg_makefile = 'drupal-org.make';
 
     if (file_exists($drupalorg_makefile)) {
-    // Search the .make file for the required 'core' attribute.
+      // On packaged install profiles, we want the profile-only tarball to be
+      // the heaviest weight in the {project_release_file} table so it sinks
+      // to the bottom of various listings.
+      $files[$file_path_tgz] = 10;
+
+      // Search the .make file for the required 'core' attribute.
       $info = drupal_parse_info_file($drupalorg_makefile);
 
       // Only proceed if a core release was found.
@@ -554,7 +559,7 @@ function package_release_contrib($type, 
         if (!drupal_exec("$tar -ch --file=- $project_short_name | $gzip -9 --no-name > $no_core_full_dest")) {
           return 'error';
         }
-        $files[] = $no_core_file_path;
+        $files[$no_core_file_path] = 6;
 
         // CORE DISTRIBUTION.
 
@@ -586,7 +591,8 @@ function package_release_contrib($type, 
         if (!drupal_exec("$tar -ch --file=- $core_build_dir | $gzip -9 --no-name > $core_full_dest")) {
           return 'error';
         }
-        $files[] = $core_file_path;
+        // We want this to float to the top, so give it the lightest weight.
+        $files[$core_file_path] = 0;
 
         // Development releases may have changed package contents -- clear out
         // their package item summary so a fresh item summary will be inserted.
@@ -1033,7 +1039,8 @@ function fix_info_file_version($file, $p
  * @param $nid
  *   The node ID of the release node to update.
  * @param $files
- *   Array of files to add to the release node.
+ *   Array of files to add to the release node. The keys are filenames, and
+ *   the values are the weight for the {project_release_file}.weight column.
  * @param $package_contents
  *   Optional. Array of nids of releases contained in a release package.
  */
@@ -1063,7 +1070,7 @@ function package_release_update_node($ni
     return FALSE;
   }
 
-  foreach ($files as $file_path) {
+  foreach ($files as $file_path => $file_weight) {
     // Compute the metadata for this file that we care about.
     $full_path = $dest_root . '/' . $file_path;
     $file_name = basename($file_path);
@@ -1080,12 +1087,12 @@ function package_release_update_node($ni
       // Don't have this file, insert a new record.
       db_query("INSERT INTO {files} (uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (%d, '%s', '%s', '%s', %d, %d, %d)", $node->uid, $file_name, $file_path, $file_mime, $file_size, FILE_STATUS_PERMANENT, $file_date);
       $fid = db_last_insert_id('files', 'fid');
-      db_query("INSERT INTO {project_release_file} (fid, nid, filehash) VALUES (%d, %d, '%s')", $fid, $node->nid, $file_hash);
+      db_query("INSERT INTO {project_release_file} (fid, nid, filehash, weight) VALUES (%d, %d, '%s', %d)", $fid, $node->nid, $file_hash, $file_weight);
     }
     else {
       // Already have this file for this release, update it.
       db_query("UPDATE {files} SET uid = %d, filename = '%s', filepath = '%s', filemime = '%s', filesize = %d, status = %d, timestamp = %d WHERE fid = %d", $node->uid, $file_name, $file_path, $file_mime, $file_size, FILE_STATUS_PERMANENT, $file_date, $file_data->fid);
-      db_query("UPDATE {project_release_file} SET filehash = '%s' WHERE fid = %d", $file_hash, $file_data->fid);
+      db_query("UPDATE {project_release_file} SET filehash = '%s', weight = %d WHERE fid = %d", $file_hash, $file_weight, $file_data->fid);
     }
   }
 
Index: release/project_release.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/release/project_release.install,v
retrieving revision 1.32
diff -u -p -r1.32 project_release.install
--- release/project_release.install	19 Aug 2010 16:31:17 -0000	1.32
+++ release/project_release.install	24 Dec 2010 15:13:49 -0000
@@ -176,6 +176,13 @@ function project_release_schema() {
         'not null' => TRUE,
         'default' => '',
       ),
+      'weight' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'size' => 'tiny',
+        'description' => 'Weight of this file in relation to other files in this release.',
+      ),
     ),
     'primary key' => array('fid'),
     'indexes' => array('nid' => array('nid')),
@@ -784,3 +791,19 @@ function project_release_update_6010() {
 
   return $ret;
 }
+
+/**
+ * Add the 'weight' column to {project_release_file}.
+ */
+function project_release_update_6011() {
+  $ret = array();
+  $spec = array(
+    'type' => 'int',
+    'not null' => TRUE,
+    'default' => 0,
+    'size' => 'tiny',
+    'description' => 'Weight of this file in relation to other files in this release.',
+  );
+  db_add_field($ret, 'project_release_file', 'weight', $spec);
+  return $ret;
+}
Index: release/views/project_release.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/release/views/project_release.views.inc,v
retrieving revision 1.16
diff -u -p -r1.16 project_release.views.inc
--- release/views/project_release.views.inc	18 Oct 2010 21:27:39 -0000	1.16
+++ release/views/project_release.views.inc	24 Dec 2010 15:13:49 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: project_release.views.inc,v 1.16 2010/10/18 21:27:39 dww Exp $
+// $Id: project_release.views.inc,v 1.16 2010/10/18 21:23:42 wright Exp $
 
 /**
  * @file
@@ -406,6 +406,20 @@ function project_release_views_data() {
       'handler' => 'views_handler_argument_string',
     ),
   );
+  $data['project_release_file']['weight'] = array(
+    'title' => t('Release file weight'),
+    'help' => t('The weight of a file attached to a release node.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
 
   $data['project_release_supported_versions']['table']['group']  = t('Project release');
   // We only want to JOIN on this table via explicit relationships.
Index: release/views/default_views/project_release_files.view.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/release/views/default_views/project_release_files.view.php,v
retrieving revision 1.1
diff -u -p -r1.1 project_release_files.view.php
--- release/views/default_views/project_release_files.view.php	30 Nov 2009 09:40:25 -0000	1.1
+++ release/views/default_views/project_release_files.view.php	24 Dec 2010 15:13:49 -0000
@@ -113,11 +113,11 @@ $handler->override_option('fields', arra
   ),
 ));
 $handler->override_option('sorts', array(
-  'fid' => array(
-    'order' => 'DESC',
-    'id' => 'fid',
-    'table' => 'files',
-    'field' => 'fid',
+  'weight' => array(
+    'order' => 'ASC',
+    'id' => 'weight',
+    'table' => 'project_release_file',
+    'field' => 'weight',
     'relationship' => 'none',
   ),
 ));
Index: release/views/handlers/project_release_handler_field_files.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/release/views/handlers/project_release_handler_field_files.inc,v
retrieving revision 1.3
diff -u -p -r1.3 project_release_handler_field_files.inc
--- release/views/handlers/project_release_handler_field_files.inc	23 Dec 2010 17:26:03 -0000	1.3
+++ release/views/handlers/project_release_handler_field_files.inc	24 Dec 2010 15:13:50 -0000
@@ -46,6 +46,7 @@ class project_release_handler_field_file
       '#title' => t('Sort files by'),
       '#type' => 'select',
       '#options' => array(
+        'weight' => t('File weight'),
         'filename' => t('File name'),
         'filesize' => t('File size'),
         'timestamp' => t('File timestamp'),
@@ -71,9 +72,14 @@ class project_release_handler_field_file
       $nids[] = $result->{$this->field_alias};
     }
     if (!empty($nids)) {
-      $order_by = 'f.' . $this->options['file_sort'];
+      if ($this->options['file_sort'] == 'weight') {
+        $order_by = 'prf.weight';
+      }
+      else {
+        $order_by = 'f.' . $this->options['file_sort'];
+      }
       $order_by .= ' ' . $this->options['file_sort_order'];
-      $result = db_query("SELECT prf.nid, prf.fid, prf.filehash, f.uid, f.filename, f.filepath, f.filesize, f.filemime, f.timestamp FROM {project_release_file} prf LEFT JOIN {files} f ON prf.fid = f.fid WHERE prf.nid IN (" . implode(', ', $nids) . ") ORDER BY $order_by");
+      $result = db_query("SELECT prf.nid, prf.fid, prf.filehash, prf.weight, f.uid, f.filename, f.filepath, f.filesize, f.filemime, f.timestamp FROM {project_release_file} prf LEFT JOIN {files} f ON prf.fid = f.fid WHERE prf.nid IN (" . implode(', ', $nids) . ") ORDER BY $order_by");
       while ($file = db_fetch_array($result)) {
         $file['filename'] = check_plain($file['filename']);
         $file['filemime'] = check_plain($file['filemime']);
@@ -107,6 +113,7 @@ class project_release_handler_field_file
     $tokens['[' . $this->options['id'] . '-size' . ']'] = t('The size of the attached file.');
     $tokens['[' . $this->options['id'] . '-hash' . ']'] = t('The MD5 hash of the attached file.');
     $tokens['[' . $this->options['id'] . '-time' . ']'] = t('The date and time when the file was created or uploaded.');
+    $tokens['[' . $this->options['id'] . '-weight' . ']'] = t('The weight of this file relative to others attached to the release.');
   }
 
   function add_self_tokens(&$tokens, $item) {
@@ -117,6 +124,7 @@ class project_release_handler_field_file
     $tokens['[' . $this->options['id'] . '-size' . ']'] = $item['filesize'];
     $tokens['[' . $this->options['id'] . '-hash' . ']'] = $item['filehash'];
     $tokens['[' . $this->options['id'] . '-time' . ']'] = $item['timestamp'];
+    $tokens['[' . $this->options['id'] . '-weight' . ']'] = $item['weight'];
     $file_parts = explode('.', basename($item['filename']));
     $ext = array_pop($file_parts);
     // See if the previous extension is '.tar' and if so, add that, so we see
@@ -128,4 +136,3 @@ class project_release_handler_field_file
     $tokens['[' . $this->options['id'] . '-ext' . ']'] = $ext;
   }
 }
-
