You are here

function elfinder_file_download in elFinder file manager 8.2

Same name and namespace in other branches
  1. 6.2 elfinder.module \elfinder_file_download()
  2. 7.3 elfinder.module \elfinder_file_download()
  3. 7.2 elfinder.module \elfinder_file_download()

File

./elfinder.module, line 373

Code

function elfinder_file_download($uri) {
  if (config('elfinder.settings')
    ->get('filesystem.handleprivate') == 'true') {
    $user = \Drupal::currentUser();
    $accessown = 'download own uploaded files';
    $accessall = 'download all uploaded files';
    $info = elfinder_get_drupal_file_obj($uri);
    if ($info->uid == $user
      ->id() && user_access($accessown) || user_access($accessall)) {
      $disposition = preg_match("/^(text|image)\\//", $info->filemime) ? 'inline' : 'attachment';
      return array(
        'Content-Type' => $info->filemime,
        'Content-Length' => $info->filesize,
        'Content-Disposition' => elFinderDrupal::GetContentDisposition($info->filename, $info->filemime, FALSE),
      );
    }
    return NULL;
  }
}