/////////////////////////////////////////////////
repo:    drupal-6.15
target:  core patch
branch:  6.x
tags:    6.x-1.5
node:    4996b48762956776df317f4b5e995f7e1627f0c2
changes:
* core patch #572516: private download -base- file API
* core patch #572516: private download -case 1- optimize CSS/JS
* core patch #572516: private download -case 2- JS translation
* core patch #572516: private download -case 3- color module
/////////////////////////////////////////////////
=================================================
message: core patch #572516: private download -base- file API
branch:  6.x
tags:    
node:    eb0daf921c4b4bb3a5d5b9d02d50b30d6764441d
=================================================
diff -r 4996b4876295 -r eb0daf921c4b includes/file.inc
--- includes/file.inc	Sun Jan 31 19:52:12 2010 -0500
+++ includes/file.inc	Sun Jan 31 20:07:16 2010 -0500
@@ -61,8 +61,8 @@ function file_create_url($path) {
  *   appended if necessary, or FALSE if the path is invalid (i.e. outside the
  *   configured 'files' or temp directories).
  */
-function file_create_path($dest = 0) {
-  $file_path = file_directory_path();
+function file_create_path($dest = 0, $public_misc = FALSE) { // core patch #572516(base)
+  $file_path = file_directory_path($public_misc); // core patch #572516(base)
   if (!$dest) {
     return $file_path;
   }
@@ -213,8 +213,8 @@ function file_check_location($source, $d
  *   - FILE_EXISTS_ERROR - Do nothing and return FALSE.
  * @return True for success, FALSE for failure.
  */
-function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
-  $dest = file_create_path($dest);
+function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME, $public_misc = FALSE) { // core patch #572516(base)
+  $dest = file_create_path($dest, $public_misc); // core patch #572516(base)
 
   $directory = $dest;
   $basename = file_check_path($directory);
@@ -327,10 +327,10 @@ function file_destination($destination, 
  *   - FILE_EXISTS_ERROR - Do nothing and return FALSE.
  * @return True for success, FALSE for failure.
  */
-function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
+function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME, $public_misc = FALSE) { // core patch #572516(base)
   $path_original = is_object($source) ? $source->filepath : $source;
 
-  if (file_copy($source, $dest, $replace)) {
+  if (file_copy($source, $dest, $replace, $public_misc)) { // core patch #572516(base)
     $path_current = is_object($source) ? $source->filepath : $source;
 
     if ($path_original == $path_current || file_delete($path_original)) {
@@ -757,7 +757,7 @@ function file_validate_image_resolution(
  *
  * @return A string containing the resulting filename or 0 on error
  */
-function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
+function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME, $public_misc = FALSE) { // core patch #572516(base)
   $temp = file_directory_temp();
   // On Windows, tempnam() requires an absolute path, so we use realpath().
   $file = tempnam(realpath($temp), 'file');
@@ -768,7 +768,7 @@ function file_save_data($data, $dest, $r
   fwrite($fp, $data);
   fclose($fp);
 
-  if (!file_move($file, $dest, $replace)) {
+  if (!file_move($file, $dest, $replace, $public_misc)) { // core patch #572516(base)
     return 0;
   }
 
@@ -967,7 +967,8 @@ function file_directory_temp() {
  *
  * @return A string containing the path to Drupal's 'files' directory.
  */
-function file_directory_path() {
+function file_directory_path($public_misc = FALSE) { // core patch #572516(base)
+  if ($public_misc) return variable_get('file_directory_path:public_misc', 'misc/dynamic'); // core patch #572516(base)
   return variable_get('file_directory_path', conf_path() .'/files');
 }
 
=================================================
message: core patch #572516: private download -case 1- optimize CSS/JS
branch:  6.x
tags:    
node:    3f9661a33a47658470513caca0054316b1a35065
=================================================
diff -r eb0daf921c4b -r 3f9661a33a47 includes/common.inc
--- includes/common.inc	Sun Jan 31 20:07:16 2010 -0500
+++ includes/common.inc	Sun Jan 31 20:18:52 2010 -0500
@@ -1836,8 +1836,8 @@ function drupal_get_css($css = NULL) {
   $no_theme_preprocess = '';
 
   $preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
-  $directory = file_directory_path();
-  $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
+  $directory = file_directory_path(TRUE); // core patch #572516(case 1)
+  $is_writable = is_dir($directory) && is_writable($directory); // core patch #572516(case 1)
 
   // A dummy query-string is added to filenames, to gain control over
   // browser-caching. The string changes on every update or full cache
@@ -1912,7 +1912,7 @@ function drupal_build_css_cache($types, 
   $data = '';
 
   // Create the css/ within the files folder.
-  $csspath = file_create_path('css');
+  $csspath = file_create_path('css', TRUE); // core patch #572516(case 1)
   file_check_directory($csspath, FILE_CREATE_DIRECTORY);
 
   if (!file_exists($csspath .'/'. $filename)) {
@@ -1938,7 +1938,7 @@ function drupal_build_css_cache($types, 
     $data = implode('', $matches[0]) . $data;
 
     // Create the CSS file.
-    file_save_data($data, $csspath .'/'. $filename, FILE_EXISTS_REPLACE);
+    file_save_data($data, $csspath .'/'. $filename, FILE_EXISTS_REPLACE, TRUE); // core patch #572516(case 1)
   }
   return $csspath .'/'. $filename;
 }
@@ -2038,7 +2038,7 @@ function _drupal_load_stylesheet($matche
  * Delete all cached CSS files.
  */
 function drupal_clear_css_cache() {
-  file_scan_directory(file_create_path('css'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE);
+  file_scan_directory(file_create_path('css', TRUE), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE); // core patch #572516(case 1)
 }
 
 /**
@@ -2189,8 +2189,8 @@ function drupal_get_js($scope = 'header'
   $no_preprocess = array('core' => '', 'module' => '', 'theme' => '');
   $files = array();
   $preprocess_js = (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
-  $directory = file_directory_path();
-  $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
+  $directory = file_directory_path(TRUE); // core patch #572516(case 1)
+  $is_writable = is_dir($directory) && is_writable($directory); // core patch #572516(case 1)
 
   // A dummy query-string is added to filenames, to gain control over
   // browser-caching. The string changes on every update or full cache
@@ -2391,7 +2391,7 @@ function drupal_build_js_cache($files, $
   $contents = '';
 
   // Create the js/ within the files folder.
-  $jspath = file_create_path('js');
+  $jspath = file_create_path('js', TRUE); // core patch #572516(case 1)
   file_check_directory($jspath, FILE_CREATE_DIRECTORY);
 
   if (!file_exists($jspath .'/'. $filename)) {
@@ -2404,7 +2404,7 @@ function drupal_build_js_cache($files, $
     }
 
     // Create the JS file.
-    file_save_data($contents, $jspath .'/'. $filename, FILE_EXISTS_REPLACE);
+    file_save_data($contents, $jspath .'/'. $filename, FILE_EXISTS_REPLACE, TRUE); // core patch #572516(case 1)
   }
 
   return $jspath .'/'. $filename;
@@ -2414,7 +2414,7 @@ function drupal_build_js_cache($files, $
  * Delete all cached JS files.
  */
 function drupal_clear_js_cache() {
-  file_scan_directory(file_create_path('js'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE);
+  file_scan_directory(file_create_path('js', TRUE), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE); // core patch #572516(case 1)
   variable_set('javascript_parsed', array());
 }
 
diff -r eb0daf921c4b -r 3f9661a33a47 modules/system/system.admin.inc
--- modules/system/system.admin.inc	Sun Jan 31 20:07:16 2010 -0500
+++ modules/system/system.admin.inc	Sun Jan 31 20:18:52 2010 -0500
@@ -1319,11 +1319,11 @@ function system_performance_settings() {
   $form['bandwidth_optimizations'] = array(
     '#type' => 'fieldset',
     '#title' => t('Bandwidth optimizations'),
-    '#description' => t('<p>Drupal can automatically optimize external resources like CSS and JavaScript, which can reduce both the size and number of requests made to your website. CSS files can be aggregated and compressed into a single file, while JavaScript files are aggregated (but not compressed). These optional optimizations may reduce server load, bandwidth requirements, and page loading times.</p><p>These options are disabled if you have not set up your files directory, or if your download method is set to private.</p>')
+    '#description' => t('<p>Drupal can automatically optimize external resources like CSS and JavaScript, which can reduce both the size and number of requests made to your website. CSS files can be aggregated and compressed into a single file, while JavaScript files are aggregated (but not compressed). These optional optimizations may reduce server load, bandwidth requirements, and page loading times.</p><p>These options are disabled if you have not set up your files directory, or if your download method is set to private and directory %public_misc does not exists or isn\'t writable.</p>', array('%public_misc' => variable_get('file_directory_path:public_misc', 'misc/dynamic'))) // core patch #572516(case 1)
   );
 
-  $directory = file_directory_path();
-  $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
+  $directory = file_directory_path(0, TRUE); // core patch #572516(case 1)
+  $is_writable = is_dir($directory) && is_writable($directory); // core patch #572516(case 1)
   $form['bandwidth_optimizations']['preprocess_css'] = array(
     '#type' => 'radios',
     '#title' => t('Optimize CSS files'),
=================================================
message: core patch #572516: private download -case 2- JS translation
branch:  6.x
tags:    
node:    2faa53a0830a81587fcbfbe756da72b9a1b62f4c
=================================================
diff -r 3f9661a33a47 -r 2faa53a0830a includes/locale.inc
--- includes/locale.inc	Sun Jan 31 20:18:52 2010 -0500
+++ includes/locale.inc	Sun Jan 31 20:28:43 2010 -0500
@@ -2181,7 +2181,7 @@ function _locale_rebuild_js($langcode = 
 
   // Construct the filepath where JS translation files are stored.
   // There is (on purpose) no front end to edit that variable.
-  $dir = file_create_path(variable_get('locale_js_directory', 'languages'));
+  $dir = file_create_path(variable_get('locale_js_directory', 'languages'), TRUE); // core patch #572516(case 2)
 
   // Delete old file, if we have no translations anymore, or a different file to be saved.
   if (!empty($language->javascript) && (!$data || $language->javascript != $data_hash)) {
@@ -2197,7 +2197,7 @@ function _locale_rebuild_js($langcode = 
 
     // Save the file.
     $dest = $dir .'/'. $language->language .'_'. $data_hash .'.js';
-    if (file_save_data($data, $dest)) {
+    if (file_save_data($data, $dest, FILE_EXISTS_REPLACE, TRUE)) { // core patch #572516(case 2)
       $language->javascript = $data_hash;
       $status = ($status == 'deleted') ? 'updated' : 'created';
     }
diff -r 3f9661a33a47 -r 2faa53a0830a modules/locale/locale.module
--- modules/locale/locale.module	Sun Jan 31 20:18:52 2010 -0500
+++ modules/locale/locale.module	Sun Jan 31 20:28:43 2010 -0500
@@ -487,7 +487,7 @@ function locale_system_update($component
 function locale_update_js_files() {
   global $language;
 
-  $dir = file_create_path(variable_get('locale_js_directory', 'languages'));
+  $dir = file_create_path(variable_get('locale_js_directory', 'languages'), TRUE); // core patch #572516(case 2)
   $parsed = variable_get('javascript_parsed', array());
 
   // The first three parameters are NULL in order to get an array with all
=================================================
message: core patch #572516: private download -case 3- color module
branch:  6.x
tags:    tip
node:    d36195f49f2e3a6a7c223c305f72b1cd476feeb9
=================================================
diff -r 2faa53a0830a -r d36195f49f2e modules/color/color.module
--- modules/color/color.module	Sun Jan 31 20:28:43 2010 -0500
+++ modules/color/color.module	Sun Jan 31 20:33:18 2010 -0500
@@ -32,22 +32,17 @@ function color_theme() {
 function color_form_alter(&$form, $form_state, $form_id) {
   // Insert the color changer into the theme settings page.
   if ($form_id == 'system_theme_settings' && color_get_info(arg(4)) && function_exists('gd_info')) {
-    if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) {
-      // Disables the color changer when the private download method is used.
-      // TODO: This should be solved in a different way. See issue #181003.
-      drupal_set_message(t('The color picker only works if the <a href="@url">download method</a> is set to public.', array('@url' => url('admin/settings/file-system'))), 'warning');
-    }
-    else {
-      $form['color'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Color scheme'),
-        '#weight' => -1,
-        '#attributes' => array('id' => 'color_scheme_form'),
-        '#theme' => 'color_scheme_form',
-      );
-      $form['color'] += color_scheme_form($form_state, arg(4));
-      $form['#submit'][] = 'color_scheme_form_submit';
-    }
+    // core patch #572516(case 3)
+    // same old code, but without taking care of download method
+    $form['color'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Color scheme'),
+      '#weight' => -1,
+      '#attributes' => array('id' => 'color_scheme_form'),
+      '#theme' => 'color_scheme_form',
+    );
+    $form['color'] += color_scheme_form($form_state, arg(4));
+    $form['#submit'][] = 'color_scheme_form_submit';
   }
 
   // Use the generated screenshot in the theme list.
@@ -294,7 +289,7 @@ function color_scheme_form_submit($form,
 
   // Prepare target locations for generated files.
   $id = $theme .'-'. substr(md5(serialize($palette) . microtime()), 0, 8);
-  $paths['color'] = file_directory_path() .'/color';
+  $paths['color'] = file_directory_path(TRUE) .'/color'; // core patch #572516(case 3)
   $paths['target'] = $paths['color'] .'/'. $id;
   foreach ($paths as $path) {
     file_check_directory($path, FILE_CREATE_DIRECTORY);
@@ -312,7 +307,7 @@ function color_scheme_form_submit($form,
   foreach ($info['copy'] as $file) {
     $base = basename($file);
     $source = $paths['source'] . $file;
-    file_copy($source, $paths['target'] . $base);
+    file_copy($source, $paths['target'] . $base, FILE_EXISTS_REPLACE, TRUE); // core patch #572516(case 3)
     $paths['map'][$file] = $base;
     $paths['files'][] = $paths['target'] . $base;
   }
@@ -442,7 +437,7 @@ function _color_rewrite_stylesheet($them
 function _color_save_stylesheet($file, $style, &$paths) {
 
   // Write new stylesheet.
-  file_save_data($style, $file, FILE_EXISTS_REPLACE);
+  file_save_data($style, $file, FILE_EXISTS_REPLACE, TRUE); // core patch #572516(case 3)
   $paths['files'][] = $file;
 
   // Set standard file permissions for webserver-generated files.
/////////////////////////////////////////////////
generated with: drudiff drupal-6.15 . 217 218 219 220 221 
/////////////////////////////////////////////////
