You are here

function _filefield_source_attach_directory in FileField Sources 7

Same name and namespace in other branches
  1. 6 sources/attach.inc \_filefield_source_attach_directory()
2 calls to _filefield_source_attach_directory()
filefield_source_attach_process in sources/attach.inc
A #process callback to extend the filefield_widget element type.
_filefield_source_attach_file_path_validate in sources/attach.inc

File

sources/attach.inc, line 290
A FileField extension to allow use of files within a server directory.

Code

function _filefield_source_attach_directory($instance, $account = NULL) {
  $field = field_info_field($instance['field_name']);
  $account = isset($account) ? $account : $GLOBALS['user'];
  $path = $instance['widget']['settings']['filefield_sources']['source_attach']['path'];
  $absolute = !empty($instance['widget']['settings']['filefield_sources']['source_attach']['absolute']);

  // Replace user level tokens.
  // Node level tokens require a lot of complexity like temporary storage
  // locations when values don't exist. See the filefield_paths module.
  if (module_exists('token')) {
    $path = token_replace($path, array(
      'user' => $account,
    ));
  }
  return $absolute ? $path : file_default_scheme() . '://' . $path;
}