You are here

function fancy_file_delete_unmanaged_get_directories in Fancy File Delete 7

Answer a list of directories to include/exclude.

3 calls to fancy_file_delete_unmanaged_get_directories()
FancyFileDeleteUnmanagedDirectoryFilter::value_form in views/inc/FancyFileDeleteUnmanagedDirectoryFilter.inc
Options form subform for setting options.
fancy_file_delete_unmanaged_get_chosen_dirs in ./fancy_file_delete.module
Answer a list of chosen directories from which to delete unmanaged files from. Defaults to all directories if no choice was previously made.
fancy_file_delete_unmanaged_set_chosen_dirs in ./fancy_file_delete.module
Set a list of chosen directories from which to delete unmanaged files from.

File

./fancy_file_delete.module, line 259

Code

function fancy_file_delete_unmanaged_get_directories() {
  $public_dir = variable_get('file_public_path', 'sites/default/files');
  $private_dir = variable_get('file_private_path', '');

  // If the private path is a sub-path of the public path, exclude it.
  $exclude_paths = array();
  if (!empty($private_dir) && strpos($private_dir, $public_dir) === 0) {
    $exclude_paths[] = $private_dir;
  }

  // Get all files from default standard file dir.
  $directories = array(
    'public://',
  );
  $directories = array_merge($directories, fancy_file_delete_unmanaged_get_sub_directories($public_dir, 'public://', $exclude_paths));

  // Get all files from the private file directory.
  if (!empty($private_dir)) {

    // If the public path is a sub-path of the private path, exclude it.
    $exclude_paths = array();
    if (!empty($public_dir) && strpos($public_dir, $private_dir) === 0) {
      $exclude_paths[] = $public_dir;
    }
    $directories[] = 'private://';
    $directories = array_merge($directories, fancy_file_delete_unmanaged_get_sub_directories($private_dir, 'private://', $exclude_paths));
  }
  natsort($directories);
  return array_values($directories);
}