commit 837ec9f05a81209ed4fd5ad66ecf9f0d888eb83c Author: Joel Pittet Date: Thu Aug 20 11:07:58 2015 -0700 fixes diff --git a/filefield_paths.module b/filefield_paths.module index 212ea55..03b47bb 100644 --- a/filefield_paths.module +++ b/filefield_paths.module @@ -122,15 +122,16 @@ function filefield_paths_form_alter(&$form, $form_state, $form_id) { '#weight' => 10, ); - // File exists behavior. Keep disabled if the file name option is the same as the original file, as this can result in - // the uploaded file itself being moved onto itself and then deleted. + // File exists behavior. Keep disabled if the file name option is the + // same as the original file, as this can result in the uploaded file + // itself being moved onto itself and then deleted. $form['instance']['settings']['filefield_paths']['replace_existing_files'] = array( '#type' => 'checkbox', '#title' => t('Replace existing files'), '#description' => t('If a file with the same name already exists in the destination directory, replace it.'), '#weight' => 11, '#default_value' => isset($settings['replace_existing_files']) ? $settings['replace_existing_files'] : FALSE, - '#disabled' => FALSE //isset($settings['file_name']) && $settings['file_name']['value'] == '[file:ffp-name-only-original].[file:ffp-extension-original]' ? TRUE : FALSE + '#disabled' => FALSE, ); // Retroactive updates. @@ -147,7 +148,7 @@ function filefield_paths_form_alter(&$form, $form_state, $form_id) { '#title' => t('Active updating'), '#default_value' => isset($settings['active_updating']) ? $settings['active_updating'] : FALSE, '#description' => t('Actively move and rename previously uploaded files as required.') . '
' . t('Warning: This feature should only be used on developmental servers or with extreme caution.') . '
', - '#weight' => 13 + '#weight' => 13, ); } } diff --git a/modules/filefield_paths.inc b/modules/filefield_paths.inc index a433ca9..662ba72 100644 --- a/modules/filefield_paths.inc +++ b/modules/filefield_paths.inc @@ -53,7 +53,7 @@ function filefield_paths_filefield_paths_field_settings($field, $instance) { function filefield_paths_filefield_paths_process_file($type, $entity, $field, $instance, $langcode, &$items) { if (isset($instance['settings']['filefield_paths'])) { $settings = $instance['settings']['filefield_paths']; - foreach ($items as &$file) { + foreach ($items as $delta => &$file) { if (filefield_paths_uri_is_local($file['uri']) && ($file['timestamp'] == REQUEST_TIME || $settings['active_updating'])) { $token_data = array( 'file' => (object) $file, @@ -82,7 +82,7 @@ function filefield_paths_filefield_paths_process_file($type, $entity, $field, $i $old_file['filename'] = $file['filename']; $moved_file = file_move((object) $old_file, $file['uri'], $file_exists_behavior); if ($moved_file && $moved_file->fid != $file['fid']) { - $entity->{$instance['field_name']}[$entity->language][0] = (array) $moved_file; + $entity->{$instance['field_name']}[$entity->language][$delta] = (array) $moved_file; file_delete((object) $old_file, TRUE); }