// Merge -> revision 8507

This commit is contained in:
rMalie
2011-09-12 16:17:37 +00:00
parent b404900911
commit a1bdb7b35e
67 changed files with 1938 additions and 1509 deletions
+16 -3
View File
@@ -523,12 +523,14 @@ class ImageCore extends ObjectModel
* If max_execution_time is provided, stops before timeout and returns string "timeout".
* If any image cannot be moved, stops and returns "false"
*
* @param int max_execution_time
* @return mixed success or timeout
*/
public static function moveToNewFileSystem($max_execution_time = 0)
{
$start_time = time();
$image = null;
$tmp_folder = 'duplicates/';
foreach (scandir(_PS_PROD_IMG_DIR_) as $file)
{
// matches the base product image or the thumbnails
@@ -537,17 +539,28 @@ class ImageCore extends ObjectModel
// don't recreate an image object for each image type
if (!$image || $image->id !== (int)$matches[2])
$image = new Image((int)$matches[2]);
if (Validate::isLoadedObject($image))
// image exists in DB and with the correct product?
if (Validate::isLoadedObject($image) && $image->id_product == (int)rtrim($matches[1], "-"))
{
// create the new folder if it does not exist
if (!$image->createImgFolder())
return false;
// move the image
// if there's already a file at the new image path, move it to a dump folder
// most likely the preexisting image is a demo image not linked to a product and it's ok to replace it
$new_path = _PS_PROD_IMG_DIR_.$image->getImgPath().(isset($matches[3]) ? $matches[3] : '').'.jpg';
if (file_exists($new_path))
{
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);
}
$tmp_path = _PS_PROD_IMG_DIR_.$tmp_folder.basename($file);
if (!@rename($new_path, $tmp_path) || !file_exists($tmp_path))
return false;
}
// move the image
if (!@rename(_PS_PROD_IMG_DIR_.$file, $new_path) || !file_exists($new_path))
return false;
}
+9 -1
View File
@@ -393,9 +393,17 @@ class ProductCore extends ObjectModel
if (!parent::add($autodate, $nullValues))
return false;
$this->setStock($this->quantity);
Module::hookExec('afterSaveProduct', array('id_product' => $this->id));
return true;
}
public function update($nullValues = false)
{
$return = parent::update($nullValues);
Module::hookExec('afterSaveProduct', array('id_product' => $this->id));
return $return;
}
/**
* Check then return multilingual fields for database interaction
*
@@ -3567,4 +3575,4 @@ class ProductCore extends ObjectModel
return isset($row['reference']);
}
}
}
+2 -4
View File
@@ -1941,15 +1941,13 @@ FileETag INode MTime Size
case 'by' :
$orderByPrefix = '';
if($prefix) {
if ($value == 'id_product' OR $value == 'date_add')
if ($value == 'id_product' || $value == 'date_add' || $value == 'price')
$orderByPrefix = 'p.';
elseif ($value == 'name')
$orderByPrefix = 'pl.';
elseif ($value == 'manufacturer')
{
$orderByPrefix = 'm.';
}
elseif ($value == 'position')
elseif ($value == 'position' || empty($value))
$orderByPrefix = 'cp.';
}
+7
View File
@@ -40,6 +40,7 @@ class UpgraderCore{
public $version_num;
public $link;
public $autoupgrade;
public $autoupgrade_module;
public $changelog;
public $md5;
@@ -95,6 +96,7 @@ class UpgraderCore{
{
if (empty($this->link))
{
$lastCheck = Configuration::get('PS_LAST_VERSION_CHECK');
// if we use the autoupgrade process, we will never refresh it
// except if no check has been done before
@@ -103,12 +105,14 @@ class UpgraderCore{
libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3))));
if ($feed = @simplexml_load_file($this->rss_version_link))
{
$this->version_name = (string)$feed->version->name;
$this->version_num = (string)$feed->version->num;
$this->link = (string)$feed->download->link;
$this->md5 = (string)$feed->download->md5;
$this->changelog = (string)$feed->download->changelog;
$this->autoupgrade = (int)$feed->autoupgrade;
$this->autoupgrade_module = (int)$feed->autoupgrade_module;
$this->desc = (string)$feed->desc ;
$configLastVersion = array(
'name' => $this->version_name,
@@ -116,9 +120,11 @@ class UpgraderCore{
'link' => $this->link,
'md5' => $this->md5,
'autoupgrade' => $this->autoupgrade,
'autoupgrade_module' => $this->autoupgrade_module,
'changelog' => $this->changelog,
'desc' => $this->desc
);
Configuration::updateValue('PS_LAST_VERSION',serialize($configLastVersion));
Configuration::updateValue('PS_LAST_VERSION_CHECK',time());
}
@@ -130,6 +136,7 @@ class UpgraderCore{
$this->version_num = $lastVersionCheck['num'];
$this->link = $lastVersionCheck['link'];
$this->autoupgrade = $lastVersionCheck['autoupgrade'];
$this->autoupgrade_module = $lastVersionCheck['autoupgrade_module'];
$this->md5 = $lastVersionCheck['md5'];
$this->desc = $lastVersionCheck['desc'];
$this->changelog = $lastVersionCheck['changelog'];