Commit 9e1c8ede authored by Gábor Hojtsy's avatar Gábor Hojtsy

#119196 by douggreen: apply file API common sense (permissions, file API...

#119196 by douggreen: apply file API common sense (permissions, file API functions instead of custom code) to files handled by color.module
parent ef290770
......@@ -238,12 +238,10 @@ function color_scheme_form_submit($form, &$form_state) {
// Prepare target locations for generated files
$id = $theme .'-'. substr(md5(serialize($palette) . microtime()), 0, 8);
$paths['color'] = variable_get('file_directory_path', 'files') .'/color';
$paths['color'] = file_directory_path() .'/color';
$paths['target'] = $paths['color'] .'/'. $id;
foreach ($paths as $path) {
if (!is_dir($path)) {
mkdir($path);
}
file_check_directory($path, FILE_CREATE_DIRECTORY);
}
$paths['target'] = $paths['target'] .'/';
$paths['id'] = $id;
......@@ -259,7 +257,8 @@ function color_scheme_form_submit($form, &$form_state) {
// Copy over neutral images
foreach ($info['copy'] as $file) {
$base = basename($file);
copy($paths['source'] . $file, $paths['target'] . $base);
$source = $paths['source'] . $file;
file_copy($source, $paths['target'] . $base);
$paths['map'][$file] = $base;
$paths['files'][] = $paths['target'] . $base;
}
......@@ -350,6 +349,9 @@ function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette) {
fwrite($file, $output);
fclose($file);
$paths['files'][] = $paths['stylesheet'];
// Set standard file permissions for webserver-generated files
@chmod($paths['stylesheet'], 0664);
}
/**
......@@ -413,6 +415,9 @@ function _color_render_images($theme, &$info, &$paths, $palette) {
imagedestroy($slice);
$paths['files'][] = $image;
// Set standard file permissions for webserver-generated files
@chmod(realpath($image), 0664);
// Build before/after map of image paths.
$paths['map'][$file] = $base;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment