Project

General

Profile

Revision 082b75eb

Added by Assos Assos over 6 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/file_entity/file_entity.pages.inc
675 675
      '#upload_validators' => file_entity_get_upload_validators($replacement_options),
676 676
      '#pre_render' => array('file_entity_upload_validators_pre_render'),
677 677
    );
678
    $form['replace_keep_original_filename'] = array(
679
      '#type' => 'checkbox',
680
      '#title' => t('Keep original filename'),
681
      '#default_value' => variable_get('file_entity_file_replace_options_keep_original_filename', FALSE),
682
      '#description' => t('Rename the newly uploaded file to the name of the original file. This action cannot be undone.'),
683
    );
678 684
  }
679 685

  
680 686
  $form['preview'] = file_view_file($file, 'preview');
......
832 838
        file_delete($replacement);
833 839
      }
834 840
    } else {
835
      $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri);
841
      if (!empty($form_state['values']['replace_keep_original_filename'])
842
      && $form_state['values']['replace_keep_original_filename']) {
843
        $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($file->uri);
844
      }
845
      else {
846
        $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri);
847
      }
836 848
      $replace_mode = $destination_uri == $file->uri ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME;
837 849
      if ($new_file_uri = file_unmanaged_copy($replacement->uri, $destination_uri, $replace_mode)) {
838 850
        // @todo Add watchdog() about replaced file here?

Also available in: Unified diff