You are here

function _filefield_source_attach_directory in FileField Sources 6

Same name and namespace in other branches
  1. 7 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 265
A FileField extension to allow use of files within a server directory.

Code

function _filefield_source_attach_directory($settings, $account = NULL) {
  $account = isset($account) ? $account : $GLOBALS['user'];
  $path = isset($settings['filefield_source_attach_path']) ? $settings['filefield_source_attach_path'] : 'file_attach';
  $absolute = !empty($settings['filefield_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, 'user', $account);
  }
  return $absolute ? $path : file_directory_path() . '/' . $path;
}