Index: modules/project/release/project_release.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project/release/project_release.module,v retrieving revision 1.38 diff -u -p -r1.38 project_release.module --- modules/project/release/project_release.module 5 Aug 2007 06:25:46 -0000 1.38 +++ modules/project/release/project_release.module 6 Aug 2007 03:49:44 -0000 @@ -1807,3 +1807,27 @@ function theme_project_release_download_ return l($link_text, $link_path); } } + +/** + * Implementation of hook_file_download(). + * + * @param $filepath + * The name of the file to download. + * @return + * An array of header fields for the download. + */ +function project_release_file_download($filename) { + $filepath = file_create_path($filename); + $result = db_query("SELECT f.nid FROM {project_release_nodes} f WHERE file_path = '%s'", $filepath); + if ($nid = db_result($result)) { + $node = node_load($nid); + if (node_access('view', $node)) { + return array( + 'Content-Type: application/octet-stream', + 'Content-Length: '. filesize($filepath), + 'Content-Disposition: attachment; filename='. mime_header_encode($filename), + ); + } + return -1; + } +}