Index: filefield_paths.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield_paths/filefield_paths.module,v
retrieving revision 1.19.2.39
diff -b -u -p -r1.19.2.39 filefield_paths.module
--- filefield_paths.module	11 Oct 2010 04:21:40 -0000	1.19.2.39
+++ filefield_paths.module	8 Nov 2010 23:00:56 -0000
@@ -5,6 +5,22 @@
  * Contains core functions for the FileField Paths module.
  */
 
+
+/**
+ * Implementation of hook_menu().
+ */
+function filefield_paths_menu() {
+  $items = array();
+  $items['admin/settings/filefield_paths'] = array(
+    'title' => t('Filefield Paths settings'),
+    'description' => t('Set whether newly uploaded files overwrite existing files.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('filefield_paths_admin_settings_form'),
+    'access arguments' => array('administer site'),
+  );
+  return $items;
+}
+
 /**
  * Implements hook_filefield_paths_field_settings().
  */
@@ -312,6 +328,25 @@ function filefield_paths_form_submit($fo
   }
 }
 
+
+/**
+ * Admin settings form
+ */
+function filefield_paths_admin_settings_form() {
+  $form['filefield_paths_replace'] = array(
+    '#type' => 'radios',
+    '#title' => t('File move behavior'),
+    '#description' => t('When a file is uploaded that already exists, should it be renamed or replaced by the new file?'),
+    '#options' => array(
+      0 => 'Rename',
+      1 => 'Replace',
+    ),
+    '#default_value' => variable_get('filefield_paths_replace', 0),
+  );
+
+  return system_settings_form($form);
+}
+
 /**
  * Set batch process to update FileField Paths.
  *
@@ -539,7 +574,8 @@ function filefield_paths_filefield_paths
 
     // 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)) {
+      $replace = variable_get('filefield_paths_replace', 0);
+      if (filefield_paths_file_move($file, $replace)) {
 
         // Fix reference to old paths.
         if (isset($node->body) || module_exists('content')) {
