You are here

function photos_file_download in Album Photos 7.3

Same name and namespace in other branches
  1. 8.4 photos.module \photos_file_download()

Implements hook_file_download().

File

./photos.module, line 449
Implementation of photos.module.

Code

function photos_file_download($uri) {

  // Check if the file is controlled by the current module.
  $files = file_load_multiple(array(), array(
    'uri' => $uri,
  ));
  $file = reset($files);
  if ($file) {
    $usage = file_usage_list($file);
    if (isset($usage['photos'])) {
      if (user_access('view photo')) {
        $info = image_get_info($uri);
        return array(
          'Content-Type' => $info['mime_type'],
        );
      }
      else {

        // Access to the file is denied.
        return -1;
      }
    }
    else {

      // File is not controlled by the current module.
      return NULL;
    }
  }
}