Index: imagecache.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.install,v
retrieving revision 1.11
diff -u -p -r1.11 imagecache.install
--- imagecache.install	24 Apr 2008 05:27:45 -0000	1.11
+++ imagecache.install	27 Apr 2008 09:42:23 -0000
@@ -31,7 +31,7 @@ function imagecache_requirements($phase)
       );
     }
     
-    $imagecache_directory = file_create_path() .'/imagecache';
+    $imagecache_directory = imagecache_directory_path();
     if (!file_check_directory($imagecache_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
       if (!is_dir($imagecache_directory)) {
         $requirements['imagecache_directory'] = array(
@@ -136,6 +136,8 @@ function imagecache_uninstall() {
       db_query('DROP SEQUENCE {imagecache_preset}_presetid_seq');
       break;
   }
+
+  variable_del('imagecache_directory_path');
 }
 
 // Add action id to actions table.
@@ -243,4 +245,3 @@ function imagecache_update_4() {
   return $ret;
 }
 
-
Index: imagecache.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.module,v
retrieving revision 1.68
diff -u -p -r1.68 imagecache.module
--- imagecache.module	24 Apr 2008 05:27:45 -0000	1.68
+++ imagecache.module	27 Apr 2008 09:42:23 -0000
@@ -52,26 +52,60 @@ function imagecache_perm() {
 function imagecache_menu($may_cache) {
   $items = array();
   if ($may_cache) {
-
+    // global configuration settings
+    $items[] = array(
+      'path' => 'admin/settings/imagecache',
+      'title' => t('Imagecache Settings'),
+      'description' => t('Change how Imagecache behave.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('imagecache_settings'),
+      'access' => user_access('administer imagecache')
+    );
+  }
+  else {
     // standard imagecache callback.
     $items[] = array(
-      'path' => file_directory_path() .'/imagecache', 
+      'path' => imagecache_directory_path(),
       'callback' => 'imagecache_cache',
       'access' => true,
       'type' => MENU_CALLBACK
     );
 
-    // private downloads imagecache callback 
-    $items[] = array( 
-      'path' => 'system/files/imagecache',
+    // private downloads imagecache callback
+    $items[] = array(
+      'path' => 'system' . '/' . imagecache_directory_path(),
       'callback' => 'imagecache_cache_private',
       'access' => true,
       'type' => MENU_CALLBACK
-    );     
+    );
   }
   return $items;
 }
 
+function imagecache_settings() {
+  $form['imagecache_directory_path'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Imagecache storage path'),
+    '#default_value' => imagecache_directory_path(),
+    '#maxlength' => 255,
+    '#description' => t('A file system path where the files generated by Imagecache will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to the Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.'),
+  );
+
+  $form['#validate'] = array(
+    'imagecache_settings_validate' => array()
+  );
+
+  return system_settings_form($form);
+}
+
+function imagecache_settings_validate($form_id, $form_values) {
+  file_check_directory($form_values['imagecache_directory_path'], FILE_CREATE_DIRECTORY, 'imagecache_directory_path');
+}
+
+function imagecache_directory_path() {
+  return variable_get('imagecache_directory_path', file_directory_path() . '/imagecache');
+}
+
 /**
  * Implementation of hook_imagecache_actions.
  *
@@ -188,7 +222,7 @@ function imagecache_action_definition($a
  */
 function imagecache_create_url($presetname, $path) {
   $path = _imagecache_strip_file_directory($path);
-  return file_create_url(file_directory_path() .'/imagecache/'. $presetname .'/'. $path);
+  return file_create_url(imagecache_directory_path() . '/' . $presetname . '/'. $path);
 }
 
 /**
@@ -198,7 +232,7 @@ function imagecache_create_url($presetna
  */
 function imagecache_create_path($presetname, $path) {
   $path = _imagecache_strip_file_directory($path);
-  return file_create_path() .'/imagecache/'. $presetname .'/'. $path;
+  return imagecache_directory_path() . '/' . $presetname .'/'. $path;
 }
 
 /**
@@ -237,7 +271,7 @@ function imagecache_cache_private() {
   } 
   else {
     // if there is a 403 image, display it.
-    $accesspath = file_create_path('imagecache/'. $preset .'.403.png');
+    $accesspath = imagecache_directory_path() . '/' . $preset . '.403.png';
     if (file_exists($accesspath)) {
       imagecache_transfer($accesspath);
       exit;
@@ -297,7 +331,7 @@ function _imagecache_cache($presetname, 
     }
   
     // if there is a 404 image uploaded for the preset display it.
-    $notfoundpath = file_create_path('imagecache/'. $preset['presetname'] .'.404.png');
+    $notfoundpath = imagecache_directory_path() . '/' . $preset['presetname'] . '.404.png';
     if (file_exists($notfoundpath)) {
       imagecache_transfer($notfoundpath);
       exit;
@@ -869,7 +903,7 @@ function imagecache_preset_actions($pres
  */
 function imagecache_preset_flush($preset) {
   if (user_access('flush imagecache')) {
-    $presetdir = realpath(file_directory_path() .'/imagecache/'. $preset['presetname']);
+    $presetdir = realpath(imagecache_directory_path() . $preset['presetname']);
     if (is_dir($presetdir)) {
       _imagecache_recursive_delete($presetdir);
     }
