// MERGE with trunk revision 7754

This commit is contained in:
rMalie
2011-07-27 12:48:42 +00:00
parent 21017fb5d8
commit 233c0076b7
182 changed files with 6179 additions and 1333 deletions
+58 -3
View File
@@ -452,7 +452,17 @@ class ImageCore extends ObjectModel
public function createImgFolder()
{
if (!file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder()))
return @mkdir(_PS_PROD_IMG_DIR_.$this->getImgFolder(), 0755, true);
{
// 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);
// Create an index.php file in the new folder
if ($success
&& !file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder().'index.php')
&& file_exists($this->source_index))
return @copy($this->source_index, _PS_PROD_IMG_DIR_.$this->getImgFolder().'index.php');
}
return true;
}
@@ -511,6 +521,51 @@ class ImageCore extends ObjectModel
}
return $result;
}
}
public static function testFileSystem()
{
$safe_mode = ini_get('safe_mode');
if ($safe_mode)
return false;
$folder1 = _PS_PROD_IMG_DIR_.'testfilesystem/';
$test_folder = $folder1.'testsubfolder/';
if (file_exists($test_folder))
{
@rmdir($test_folder);
@rmdir($folder1);
}
if (file_exists($test_folder))
return false;
@mkdir($test_folder, 0755, true);
@chmod($test_folder, 0755);
if (!is_writeable($test_folder))
return false;
@rmdir($test_folder);
@rmdir($folder1);
if (file_exists($folder1))
return false;
return true;
}
/**
* Returns the path where a product image should be created (without file format)
*
* @return string path
*/
public function getPathForCreation()
{
if (!$this->id)
return false;
if (Configuration::get('PS_LEGACY_IMAGES'))
{
if (!$this->id_product)
return false;
$path = $this->id_product.'-'.$this->id;
}
else
{
$path = $this->getImgPath();
$this->createImgFolder();
}
}
}