[-] Classes : fix bug PSCFI-3367 - incorrect admin rights for created image folders

This commit is contained in:
tDidierjean committed 2011-09-20 16:58:58 +00:00
1 parent daff11df6b
commit 41e5a8d64e
1 file changed
+9 -6
+9 -6
View File
@@ -56,6 +56,9 @@ class ImageCore extends ObjectModel
/** @var string image path without extension */
protected $existing_path;
/** @var int access rights of created folders (octal) */
protected $access_rights = 0775;
protected $tables = array ('image', 'image_lang');
protected $fieldsRequired = array('id_product');
@@ -511,8 +514,8 @@ class ImageCore extends ObjectModel
if (!file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder()))
{
// Apparently sometimes mkdir cannot set the rights, and sometimes chmod can't. Trying both.
$success = @mkdir(_PS_PROD_IMG_DIR_.$this->getImgFolder(), 0755, true)
|| @chmod(_PS_PROD_IMG_DIR_.$this->getImgFolder(), 0755);
$success = @mkdir(_PS_PROD_IMG_DIR_.$this->getImgFolder(), $access_rights, true)
|| @chmod(_PS_PROD_IMG_DIR_.$this->getImgFolder(), $access_rights);
// Create an index.php file in the new folder
if ($success
@@ -586,8 +589,8 @@ class ImageCore extends ObjectModel
{
if(!file_exists(_PS_PROD_IMG_DIR_.$tmp_folder))
{
@mkdir(_PS_PROD_IMG_DIR_.$tmp_folder, 0755);
@chmod(_PS_PROD_IMG_DIR_.$tmp_folder, 0755);
@mkdir(_PS_PROD_IMG_DIR_.$tmp_folder, $access_rights);
@chmod(_PS_PROD_IMG_DIR_.$tmp_folder, $access_rights);
}
$tmp_path = _PS_PROD_IMG_DIR_.$tmp_folder.basename($file);
if (!@rename($new_path, $tmp_path) || !file_exists($tmp_path))
@@ -618,8 +621,8 @@ class ImageCore extends ObjectModel
}
if (file_exists($test_folder))
return false;
@mkdir($test_folder, 0755, true);
@chmod($test_folder, 0755);
@mkdir($test_folder, $access_rights, true);
@chmod($test_folder, $access_rights);
if (!is_writeable($test_folder))
return false;
@rmdir($test_folder);