You are here

function rotor_file_download in Rotor Banner 7

Same name and namespace in other branches
  1. 5 rotor.module \rotor_file_download()
  2. 6.2 rotor.module \rotor_file_download()

Implementation of hook_file_download().

File

./rotor.module, line 284
A rotor banner consists in a set of images that will be changing. This module is made using jquery.

Code

function rotor_file_download($filepath) {
  $result = db_query("SELECT r.nid, r.fid, f.filemime, f.filesize FROM {rotor_item} r INNER JOIN {files} f ON r.fid = f.fid WHERE f.filepath = '%s'", file_create_path($filepath));
  if ($file = db_fetch_object($result)) {
    $node = node_load(array(
      'type' => 'rotor_item',
      'nid' => $file->nid,
    ));
    if (node_access('view', $node)) {
      return array(
        'Content-Type: ' . mime_header_encode($file->filemime),
        'Content-Length: ' . (int) $file->filesize,
      );
    }
    return -1;
  }
}