=== modified file 'sites/all/modules/customcssjs/customcssjs.module'
--- sites/all/modules/customcssjs/customcssjs.module	2010-08-13 21:06:05 +0000
+++ sites/all/modules/customcssjs/customcssjs.module	2010-08-13 22:55:39 +0000
@@ -32,18 +32,27 @@
 function customcssjs_init() {
   // Add the CSS and JS
   //
-  $basecamino = file_directory_path() ;
+  if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
+    if (!variable_get('customcssjs_private_allowed', FALSE)) {
+      return;
+    }
+    // Directory is in the website root
+    $basecamino = '' ;
+  }
+  else {
+    $basecamino = file_directory_path() . '/' ;
+  }
   $css_path = variable_get('customcssjs_css', array()) ;
   if (!empty($css_path)) {
     $css_files = file_scan_directory(
-      $basecamino .'/'. $css_path, "css", array('.','..','CVS'),
+      $basecamino . $css_path, "css", array('.','..','CVS'),
       '_customcssjs_add_css', // Callback function for adding the CSS
       FALSE, 'filename', 0 ) ;
   }
   $js_path = variable_get('customcssjs_js', array()) ;
   if (!empty($js_path)) {
     $js_files = file_scan_directory(
-      $basecamino .'/'. $js_path, "js", array('.','..','CVS'),
+      $basecamino . $js_path, "js", array('.','..','CVS'),
       '_customcssjs_add_js', // Callback function for adding the JS
       FALSE, 'filename', 0 ) ;
   }
@@ -83,13 +92,35 @@
   $default_js_path = 'customcssjs/js';
 
   $form = array() ;
+  if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
+    // Drupal wants to always add CSS/JS files with a relative path, so
+    // they need to be inside the web root. But since we have private downloads,
+    // file_directory_path() is an absolute path, very probably not in the web root.
+
+    // When submitting the form, this function is called twice (before validating input, and after redirection).
+    // Don't set the message when validating input.
+    if (empty($_POST)) {
+      drupal_set_message(t("Your download method is set to 'Private'. Your CSS/JS folders will NOT be added inside your files folder, but directly in your web root. You MUST NOT use folders which are used by Drupal system files, or by other Drupal websites on the same multisite installation."), 'warning');
+    }
+    $form['customcssjs_private_allowed'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Allow custom CSS / JS directly in web root'),
+      '#default_value' => variable_get('customcssjs_private_allowed', FALSE),
+      '#description' => t('Please confirm that you are aware of the caveats of using this module combined with <a href="/admin/settings/file-system">private downloads</a>.'),
+      '#required' => TRUE,
+    ) ;
+    $fileroot_desc = 'web root directory';
+  }
+  else {
+    $fileroot_desc = 'default files folder: ' . file_directory_path() . '. You may setup this path <a href="/admin/settings/file-system">here</a>.';
+  }
   $form['customcssjs_css'] = array(
     '#type' => 'textfield',
     '#title' => t('Folder for CSS files'),
     '#default_value' => variable_get('customcssjs_css', $default_css_path),
     '#size' => 50,
     '#maxlength' => 50,
-    '#description' => t('Path relative to default files folder: '. file_directory_path() .'. You may setup this path <a href="/admin/settings/file-system">here</a>.'),
+    '#description' => t('Path relative to ' . $fileroot_desc),
     '#required' => TRUE,
   ) ;
   $form['customcssjs_js'] = array(
@@ -98,7 +129,7 @@
     '#default_value' => variable_get('customcssjs_js', $default_js_path),
     '#size' => 50,
     '#maxlength' => 50,
-    '#description' => t('Path relative to default files folder: '. file_directory_path() .'. You may setup this path <a href="/admin/settings/file-system">here</a>.'),
+    '#description' => t('Path relative to ' . $fileroot_desc),
     '#required' => TRUE,
   ) ;
   return system_settings_form($form) ;
@@ -106,12 +137,22 @@
 
 
 function customcssjs_admin_validate($form, &$form_state) {
+  if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
+    if (!$form_state['values']['customcssjs_private_allowed']) {
+      return;
+    }
+    // Directory is in the website root
+    $basecamino = '' ;
+  }
+  else {
+    $basecamino = file_directory_path() . '/' ;
+  }
 
   $css_path = $form_state['values']['customcssjs_css'] ;
-  $css_full_path = file_directory_path() .'/'. $css_path;
+  $css_full_path = $basecamino . $css_path;
   _customcssjs_file_check_directory($css_full_path, 1, 'customcssjs_css');
   $js_path = $form_state['values']['customcssjs_js'] ;
-  $js_full_path = file_directory_path() .'/'.  $js_path;
+  $js_full_path = $basecamino . $js_path;
   _customcssjs_file_check_directory($js_full_path, 1, 'customcssjs_js');
 }
 

