function filefield_paths_process_file in File (Field) Paths 6.2
Process FileField Paths settings, rename and move files.
2 calls to filefield_paths_process_file()
- filefield_paths_node_update in ./
filefield_paths.module - Implements hook_node_update().
- _filefield_paths_updater_process in includes/
updater.inc
File
- ./
filefield_paths.module, line 207 - Contains core functions for the FileField Paths module.
Code
function filefield_paths_process_file(&$file, $settings, &$node) {
$user = user_load($node->uid);
$source = $file['filepath'];
$fields = module_invoke_all('filefield_paths_field_settings');
foreach (array_keys($fields) as $field) {
$file[$fields[$field]['key']] = token_replace_multiple($settings[$field], array(
'global' => NULL,
'node' => $node,
'filefield_paths' => array(
$file,
),
'user' => $user,
));
// Invoke filefield_paths_postprocess_field().
foreach (module_implements('filefield_paths_field_postprocess') as $module) {
$function = "{$module}_filefield_paths_field_postprocess";
$function(&$file[$fields[$field]['key']], $field, $settings["{$field}_options"]);
}
}
// Prepare filepath.
$file['filepath'] = !empty($file['filepath']) ? "{$file['filepath']}/{$file['filename']}" : $file['filename'];
$file['filepath'] = file_directory_path() . "/{$file['filepath']}";
// Finalize file if necessary.
//if ($file['filepath'] != $source) {
_filefield_paths_file_move($source, $file);
// Invoke filefield_paths_postprocess_file().
foreach (module_implements('filefield_paths_file_postprocess') as $module) {
$function = "{$module}_filefield_paths_file_postprocess";
$function($source, $file, &$node, $settings);
}
//}
// // Finalize files if necessary
// if (dirname($file['filepath']['new']) != dirname($file['field']['filepath']) || $file['filename']['new'] != $file['field']['filename']) {
// if (filefield_paths_file_move($file)) {
//
// // Store new filename in file Array
// $file['field']['filename'] = $file['filename']['new'];
// }
// }
// }
}