Applied adapted Drupal core patch #572516 for sites with mixed public and private files
This commit is contained in:
parent
75c72c4cbb
commit
5c5aaddc78
6 changed files with 35 additions and 27 deletions
|
@ -60,8 +60,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_files = FALSE) {
|
||||
$file_path = file_directory_path($public_files);
|
||||
if (!$dest) {
|
||||
return $file_path;
|
||||
}
|
||||
|
@ -292,8 +292,8 @@ function file_check_location($source, $directory = '') {
|
|||
* @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_files = FALSE) {
|
||||
$dest = file_create_path($dest, $public_files);
|
||||
|
||||
$directory = $dest;
|
||||
$basename = file_check_path($directory);
|
||||
|
@ -413,10 +413,10 @@ function file_destination($destination, $replace) {
|
|||
* @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_files = FALSE) {
|
||||
$path_original = is_object($source) ? $source->filepath : $source;
|
||||
|
||||
if (file_copy($source, $dest, $replace)) {
|
||||
if (file_copy($source, $dest, $replace, $public_files)) {
|
||||
$path_current = is_object($source) ? $source->filepath : $source;
|
||||
|
||||
if ($path_original == $path_current || file_delete($path_original)) {
|
||||
|
@ -874,7 +874,7 @@ function file_validate_image_resolution(&$file, $maximum_dimensions = 0, $minimu
|
|||
*
|
||||
* @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_files = FALSE) {
|
||||
$temp = file_directory_temp();
|
||||
// On Windows, tempnam() requires an absolute path, so we use realpath().
|
||||
$file = tempnam(realpath($temp), 'file');
|
||||
|
@ -885,7 +885,7 @@ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
|
|||
fwrite($fp, $data);
|
||||
fclose($fp);
|
||||
|
||||
if (!file_move($file, $dest, $replace)) {
|
||||
if (!file_move($file, $dest, $replace, $public_files)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -895,7 +895,7 @@ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
|
|||
/**
|
||||
* Set the status of a file.
|
||||
*
|
||||
* @param $file
|
||||
* @param $file
|
||||
* A Drupal file object.
|
||||
* @param $status
|
||||
* A status value to set the file to. One of:
|
||||
|
@ -924,7 +924,7 @@ function file_transfer($source, $headers) {
|
|||
if (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
|
||||
// IE cannot download private files because it cannot store files downloaded
|
||||
// over HTTPS in the browser cache. The problem can be solved by sending
|
||||
// custom headers to IE. See http://support.microsoft.com/kb/323308/en-us
|
||||
|
@ -1150,7 +1150,10 @@ function file_directory_temp() {
|
|||
*
|
||||
* @return A string containing the path to Drupal's 'files' directory.
|
||||
*/
|
||||
function file_directory_path() {
|
||||
function file_directory_path($public_files = FALSE) {
|
||||
if ($public_files) {
|
||||
return variable_get('file_dirpublic_path', 'files');
|
||||
}
|
||||
return variable_get('file_directory_path', conf_path() .'/files');
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue