// Merge -> revision 8800

This commit is contained in:
rMalie
2011-09-27 14:30:06 +00:00
parent cde0690abc
commit 91083e190c
110 changed files with 1240 additions and 1066 deletions
+2 -2
View File
@@ -844,7 +844,7 @@ abstract class AdminTabCore
if (!Validate::isDate($value[0]))
$this->_errors[] = Tools::displayError('\'from:\' date format is invalid (YYYY-MM-DD)');
else
$sqlFilter .= ' AND '.pSQL($key).' >= \''.pSQL(Tools::dateFrom($value[0])).'\'';
$sqlFilter .= ' AND `'.bqSQL($key).'` >= \''.pSQL(Tools::dateFrom($value[0])).'\'';
}
if (isset($value[1]) AND !empty($value[1]))
@@ -852,7 +852,7 @@ abstract class AdminTabCore
if (!Validate::isDate($value[1]))
$this->_errors[] = Tools::displayError('\'to:\' date format is invalid (YYYY-MM-DD)');
else
$sqlFilter .= ' AND '.pSQL($key).' <= \''.pSQL(Tools::dateTo($value[1])).'\'';
$sqlFilter .= ' AND `'.bqSQL($key).'` <= \''.pSQL(Tools::dateTo($value[1])).'\'';
}
}
else
+21 -20
View File
@@ -417,10 +417,11 @@ class CartCore extends ObjectModel
IF (IFNULL(pa.`supplier_reference`, \'\') = \'\', p.`supplier_reference`, pa.`supplier_reference`) AS supplier_reference,
(p.`weight`+ pa.`weight`) weight_attribute,
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13, IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
pai.`id_image` as pai_id_image, IFNULL(pa.`minimal_quantity`, p.`minimal_quantity`) as minimal_quantity, pa.`ecotax` AS ecotax_attr');
pai.`id_image` as pai_id_image, il.`legend` as pai_legend, IFNULL(pa.`minimal_quantity`, p.`minimal_quantity`) as minimal_quantity, pa.`ecotax` AS ecotax_attr');
$sql->leftJoin('product_attribute pa ON pa.`id_product_attribute` = cp.`id_product_attribute`');
$sql->leftJoin('product_attribute_image pai ON pai.`id_product_attribute` = pa.`id_product_attribute`');
$sql->leftJoin('image_lang il ON il.id_image = pai.id_image AND il.id_lang = '.(int)$this->id_lang);
}
else
$sql->select('p.`reference` AS reference, p.`supplier_reference` AS supplier_reference, p.`ean13`, p.`upc` AS upc, p.`minimal_quantity` AS minimal_quantity');
@@ -465,30 +466,29 @@ class CartCore extends ObjectModel
$row['price'] = Product::getPriceStatic((int)$row['id_product'], false, (int)$row['id_product_attribute'], 6, NULL, false, true, $row['cart_quantity'], false, ((int)($this->id_customer) ? (int)($this->id_customer) : NULL), (int)($this->id), ((int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) ? (int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) : NULL), $specificPriceOutput);
$row['price_wt'] = Product::getPriceStatic((int)$row['id_product'], true, (int)$row['id_product_attribute'], 2, NULL, false, true, $row['cart_quantity'], false, ((int)($this->id_customer) ? (int)($this->id_customer) : NULL), (int)($this->id), ((int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) ? (int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) : NULL));
/* In case when you use QuantityDiscount, getPriceStatic() can be return more of 2 decimals */
// In case when you use QuantityDiscount, getPriceStatic() can be return more of 2 decimals
$row['price_wt'] = Tools::ps_round($row['price_wt'], 2);
$row['total_wt'] = $row['price_wt'] * (int)($row['cart_quantity']);
$row['total'] = Tools::ps_round($row['price'] * (int)($row['cart_quantity']), 2);
}
$row2 = Db::getInstance()->getRow('
SELECT i.`id_image`, il.`legend`
FROM `'._DB_PREFIX_.'image` i
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
WHERE '.((isset($row['`pai_id_image`']) AND $row['`pai_id_image`'])
? 'i.`id_image` = (
SELECT i2.`id_image`
FROM `'._DB_PREFIX_.'image` i2
INNER JOIN `'._DB_PREFIX_.'product_attribute_image` pai2 ON (pai2.`id_image` = i2.`id_image`)
WHERE i2.`id_product` = p.`id_product` AND pai2.`id_product_attribute` = pa.`id_product_attribute`
ORDER BY i2.`position`
LIMIT 1
)'
: 'i.`id_product` = '.(int)$row['id_product'].' AND i.`cover` = 1').'
');
if (!$row2)
$row2 = array('id_image' => false, 'legend' => false);
$row = array_merge($row, $row2);
if (!isset($row['pai_id_image']))
{
$row2 = Db::getInstance()->getRow('
SELECT i.`id_image`, il.`legend`
FROM `'._DB_PREFIX_.'image` i
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
WHERE i.`id_product` = '.(int)$row['id_product'].' AND i.`cover` = 1');
if (!$row2)
$row2 = array('id_image' => false, 'legend' => false);
else
$row = array_merge($row, $row2);
}
else
{
$row['id_image'] = $row['pai_id_image'];
$row['legend'] = $row['pai_legend'];
}
$row['reduction_applies'] = ($specificPriceOutput AND (float)$specificPriceOutput['reduction']);
$row['quantity_discount_applies'] = ($specificPriceOutput AND $row['cart_quantity'] >= (int)$specificPriceOutput['from_quantity']);
@@ -500,6 +500,7 @@ class CartCore extends ObjectModel
$this->_products[] = $row;
}
return $this->_products;
}
+2 -2
View File
@@ -674,7 +674,7 @@ class CategoryCore extends ObjectModel
FROM `'._DB_PREFIX_.'category` c3
WHERE c3.`nleft` > c.`nleft`
AND c3.`nright` < c.`nright`
AND c3.`id_category` IN ('.$selectedCat.')
AND c3.`id_category` IN ('.array_map('intval', $selectedCat).')
)' : '0').' AS nbSelectedSubCat
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.$shop->sqlLang('cl').'
@@ -1123,7 +1123,7 @@ class CategoryCore extends ObjectModel
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->sqlLang('cl').')
WHERE cl.`id_lang` = '.(int)$id_lang.'
AND c.`id_category` IN ('.implode(',', $ids_category).')
AND c.`id_category` IN ('.implode(',', array_map('intval', $ids_category)).')
');
foreach($results as $category)
+25 -25
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -28,16 +28,16 @@
abstract class ModuleGraphCore extends Module
{
protected $_employee;
/** @var integer array graph data */
protected $_values = array();
/** @var string array graph legends (X axis) */
protected $_legend = array();
/**@var string graph titles */
protected $_titles = array('main' => NULL, 'x' => NULL, 'y' => NULL);
/** @var ModuleGraphEngine graph engine */
protected $_render;
@@ -58,7 +58,7 @@ abstract class ModuleGraphCore extends Module
// Get dates in a manageable format
$fromArray = getdate(strtotime($this->_employee->stats_date_from));
$toArray = getdate(strtotime($this->_employee->stats_date_to));
// If the granularity is inferior to 1 day
if ($this->_employee->stats_date_from == $this->_employee->stats_date_to)
{
@@ -156,11 +156,11 @@ abstract class ModuleGraphCore extends Module
$this->setAllTimeValues($layers);
}
}
protected function csvExport($datas)
{
$context = Context::getContext();
$this->setEmployee($context->employee->id);
$this->setLang($context->language->id);
@@ -168,7 +168,7 @@ abstract class ModuleGraphCore extends Module
if (isset($datas['option']))
$this->setOption($datas['option'], $layers);
$this->getData($layers);
// @todo use native CSV PHP functions ?
// Generate first line (column titles)
if (is_array($this->_titles['main']))
@@ -191,7 +191,7 @@ abstract class ModuleGraphCore extends Module
$total += (is_array($this->_values[$i]) ? $this->_values[$i][$key] : $this->_values[$key]);
foreach ($this->_legend AS $key => $legend)
{
$this->_csv .= $legend.';';
$this->_csv .= $legend.';';
for ($i = 0; $i < (is_array($this->_titles['main']) ? sizeof($this->_values) : 1); ++$i)
{
if (!isset($this->_values[$i]) || !is_array($this->_values[$i]))
@@ -219,7 +219,7 @@ abstract class ModuleGraphCore extends Module
}
$this->_displayCsv();
}
protected function _displayCsv()
{
ob_end_clean();
@@ -228,33 +228,33 @@ abstract class ModuleGraphCore extends Module
echo $this->_csv;
exit;
}
public function create($render, $type, $width, $height, $layers)
{
if (!Tools::file_exists_cache($file = dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php'))
die(Tools::displayError());
require_once($file);
$this->_render = new $render($type);
$this->getData($layers);
$this->_render->createValues($this->_values);
$this->_render->setSize($width, $height);
$this->_render->setLegend($this->_legend);
$this->_render->setTitles($this->_titles);
}
public function draw()
{
$this->_render->draw();
}
/**
* @todo Set this method as abstracted ? Quid of module compatibility.
*/
public function setOption($option, $layers = 1)
{
}
public function engine($params)
{
$context = Context::getContext();
@@ -262,7 +262,7 @@ abstract class ModuleGraphCore extends Module
return Tools::displayError('No graph engine selected');
if (!file_exists(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php'))
return Tools::displayError('Graph engine selected is unavailable.');
$id_employee = (int)($context->employee->id);
$id_lang = (int)($context->language->id);
@@ -274,25 +274,25 @@ abstract class ModuleGraphCore extends Module
$params['width'] = 550;
if (!isset($params['height']))
$params['height'] = 270;
$urlParams = $params;
$urlParams['render'] = $render;
$urlParams['module'] = Tools::getValue('module');
$urlParams['id_employee'] = $id_employee;
$urlParams['id_lang'] = $id_lang;
$drawer = 'drawer.php?' . http_build_query($urlParams);
$drawer = 'drawer.php?' . http_build_query(array_map('Tools::safeOutput', $urlParams));
require_once(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php');
return call_user_func(array($render, 'hookGraphEngine'), $params, $drawer);
}
protected static function getEmployee($employee = null, Context $context = null)
{
if (!$context)
$context = Context::getContext();
if (!$employee)
$employee = $context->employee;
if (empty($employee->stats_date_from) OR empty($employee->stats_date_to) OR $employee->stats_date_from == '0000-00-00' OR $employee->stats_date_to == '0000-00-00')
{
if (empty($employee->stats_date_from) OR $employee->stats_date_from == '0000-00-00')
@@ -303,18 +303,18 @@ abstract class ModuleGraphCore extends Module
}
return $employee;
}
public function getDate()
{
return self::getDateBetween($this->_employee);
}
public static function getDateBetween($employee = null)
{
$employee = self::getEmployee($employee);
return ' \''.$employee->stats_date_from.' 00:00:00\' AND \''.$employee->stats_date_to.' 23:59:59\' ';
}
public function getLang()
{
return $this->_id_lang;
+1 -1
View File
@@ -100,7 +100,7 @@ abstract class ModuleGridCore extends Module
if (!file_exists(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php'))
return Tools::displayError('Grid engine selected is unavailable.');
$grider = 'grider.php?render='.$render.'&module='.Tools::getValue('module');
$grider = 'grider.php?render='.$render.'&module='.Tools::safeOutput(Tools::getValue('module'));
$context = Context::getContext();
$grider .= '&id_employee='.(int)($context->employee->id);
+3 -2
View File
@@ -1543,7 +1543,7 @@ class ProductCore extends ObjectModel
'.$context->shop->sqlAsso('product', 'p').'
WHERE p.`active` = 1
AND p.`show_price` = 1
'.((!$beginning AND !$ending) ? ' AND p.`id_product` IN('.((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
'.((!$beginning AND !$ending) ? ' AND p.`id_product` IN('.((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', array_map('intval', $ids_product)) : 0).')' : '').'
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `'._DB_PREFIX_.'category_group` cg
@@ -2809,6 +2809,7 @@ class ProductCore extends ObjectModel
public static function defineProductImage($row, $id_lang)
{
if (isset($row['id_image']))
if ($row['id_image'])
return $row['id_product'].'-'.$row['id_image'];
return Language::getIsoById((int)$id_lang).'-default';
@@ -3606,7 +3607,7 @@ class ProductCore extends ObjectModel
$row = Db::getInstance()->getRow('
SELECT `reference`
FROM `'._DB_PREFIX_.'product` p
WHERE p.reference = "'.$reference.'"');
WHERE p.reference = "'.pSQL($reference).'"');
return isset($row['reference']);
}
+4 -4
View File
@@ -198,8 +198,8 @@ class SpecificPriceCore extends ObjectModel
return Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'specific_price_priority` (`id_product`, `priority`)
VALUES ('.(int)$id_product.',\''.rtrim($value, ';').'\')
ON DUPLICATE KEY UPDATE `priority` = \''.rtrim($value, ';').'\'
VALUES ('.(int)$id_product.',\''.pSQL(rtrim($value, ';')).'\')
ON DUPLICATE KEY UPDATE `priority` = \''.pSQL(rtrim($value, ';')).'\'
');
}
@@ -285,9 +285,9 @@ class SpecificPriceCore extends ObjectModel
`id_group` IN(0, '.(int)$id_group.') AND
`from_quantity` = 1 AND
(
(`from` = \'0000-00-00 00:00:00\' OR \''.$beginning.'\' >= `from`)
(`from` = \'0000-00-00 00:00:00\' OR \''.pSQL($beginning).'\' >= `from`)
AND
(`to` = \'0000-00-00 00:00:00\' OR \''.$ending.'\' <= `to`)
(`to` = \'0000-00-00 00:00:00\' OR \''.pSQL($ending).'\' <= `to`)
)
AND
`reduction` > 0
+2 -2
View File
@@ -509,8 +509,8 @@ class ToolsCore
public static function safeOutput($string, $html = false)
{
if (!$html)
$string = @htmlentities(strip_tags($string), ENT_QUOTES, 'utf-8');
return $string;
$string = strip_tags($string);
return @Tools::htmlentitiesUTF8($string, ENT_QUOTES);;
}
public static function htmlentitiesUTF8($string, $type = ENT_QUOTES)
+1 -1
View File
@@ -303,7 +303,7 @@ abstract class DbCore
public function delete($table, $where = false, $limit = false, $use_cache = 1)
{
$this->_result = false;
$sql = 'DELETE FROM `'.pSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)$limit : '');
$sql = 'DELETE FROM `'.bqSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)$limit : '');
$res = $this->query($sql);
if ($use_cache AND _PS_CACHE_ENABLED_)
Cache::getInstance()->deleteQuery($sql);