You are here

function filefield_source_imce_custom_scan_full in FileField Sources 6

Same name and namespace in other branches
  1. 7 sources/imce.inc \filefield_source_imce_custom_scan_full()

Scan directory and return file list, subdirectories, and total size for Full Mode.

1 string reference to 'filefield_source_imce_custom_scan_full'
filefield_source_imce_page in sources/imce.inc
Outputs the IMCE browser for FileField.

File

sources/imce.inc, line 221
A FileField extension to allow referencing of files from IMCE.

Code

function filefield_source_imce_custom_scan_full($dirname, &$imce) {

  // Get a list of files in the database for this directory.
  $sql_dir_name = $dirname == '.' ? file_directory_path() : file_directory_path() . '/' . $dirname;
  $result = db_query("SELECT filepath FROM {files} WHERE filepath LIKE '%s' AND filepath NOT LIKE '%s'", $sql_dir_name . '/%', $sql_dir_name . '/%/%');
  $db_files = array();
  while ($row = db_fetch_object($result)) {
    $db_files[basename($row->filepath)] = 1;
  }

  // Get the default IMCE directory scan, then filter down to database files.
  $directory = imce_scan_directory($dirname);
  foreach ($directory['files'] as $filename => $file) {
    if (!isset($db_files[$filename])) {
      unset($directory['files'][$filename]);
      $directory['dirsize'] -= $file['size'];
    }
  }

  // Disable file operations for IMCE 6.x-1.x
  if (!module_hook('imce', 'file_references')) {
    filefield_source_imce_disable_perms($imce, array(
      'browse',
      'subnav',
    ));
  }
  return $directory;
}