Fix for Node lookup

  1. function my_file_download($filepath) {
  2.   // Check if the file is controlled by the current module.
  3.   $node = // some mystery lookup function you write.
  4.   if (!empty($node) && $filemime = db_result(db_query("SELECT filemime FROM {fileupload} WHERE filepath = '%s'", file_create_path($filepath)))) {
  5.     if (node_access('view', $node)) {
  6.       return array('Content-type:' . $filemime);
  7.     }
  8.     else {
  9.       return -1;
  10.     }
  11.   }
  12. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.