Index: uc_file.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_file/uc_file.pages.inc,v
retrieving revision 1.1.2.17
diff -u -r1.1.2.17 uc_file.pages.inc
--- uc_file.pages.inc	27 Feb 2010 19:45:33 -0000	1.1.2.17
+++ uc_file.pages.inc	7 Jun 2010 15:13:21 -0000
@@ -33,15 +33,6 @@
  *   Array of the files.
  */
 function theme_uc_file_user_downloads($files) {
-  // Create a header and the pager it belongs to.
-  $header = array(
-    array('data' => t('Purchased'  ), 'field' => 'u.granted', 'sort' => 'desc'),
-    array('data' => t('Filename'   ), 'field' => 'f.filename'),
-    array('data' => t('Description'), 'field' => 'p.description'),
-    array('data' => t('Downloads'  ), 'field' => 'u.accessed'),
-    array('data' => t('Addresses'  )),
-  );
-
   $rows = array();
   $row = 0;
   foreach ($files as $file) {
@@ -58,7 +49,7 @@
     $rows[] = array(array('data' => t('No downloads found'), 'colspan' => 5));
   }
 
-  $output .= theme('table', $header, $rows);
+  $output .= theme('table', uc_file_downloads_table_header(), $rows);
   $output .= theme('pager', NULL, UC_FILE_PAGER_SIZE, 0);
   $output .= '<div class="form-item"><p class="description">'.
   t('Once your download is finished, you must refresh the page to download again. (Provided you have permission)') .
@@ -69,6 +60,19 @@
 }
 
 /**
+ * Returns header for file downloads table
+ */
+function uc_file_downloads_table_header() {
+  return array(
+    array('data' => t('Purchased'  ), 'field' => 'u.granted', 'sort' => 'desc'),
+    array('data' => t('Filename'   ), 'field' => 'f.filename'),
+    array('data' => t('Description'), 'field' => 'p.description'),
+    array('data' => t('Downloads'  ), 'field' => 'u.accessed'),
+    array('data' => t('Addresses'  )),
+  );
+}
+
+/**
  * Table builder for user downloads
  */
 function uc_file_user_downloads($account) {
@@ -80,7 +84,7 @@
     "SELECT u.granted, f.filename, u.accessed, u.addresses, p.description, u.file_key, f.fid, u.download_limit, u.address_limit, u.expiration FROM {uc_file_users} as u ".
     "LEFT JOIN {uc_files} as f ON u.fid = f.fid ".
     "LEFT JOIN {uc_file_products} as p ON p.pfid = u.pfid WHERE uid = %d".
-    tablesort_sql($header),
+    tablesort_sql(uc_file_downloads_table_header()),
     UC_FILE_PAGER_SIZE,
     0,
     "SELECT COUNT(*) FROM {uc_file_users} WHERE uid = %d",

