//// Merge -> revision 8290
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8295 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1151,7 +1151,10 @@ class CartCore extends ObjectModel
|
||||
$tmp = $shipping;
|
||||
|
||||
if ($shipping <= $tmp)
|
||||
{
|
||||
$id_carrier = (int)($row['id_carrier']);
|
||||
$tmp = $shipping;
|
||||
}
|
||||
}
|
||||
else // by price
|
||||
{
|
||||
@@ -1161,10 +1164,13 @@ class CartCore extends ObjectModel
|
||||
$tmp = $shipping;
|
||||
|
||||
if ($shipping <= $tmp)
|
||||
{
|
||||
$id_carrier = (int)($row['id_carrier']);
|
||||
$tmp = $shipping;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($id_carrier))
|
||||
$id_carrier = Configuration::get('PS_CARRIER_DEFAULT');
|
||||
|
||||
@@ -78,6 +78,8 @@ class HelperCore
|
||||
$html .= 'var selectedCat = "'.implode(',', $selected_cat).'"';
|
||||
else
|
||||
$html .= 'var selectedCat = "'.implode(',', array_keys($selected_cat)).'"';
|
||||
} else {
|
||||
$html .= 'var selectedCat = ""';
|
||||
}
|
||||
$html .= '
|
||||
var selectedLabel = \''.$trads['selected'].'\';
|
||||
|
||||
@@ -360,14 +360,14 @@ class ManufacturerCore extends ObjectModel
|
||||
$ids = array();
|
||||
foreach ($id_addresses as $id)
|
||||
$ids[] = (int)$id['id'];
|
||||
$result1 = (Db::getInstance()->ExecuteS('
|
||||
$result1 = (Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'address`
|
||||
SET id_manufacturer = 0
|
||||
WHERE id_manufacturer = '.(int)$this->id.'
|
||||
AND deleted = 0') !== false);
|
||||
$result2 = true;
|
||||
if (count($ids))
|
||||
$result2 = (Db::getInstance()->ExecuteS('
|
||||
$result2 = (Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'address`
|
||||
SET id_customer = 0, id_supplier = 0, id_manufacturer = '.(int)$this->id.'
|
||||
WHERE id_address IN('.implode(',', $ids).')
|
||||
|
||||
+4
-1
@@ -427,7 +427,10 @@ class OrderCore extends ObjectModel
|
||||
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
||||
$row['product_price'] = ($row['product_price'] - $row['product_price'] * ($row['reduction_percent'] * 0.01));
|
||||
else
|
||||
$row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $row['product_price_wt'] * ($row['reduction_percent'] * 0.01)), 2);
|
||||
{
|
||||
$reduction = Tools::ps_round($row['product_price_wt'] * ($row['reduction_percent'] * 0.01), 2);
|
||||
$row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $reduction), 2);
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['reduction_amount'] != 0)
|
||||
|
||||
+23
-10
@@ -249,7 +249,7 @@ class ProductCore extends ObjectModel
|
||||
'cache_has_attachments' => 'isBool'
|
||||
);
|
||||
protected $fieldsRequiredLang = array('link_rewrite', 'name');
|
||||
/* Description short is limited to 400 chars (but can be configured in Preferences Tab), but without html, so it can't be generic */
|
||||
/* Description short is limited to 800 chars (but can be configured in Preferences Tab), but without html, so it can't be generic */
|
||||
protected $fieldsSizeLang = array('meta_description' => 255, 'meta_keywords' => 255,
|
||||
'meta_title' => 128, 'link_rewrite' => 128, 'name' => 128, 'available_now' => 255, 'available_later' => 255);
|
||||
protected $fieldsValidateLang = array(
|
||||
@@ -550,14 +550,14 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$limit = (int)Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT');
|
||||
if ($limit <= 0)
|
||||
$limit = 400;
|
||||
$limit = 800;
|
||||
if (!is_array($this->description_short))
|
||||
$this->description_short = array();
|
||||
foreach ($this->description_short as $k => $value)
|
||||
if (Tools::strlen(strip_tags($value)) > $limit)
|
||||
{
|
||||
if ($die) die (Tools::displayError().' ('.get_class($this).'->description: length > '.$limit.' for language '.$k.')');
|
||||
return $errorReturn ? get_class($this).'->'.Tools::displayError('description: length >').' '.$limit.' '.Tools::displayError('for language').' '.$k : false;
|
||||
if ($die) die (Tools::displayError().' ('.get_class($this).'->description_short: length > '.$limit.' for language '.$k.')');
|
||||
return $errorReturn ? get_class($this).'->'.Tools::displayError('description_short: length >').' '.$limit.' '.Tools::displayError('for language').' '.$k : false;
|
||||
}
|
||||
return parent::validateFieldsLang($die, $errorReturn);
|
||||
}
|
||||
@@ -1676,13 +1676,26 @@ class ProductCore extends ObjectModel
|
||||
$cart_quantity = 0;
|
||||
if ((int)($id_cart))
|
||||
{
|
||||
if (!isset(self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)]) OR self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)] != (int)($quantity))
|
||||
self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
$condition = '';
|
||||
$cache_name = (int)($id_cart).'_'.(int)($id_product);
|
||||
|
||||
if(Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION'))
|
||||
{
|
||||
$cache_name = (int)($id_cart).'_'.(int)($id_product).'_'.(int)($id_product_attribute);
|
||||
$condition = ' AND `id_product_attribute` = '.(int)($id_product_attribute);
|
||||
}
|
||||
|
||||
if (!isset(self::$_cart_quantity[$cache_name]) OR self::$_cart_quantity[$cache_name] != (int)($quantity))
|
||||
{
|
||||
self::$_cart_quantity[$cache_name] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT SUM(`quantity`)
|
||||
FROM `'._DB_PREFIX_.'cart_product`
|
||||
WHERE `id_product` = '.(int)($id_product).' AND `id_cart` = '.(int)($id_cart)
|
||||
WHERE `id_product` = '.(int)($id_product).'
|
||||
AND `id_cart` = '.(int)($id_cart).' '.$condition
|
||||
);
|
||||
$cart_quantity = self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)];
|
||||
|
||||
$cart_quantity = self::$_cart_quantity[$cache_name];
|
||||
}
|
||||
}
|
||||
$quantity = ($id_cart AND $cart_quantity) ? $cart_quantity : $quantity;
|
||||
$id_currency = (int)(Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
@@ -3402,10 +3415,10 @@ class ProductCore extends ObjectModel
|
||||
*/
|
||||
public function setCoverWs($id_image)
|
||||
{
|
||||
Db::getInstance()->ExecuteS('UPDATE `'._DB_PREFIX_.'image`
|
||||
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `cover` = 0 WHERE `id_product` = '.(int)($this->id).'
|
||||
');
|
||||
Db::getInstance()->ExecuteS('UPDATE `'._DB_PREFIX_.'image`
|
||||
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `cover` = 1 WHERE `id_product` = '.(int)($this->id).' AND `id_image` = '.(int)$id_image);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,8 @@ class ProductDownloadCore extends ObjectModel
|
||||
public function delete($deleteFile=false)
|
||||
{
|
||||
if ($deleteFile)
|
||||
$this->deleteFile();
|
||||
return $this->deleteFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
|
||||
@@ -138,7 +138,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
AND
|
||||
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
||||
)
|
||||
ORDER BY `score` DESC, `from_quantity` DESC');
|
||||
ORDER BY `from_quantity` DESC, `score` DESC, `from_quantity` DESC');
|
||||
}
|
||||
return self::$_specificPriceCache[$key];
|
||||
}
|
||||
@@ -192,19 +192,20 @@ class SpecificPriceCore extends ObjectModel
|
||||
AND
|
||||
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
||||
)
|
||||
ORDER BY `score` DESC, `from_quantity` DESC
|
||||
ORDER BY `from_quantity` DESC, `score` DESC
|
||||
');
|
||||
|
||||
$targeted_prices = array();
|
||||
$max_score = NULL;
|
||||
$last_quantity = NULL;
|
||||
|
||||
foreach($res as $specific_price)
|
||||
{
|
||||
if (!isset($max_score))
|
||||
$max_score = $specific_price['score'];
|
||||
else if ($max_score != $specific_price['score'])
|
||||
if (!isset($last_quantity))
|
||||
$last_quantity = $specific_price['from_quantity'];
|
||||
else if ($last_quantity == $specific_price['from_quantity'])
|
||||
break;
|
||||
|
||||
$last_quantity = $specific_price['from_quantity'];
|
||||
if ($specific_price['from_quantity'] > 1)
|
||||
$targeted_prices[] = $specific_price;
|
||||
}
|
||||
|
||||
+7
-7
@@ -1162,15 +1162,19 @@ class ToolsCore
|
||||
return self::$file_exists_cache[$filename];
|
||||
}
|
||||
|
||||
public static function file_get_contents($url, $useIncludePath = false, $streamContext = NULL)
|
||||
public static function file_get_contents($url, $useIncludePath = false, $streamContext = NULL, $curlTimeOut = 5)
|
||||
{
|
||||
if ($streamContext == NULL)
|
||||
$streamContext = stream_context_create(array('http' => array('timeout' => 5)));
|
||||
|
||||
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
|
||||
return file_get_contents($url, $useIncludePath, $streamContext);
|
||||
else if (function_exists('curl_init'))
|
||||
return @file_get_contents($url, $useIncludePath, $streamContext);
|
||||
elseif (function_exists('curl_init') && in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $curlTimeOut);
|
||||
$content = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $content;
|
||||
@@ -1182,11 +1186,7 @@ class ToolsCore
|
||||
public static function simplexml_load_file($url, $class_name = null)
|
||||
{
|
||||
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
|
||||
return simplexml_load_file($url, $class_name);
|
||||
elseif (function_exists('curl_init'))
|
||||
{
|
||||
return simplexml_load_string(Tools::file_get_contents($url), $class_name);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
+17
-1
@@ -366,7 +366,7 @@ class ValidateCore
|
||||
*/
|
||||
public static function isCleanHtml($html)
|
||||
{
|
||||
$jsEvent = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave';
|
||||
$jsEvent = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror';
|
||||
return (!preg_match('/<[ \t\n]*script/i', $html) && !preg_match('/<?.*('.$jsEvent.')[ \t\n]*=/i', $html) && !preg_match('/.*script\:/i', $html));
|
||||
}
|
||||
|
||||
@@ -675,6 +675,22 @@ class ValidateCore
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function isMySQLEngine($engine)
|
||||
{
|
||||
return (in_array($engine, array('InnoDB', 'MyISAM')));
|
||||
}
|
||||
|
||||
public static function isUnixName($data)
|
||||
{
|
||||
return preg_match('/^[a-z0-9_-]+$/ui', $data);
|
||||
}
|
||||
|
||||
public static function isTablePrefix($data)
|
||||
{
|
||||
// Even if "-" is theorically allowed, it will be considered a syntax error if you do not add backquotes (`) around the table name
|
||||
return preg_match('/^[a-z0-9_]+$/ui', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for standard name file validity
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user