--- project_release.module Mon Jan 08 19:46:20 2007 +++ project_release.module Mon Apr 23 08:59:00 2007 @@ -1508,3 +1508,28 @@ function project_release_download_link($ return l($link_text, $link_path); } } + +function project_release_file_download($filename) { + $path = file_create_path($filename); + $result = db_query("SELECT f.* FROM {project_release_nodes} f WHERE file_path = '%s'", $path); + if ($file = db_fetch_object($result)) { + if (user_access('view uploaded files')) { + $node = node_load($file->nid); + if (node_access('view', $node)) { + return array( + 'Content-Type: application/force-download', + 'Content-Length: '. filesize($path), + 'Content-disposition: attachment; filename="' . $filename . '"', + 'Content-Transfer-Encoding: binary' + ); + } + else { + return -1; + } + } + else { + return -1; + } + } +} \ No newline at end of file