You are here

public function elFinderVolumeDrupal::downloadcount in elFinder file manager 8.2

Same name and namespace in other branches
  1. 6.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::downloadcount()
  2. 7.3 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::downloadcount()
  3. 7.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::downloadcount()

File

src/Controller/elFinderVolumeDrupal.php, line 378
elFinder driver for Drupal filesystem.

Class

elFinderVolumeDrupal
@file

Code

public function downloadcount($target) {
  $path = $this
    ->decode($target);
  $file = $this
    ->_drupalfileobject($path);
  if ($file
    ->id() && module_exists('elfinder_stats')) {
    $downloads = db_select('elfinder_stats', 's')
      ->fields('s', array(
      'fid',
    ))
      ->condition('s.fid', $file
      ->id())
      ->condition('s.type', 'download')
      ->countQuery()
      ->execute()
      ->fetchField();
    return $downloads ? $downloads : 0;
  }
  return 0;
}