--- attachment.orig	2006-09-22 22:44:57.000000000 +0200
+++ attachment.module	2006-09-22 22:52:58.000000000 +0200
@@ -327,7 +327,21 @@ function attachment_filemanager_download
     $nid = db_result(db_query("SELECT nid FROM {attachment} WHERE {attachment}.fid = %d", $file->fid));
     $node = node_load(array('nid'=>$nid));
     if (node_access('view', $node)) {
-      return TRUE;
+      // Access is granted. Check request to determine content-disposition.
+      $headers = array(
+                       'Content-Type: '. $file->mimetype,
+                       'Content-Transfer-Encoding: binary', 
+                       'Pragma: public', 
+                       'Cache-Control: must-revalidate, post-check=0, pre-check=0', 
+                       'Cache-Control: private', 
+                       'Content-Length: '. $file->size
+                       );
+      if ($_GET['download']) 
+        $headers[] = ('Content-Disposition: attachment; filename="'. $file->filename .'"');
+      else 
+        $headers[] = ('Content-Disposition: inline; filename="'. $file->filename .'"');
+      
+      return $headers;
     }
     else {
       return FALSE;
@@ -352,6 +366,8 @@ function theme_attachments($node) {
   $header[0]['class'] = 'filename';
   $header[1]['data'] = t('Size');
   $header[1]['class'] = 'size';
+  $header[2]['data'] = t('Actions');
+  $header[2]['class'] = 'action';
 
   foreach ((array)$node->attachments as $attachment) {
     if (!$attachment['hidden'] && !$attachment['deleted']) {
@@ -362,6 +378,9 @@ function theme_attachments($node) {
       $row[0]['class'] = 'filename';
       $row[1]['data'] = format_size($attachment['size']);
       $row[1]['class'] = 'size';
+      $row[2]['data'] = '<a href="' . module_invoke('filemanager', 'url', $attachment['fid'], FALSE, TRUE) . '&download=1"';
+      $row[2]['data'] .= drupal_attributes('Save this file to disk') . '>' . 'Download' . '</a>';
+      $row[2]['class'] = 'downloadlink';
       $rows[] = $row;
     }
   }
