Merge branch 'development' of github.com:202-ecommerce/PrestaShop into development
This commit is contained in:
@@ -139,7 +139,7 @@ class AttributeCore extends ObjectModel
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.')
|
||||
'.Shop::addSqlAssociation('attribute_group', 'ag').'
|
||||
'.Shop::addSqlAssociation('attribute', 'a').'
|
||||
'.($not_null ? 'WHERE a.`id_attribute` IS NOT NULL AND al.`name` IS NOT NULL' : '').'
|
||||
'.($not_null ? 'WHERE a.`id_attribute` IS NOT NULL AND al.`name` IS NOT NULL AND agl.`id_attribute_group` IS NOT NULL' : '').'
|
||||
ORDER BY agl.`name` ASC, a.`position` ASC
|
||||
');
|
||||
}
|
||||
@@ -343,4 +343,4 @@ class AttributeCore extends ObjectModel
|
||||
|
||||
return (is_numeric($position)) ? $position : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,6 +340,7 @@ class CartCore extends ObjectModel
|
||||
'.($filter == CartRule::FILTER_ACTION_SHIPPING ? 'AND free_shipping = 1' : '').'
|
||||
'.($filter == CartRule::FILTER_ACTION_GIFT ? 'AND gift_product != 0' : '').'
|
||||
'.($filter == CartRule::FILTER_ACTION_REDUCTION ? 'AND (reduction_percent != 0 OR reduction_amount != 0)' : '')
|
||||
.' ORDER by cr.priority ASC'
|
||||
);
|
||||
Cache::store($cache_key, $result);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ class ConfigurationTestCore
|
||||
'theme_cache_dir' => 'themes/'._THEME_NAME_.'/cache/',
|
||||
'translations_dir' => 'translations',
|
||||
'customizable_products_dir' => 'upload',
|
||||
'virtual_products_dir' => 'download'
|
||||
'virtual_products_dir' => 'download',
|
||||
'files' => false
|
||||
);
|
||||
}
|
||||
|
||||
@@ -318,4 +319,21 @@ class ConfigurationTestCore
|
||||
{
|
||||
return extension_loaded('Dom');
|
||||
}
|
||||
|
||||
public static function test_files()
|
||||
{
|
||||
$files = array(
|
||||
'/cache/smarty/compile/index.php',
|
||||
'/classes/log/index.php',
|
||||
'/classes/cache/index.php',
|
||||
'/config/index.php',
|
||||
'/tools/tar/Archive_Tar.php',
|
||||
'/tools/pear/PEAR.php',
|
||||
'/index.php'
|
||||
);
|
||||
foreach ($files as $file)
|
||||
if (!file_exists(rtrim(_PS_ROOT_DIR_, DIRECTORY_SEPARATOR).str_replace('/', DIRECTORY_SEPARATOR, $file)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+20
-1
@@ -81,6 +81,7 @@ class CurrencyCore extends ObjectModel
|
||||
|
||||
/** @var array Currency cache */
|
||||
static protected $currencies = array();
|
||||
protected static $countActiveCurrencies = array();
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectsNodeName' => 'currencies',
|
||||
@@ -414,5 +415,23 @@ class CurrencyCore extends ObjectModel
|
||||
self::$currencies[(int)($id)] = new Currency($id);
|
||||
return self::$currencies[(int)($id)];
|
||||
}
|
||||
}
|
||||
|
||||
public static function countActiveCurrencies($id_shop = null)
|
||||
{
|
||||
if ($id_shop === null)
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
|
||||
if (!isset(self::$countActiveCurrencies[$id_shop]))
|
||||
self::$countActiveCurrencies[$id_shop] = Db::getInstance()->getValue('
|
||||
SELECT COUNT(DISTINCT c.id_currency) FROM `'._DB_PREFIX_.'currency` c
|
||||
LEFT JOIN '._DB_PREFIX_.'currency_shop cs ON (cs.id_currency = c.id_currency AND cs.id_shop = '.(int)$id_shop.')
|
||||
WHERE c.`active` = 1
|
||||
');
|
||||
return self::$countActiveCurrencies[$id_shop];
|
||||
}
|
||||
|
||||
public static function isMultiCurrencyActivated($id_shop = null)
|
||||
{
|
||||
return (Currency::countActiveCurrencies($id_shop) > 1);
|
||||
}
|
||||
}
|
||||
+34
-54
@@ -91,12 +91,8 @@ class LinkCore
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null)
|
||||
$shop = new Shop($id_shop);
|
||||
else
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
if (!is_object($product))
|
||||
{
|
||||
@@ -163,11 +159,7 @@ class LinkCore
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
if (!is_object($category))
|
||||
$category = new Category($category, $id_lang);
|
||||
@@ -206,11 +198,7 @@ class LinkCore
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
if (!is_object($cms_category))
|
||||
@@ -239,19 +227,12 @@ class LinkCore
|
||||
* @param int $id_lang
|
||||
* @return string
|
||||
*/
|
||||
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null, $id_shop = null)
|
||||
public function getCMSLink($cms, $alias = null, $ssl = null, $id_lang = null, $id_shop = null)
|
||||
{
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
|
||||
$base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain);
|
||||
$url = $base.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$url = $this->getBaseLink($id_shop, $ssl).$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
if (!is_object($cms))
|
||||
@@ -290,11 +271,8 @@ class LinkCore
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
if (!is_object($supplier))
|
||||
@@ -327,11 +305,7 @@ class LinkCore
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
if (!is_object($manufacturer))
|
||||
@@ -360,18 +334,12 @@ class LinkCore
|
||||
* @param int $id_lang
|
||||
* @return string
|
||||
*/
|
||||
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null, $id_shop = null)
|
||||
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = null, $id_lang = null, $id_shop = null)
|
||||
{
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
|
||||
$base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain);
|
||||
$url = $base.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
$url = $this->getBaseLink($id_shop, $ssl).$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
// If the module has its own route ... just use it !
|
||||
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop))
|
||||
@@ -453,10 +421,9 @@ class LinkCore
|
||||
*
|
||||
* @return string Page link
|
||||
*/
|
||||
public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
|
||||
public function getPageLink($controller, $ssl = null, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
|
||||
{
|
||||
$controller = Tools::strReplaceFirst('.php', '', $controller);
|
||||
|
||||
if (!$id_lang)
|
||||
$id_lang = (int)Context::getContext()->language->id;
|
||||
|
||||
@@ -469,17 +436,9 @@ class LinkCore
|
||||
parse_str($request, $request);
|
||||
}
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
|
||||
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request, false, '', $id_shop);
|
||||
|
||||
$url = ($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain;
|
||||
$url .= $shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/');
|
||||
|
||||
return $url;
|
||||
return $this->getBaseLink($id_shop, $ssl).$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/');
|
||||
}
|
||||
|
||||
public function getCatImageLink($name, $id_category, $type = null)
|
||||
@@ -643,5 +602,26 @@ class LinkCore
|
||||
|
||||
return Language::getIsoById($id_lang).'/';
|
||||
}
|
||||
|
||||
protected function getBaseLink($id_shop = null, $ssl = null)
|
||||
{
|
||||
static $force_ssl = null;
|
||||
|
||||
if ($ssl === null)
|
||||
{
|
||||
if ($force_ssl === null)
|
||||
$force_ssl = (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'));
|
||||
$ssl = $force_ssl;
|
||||
}
|
||||
|
||||
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null)
|
||||
$shop = new Shop($id_shop);
|
||||
else
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain);
|
||||
|
||||
return $base.$shop->getBaseURI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -235,8 +235,13 @@ class MailCore
|
||||
include_once($template_path.$iso.'/lang.php');
|
||||
else if ($module_name && file_exists($theme_path.'mails/'.$iso.'/lang.php'))
|
||||
include_once($theme_path.'mails/'.$iso.'/lang.php');
|
||||
else
|
||||
else if (file_exists(_PS_MAIL_DIR_.$iso.'/lang.php'))
|
||||
include_once(_PS_MAIL_DIR_.$iso.'/lang.php');
|
||||
else
|
||||
{
|
||||
Tools::dieOrLog(Tools::displayError('Error - The lang file is missing for :').' '.$iso, $die);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Create mail and attach differents parts */
|
||||
$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject);
|
||||
|
||||
+30
-9
@@ -893,7 +893,7 @@ abstract class ObjectModelCore
|
||||
* @param int $id_lang
|
||||
* @return bool|string
|
||||
*/
|
||||
public function validateField($field, $value, $id_lang = null)
|
||||
public function validateField($field, $value, $id_lang = null, $skip = array(), $human_errors = false)
|
||||
{
|
||||
$this->cacheFieldsRequiredDatabase();
|
||||
$data = $this->def['fields'][$field];
|
||||
@@ -901,9 +901,12 @@ abstract class ObjectModelCore
|
||||
// Check if field is required
|
||||
$required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array();
|
||||
if (!$id_lang || $id_lang == Configuration::get('PS_LANG_DEFAULT'))
|
||||
if (!empty($data['required']) || in_array($field, $required_fields))
|
||||
if (!in_array('required', $skip) && (!empty($data['required']) || in_array($field, $required_fields)))
|
||||
if (Tools::isEmpty($value))
|
||||
return 'Property '.get_class($this).'->'.$field.' is empty';
|
||||
if ($human_errors)
|
||||
return sprintf(Tools::displayError('The %s field is required.'), $this->displayFieldName($field, get_class($this)));
|
||||
else
|
||||
return 'Property '.get_class($this).'->'.$field.' is empty';
|
||||
|
||||
// Default value
|
||||
if (!$value && !empty($data['default']))
|
||||
@@ -913,11 +916,11 @@ abstract class ObjectModelCore
|
||||
}
|
||||
|
||||
// Check field values
|
||||
if (!empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values']))
|
||||
return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')';
|
||||
if (!in_array('values', $skip) && !empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values']))
|
||||
return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')';
|
||||
|
||||
// Check field size
|
||||
if (!empty($data['size']))
|
||||
if (!in_array('size', $skip) && !empty($data['size']))
|
||||
{
|
||||
$size = $data['size'];
|
||||
if (!is_array($data['size']))
|
||||
@@ -925,11 +928,24 @@ abstract class ObjectModelCore
|
||||
|
||||
$length = Tools::strlen($value);
|
||||
if ($length < $size['min'] || $length > $size['max'])
|
||||
return 'Property '.get_class($this).'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max'];
|
||||
{
|
||||
if ($human_errors)
|
||||
{
|
||||
if (isset($data['lang']) && $data['lang'])
|
||||
{
|
||||
$language = new Language((int)$id_lang);
|
||||
return sprintf(Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'), $this->displayFieldName($field, get_class($this)), $language->name, $size['max']);
|
||||
}
|
||||
else
|
||||
return sprintf(Tools::displayError('The %1$s field is too long (%2$d chars max).'), $this->displayFieldName($field, get_class($this)), $size['max']);
|
||||
}
|
||||
else
|
||||
return 'Property '.get_class($this).'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max'];
|
||||
}
|
||||
}
|
||||
|
||||
// Check field validator
|
||||
if (!empty($data['validate']))
|
||||
if (!in_array('validate', $skip) && !empty($data['validate']))
|
||||
{
|
||||
if (!method_exists('Validate', $data['validate']))
|
||||
throw new PrestaShopException('Validation function not found. '.$data['validate']);
|
||||
@@ -948,7 +964,12 @@ abstract class ObjectModelCore
|
||||
$res = false;
|
||||
}
|
||||
if (!$res)
|
||||
return 'Property '.get_class($this).'->'.$field.' is not valid';
|
||||
{
|
||||
if ($human_errors)
|
||||
return sprintf(Tools::displayError('The %s field is invalid.'), $this->displayFieldName($field, get_class($this)));
|
||||
else
|
||||
return 'Property '.get_class($this).'->'.$field.' is not valid';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -399,6 +399,8 @@ abstract class PaymentModuleCore extends Module
|
||||
} // end foreach ($products)
|
||||
|
||||
$cart_rules_list = '';
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule)
|
||||
{
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
@@ -419,7 +421,8 @@ abstract class PaymentModuleCore extends Module
|
||||
** THEN
|
||||
** The voucher is cloned with a new value corresponding to the remainder
|
||||
*/
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > $order->total_products_wt && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0)
|
||||
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0)
|
||||
{
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
@@ -432,9 +435,9 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax)
|
||||
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_incl : 0);
|
||||
$voucher->reduction_amount = $values['tax_incl'] - ($order->total_products_wt - $total_reduction_value_ti) - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_incl : 0);
|
||||
else
|
||||
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_excl : 0);
|
||||
$voucher->reduction_amount = $values['tax_excl'] - ($order->total_products - $total_reduction_value_tex) - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_excl : 0);
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
@@ -466,7 +469,10 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
$values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt;
|
||||
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
|
||||
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
|
||||
+12
-11
@@ -730,10 +730,10 @@ class ProductCore extends ObjectModel
|
||||
/**
|
||||
* @see ObjectModel::validateField()
|
||||
*/
|
||||
public function validateField($field, $value, $id_lang = null)
|
||||
public function validateField($field, $value, $id_lang = null, $skip = array(), $human_errors = false)
|
||||
{
|
||||
$value = ($field == 'description_short' ? strip_tags($value) : $value);
|
||||
return parent::validateField($field, $value, $id_lang);
|
||||
return parent::validateField($field, $value, $id_lang, $skip, $human_errors);
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
@@ -2468,8 +2468,9 @@ class ProductCore extends ObjectModel
|
||||
|
||||
if (!Validate::isBool($usetax) || !Validate::isUnsignedId($id_product))
|
||||
die(Tools::displayError());
|
||||
|
||||
// Initializations
|
||||
$id_group = (isset($context->customer) ? $context->customer->id_default_group : (int)Configuration::get('PS_CUSTOMER_GROUP'));
|
||||
$id_group = (int)Group::getCurrent()->id;
|
||||
|
||||
// If there is cart in context or if the specified id_cart is different from the context cart id
|
||||
if (!is_object($cur_cart) || (Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart))
|
||||
@@ -3055,18 +3056,18 @@ class ProductCore extends ObjectModel
|
||||
if (!Combination::isFeatureActive())
|
||||
return array();
|
||||
$sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name,
|
||||
a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pa.`id_product_attribute`,
|
||||
IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, pa.`weight`,
|
||||
a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, product_attribute_shop.`id_product_attribute`,
|
||||
IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, product_attribute_shop.`weight`,
|
||||
product_attribute_shop.`default_on`, pa.`reference`, product_attribute_shop.`unit_price_impact`,
|
||||
pa.`minimal_quantity`, pa.`available_date`, ag.`group_type`
|
||||
product_attribute_shop.`minimal_quantity`, product_attribute_shop.`available_date`, ag.`group_type`
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||
'.Product::sqlStock('pa', 'pa').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group`
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group`)
|
||||
'.Shop::addSqlAssociation('attribute', 'a').'
|
||||
WHERE pa.`id_product` = '.(int)$this->id.'
|
||||
AND al.`id_lang` = '.(int)$id_lang.'
|
||||
|
||||
+18
-20
@@ -704,6 +704,21 @@ class ToolsCore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param string File path
|
||||
* @param array Excluded files
|
||||
*/
|
||||
public static function deleteFile($file, $exclude_files = array())
|
||||
{
|
||||
if (isset($exclude_files) && !is_array($exclude_files))
|
||||
$exclude_files = array($exclude_files);
|
||||
|
||||
if (file_exists($file) && is_file($file) && array_search(basename($file), $exclude_files) === FALSE)
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear smarty cache folders
|
||||
@@ -1408,26 +1423,9 @@ class ToolsCore
|
||||
|
||||
public static function copy($source, $destination, $stream_context = null)
|
||||
{
|
||||
if ($stream_context == null && preg_match('/^https?:\/\//', $source))
|
||||
$stream_context = @stream_context_create(array('http' => array('timeout' => 10)));
|
||||
|
||||
if (in_array(@ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $source))
|
||||
return @copy($source, $destination, $stream_context);
|
||||
elseif (function_exists('curl_init'))
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_URL, $source);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
$opts = stream_context_get_options($stream_context);
|
||||
$content = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return file_put_contents($destination, $content);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
if (is_null($stream_context) && !preg_match('/^https?:\/\//', $source))
|
||||
return @copy($source, $destination);
|
||||
return @file_put_contents($destination, Tools::file_get_contents($source, false, $stream_context));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ class AdminControllerCore extends Controller
|
||||
public $template = 'content.tpl';
|
||||
|
||||
/** @var string Associated table name */
|
||||
public $table;
|
||||
public $table = 'configuration';
|
||||
|
||||
public $list_id;
|
||||
|
||||
@@ -2426,102 +2426,41 @@ class AdminControllerCore extends Controller
|
||||
if (!$class_name)
|
||||
$class_name = $this->className;
|
||||
|
||||
/* Class specific validation rules */
|
||||
if (!empty($class_name))
|
||||
$rules = call_user_func(array($class_name, 'getValidationRules'), $class_name);
|
||||
$object = new $class_name();
|
||||
$definition = ObjectModel::getDefinition($class_name);
|
||||
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
|
||||
if (isset($rules) && count($rules) && (count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
|
||||
foreach ($definition['fields'] as $field => $def)
|
||||
{
|
||||
/* Language() instance determined by default language */
|
||||
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
$skip = array();
|
||||
if (in_array($field, array('passwd', 'no-picture')))
|
||||
$skip = array('required');
|
||||
|
||||
/* All availables languages */
|
||||
$languages = Language::getLanguages(false);
|
||||
if (isset($def['lang']) && $def['lang'] && isset($def['required']) && $def['required'])
|
||||
{
|
||||
$value = Tools::getValue($field.'_'.$default_language->id);
|
||||
if (Tools::isEmpty($value))
|
||||
$this->errors[$field.'_'.$default_language->id] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
$object->displayFieldName($field, $class_name),
|
||||
$default_language->name
|
||||
);
|
||||
|
||||
foreach (Language::getLanguages(false) as $language)
|
||||
{
|
||||
$value = Tools::getValue($field.'_'.$language['id_lang']);
|
||||
if (!empty($value))
|
||||
if (($error = $object->validateField($field, $value, $language['id_lang'], $skip, true)) !== true)
|
||||
$this->errors[$field.'_'.$language['id_lang']] = $error;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (($error = $object->validateField($field, Tools::getValue($field), null, $skip, true)) !== true)
|
||||
$this->errors[$field] = $error;
|
||||
}
|
||||
|
||||
/* Checking for required fields */
|
||||
if (isset($rules['required']) && is_array($rules['required']))
|
||||
foreach ($rules['required'] as $field)
|
||||
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is required.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
|
||||
/* Checking for multilingual required fields */
|
||||
if (isset($rules['requiredLang']) && is_array($rules['requiredLang']))
|
||||
foreach ($rules['requiredLang'] as $field_lang)
|
||||
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
||||
$this->errors[$field_lang.'_'.$default_language->id] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$default_language->name
|
||||
);
|
||||
|
||||
/* Checking for maximum fields sizes */
|
||||
if (isset($rules['size']) && is_array($rules['size']))
|
||||
foreach ($rules['size'] as $field => $max_length)
|
||||
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %1$s field is too long (%2$d chars max).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
||||
$max_length
|
||||
);
|
||||
|
||||
/* Checking for maximum multilingual fields size */
|
||||
if (isset($rules['sizeLang']) && is_array($rules['sizeLang']))
|
||||
foreach ($rules['sizeLang'] as $field_lang => $max_length)
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
||||
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name'],
|
||||
$max_length
|
||||
);
|
||||
}
|
||||
/* Overload this method for custom checking */
|
||||
$this->_childValidation();
|
||||
|
||||
/* Checking for fields validity */
|
||||
if (isset($rules['validate']) && is_array($rules['validate']))
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||
if (!Validate::$function($value) && !empty($value))
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
|
||||
/* Checking for passwd_old validity */
|
||||
if (($value = Tools::getValue('passwd')) != false)
|
||||
{
|
||||
if ($class_name == 'Employee' && !Validate::isPasswdAdmin($value))
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
elseif ($class_name == 'Customer' && !Validate::isPasswd($value))
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
}
|
||||
|
||||
/* Checking for multilingual fields validity */
|
||||
if (isset($rules['validateLang']) && is_array($rules['validateLang']))
|
||||
foreach ($rules['validateLang'] as $field_lang => $function)
|
||||
foreach ($languages as $language)
|
||||
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
||||
if (!Validate::$function($value))
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The %1$s field (%2$s) is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,9 @@ class FrontControllerCore extends Controller
|
||||
|
||||
parent::__construct();
|
||||
|
||||
if (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'))
|
||||
$this->ssl = true;
|
||||
|
||||
if (isset($useSSL))
|
||||
$this->ssl = $useSSL;
|
||||
else
|
||||
@@ -144,8 +147,6 @@ class FrontControllerCore extends Controller
|
||||
// Init cookie language
|
||||
// @TODO This method must be moved into switchLanguage
|
||||
Tools::setCookieLanguage($this->context->cookie);
|
||||
|
||||
$currency = Tools::setCurrency($this->context->cookie);
|
||||
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode()) ? 'https://' : 'http://';
|
||||
$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
|
||||
@@ -167,6 +168,8 @@ class FrontControllerCore extends Controller
|
||||
if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault))
|
||||
$this->context->country = $newDefault;
|
||||
|
||||
$currency = Tools::setCurrency($this->context->cookie);
|
||||
|
||||
if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id)))
|
||||
{
|
||||
$this->context->customer->logout();
|
||||
@@ -600,7 +603,7 @@ class FrontControllerCore extends Controller
|
||||
if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET' || Tools::getValue('live_edit'))
|
||||
return;
|
||||
|
||||
$match_url = (($this->ssl && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$match_url = (Configuration::get('PS_SSL_ENABLED') && ($this->ssl || Configuration::get('PS_SSL_ENABLED_EVERYWHERE')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$match_url = rawurldecode($match_url);
|
||||
if (!preg_match('/^'.Tools::pRegexp(rawurldecode($canonical_url), '/').'([&?].*)?$/', $match_url))
|
||||
{
|
||||
@@ -670,6 +673,7 @@ class FrontControllerCore extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country))
|
||||
$this->context->cookie->iso_code_country = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country))))
|
||||
|
||||
@@ -35,10 +35,10 @@ class HelperFormCore extends Helper
|
||||
/** @var array of forms fields */
|
||||
protected $fields_form = array();
|
||||
|
||||
/** @var array values of form fields */
|
||||
/** @var array values of form fields */
|
||||
public $fields_value = array();
|
||||
|
||||
public $table;
|
||||
public $table = 'configuration';
|
||||
public $name_controller = '';
|
||||
|
||||
/** @var string if not null, a title will be added on that list */
|
||||
|
||||
@@ -136,6 +136,9 @@ class HelperListCore extends Helper
|
||||
$this->_list = $list;
|
||||
$this->fields_list = $fields_display;
|
||||
|
||||
$this->orderBy = preg_replace('/^([a-z _]*!)/Ui', '', $this->orderBy);
|
||||
$this->orderWay = preg_replace('/^([a-z _]*!)/Ui', '', $this->orderWay);
|
||||
|
||||
// Display list header (filtering, pagination and column names)
|
||||
$tpl_vars['header'] = $this->displayListHeader();
|
||||
|
||||
@@ -522,9 +525,6 @@ class HelperListCore extends Helper
|
||||
isset($this->context->cookie->{$this->list_id.'_pagination'}) ? $this->context->cookie->{$this->list_id.'_pagination'} : null
|
||||
);
|
||||
|
||||
// Cleaning links
|
||||
if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway'))
|
||||
$this->currentIndex = preg_replace('/&'.$this->table.'Orderby=([a-z _]*)&'.$this->table.'Orderway=([a-z]*)/i', '', $this->currentIndex);
|
||||
|
||||
if ($this->position_identifier && (int)Tools::getValue($this->position_identifier, 1))
|
||||
$table_id = substr($this->identifier, 3, strlen($this->identifier));
|
||||
|
||||
+20
-13
@@ -938,7 +938,7 @@ abstract class ModuleCore
|
||||
|
||||
public static function configXmlStringFormat($string)
|
||||
{
|
||||
return str_replace('\'', '\\\'', Tools::htmlentitiesDecodeUTF8($string));
|
||||
return Tools::htmlentitiesDecodeUTF8($string);
|
||||
}
|
||||
|
||||
|
||||
@@ -1630,15 +1630,18 @@ abstract class ModuleCore
|
||||
|
||||
protected function getCacheId($name = null)
|
||||
{
|
||||
$cache_array = array(
|
||||
$name !== null ? $name : $this->name,
|
||||
(int)Tools::usingSecureMode(),
|
||||
(int)$this->context->shop->id,
|
||||
(int)Group::getCurrent()->id,
|
||||
(int)$this->context->language->id,
|
||||
(int)$this->context->currency->id,
|
||||
(int)$this->context->country->id
|
||||
);
|
||||
$cache_array = array();
|
||||
$cache_array[] = $name !== null ? $name : $this->name;
|
||||
if (Configuration::get('PS_SSL_ENABLED'))
|
||||
$cache_array[] = (int)Tools::usingSecureMode();
|
||||
if (Shop::isFeatureActive())
|
||||
$cache_array[] = (int)$this->context->shop->id;
|
||||
$cache_array[] = (int)Group::getCurrent()->id;
|
||||
if (Language::isMultiLanguageActivated())
|
||||
$cache_array[] = (int)$this->context->language->id;
|
||||
if (Currency::isMultiCurrencyActivated())
|
||||
$cache_array[] = (int)$this->context->currency->id;
|
||||
$cache_array[] = (int)$this->context->country->id;
|
||||
return implode('|', $cache_array);
|
||||
}
|
||||
|
||||
@@ -1701,10 +1704,12 @@ abstract class ModuleCore
|
||||
|
||||
if ($overloaded)
|
||||
return $overloaded;
|
||||
else if (file_exists(_PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template))
|
||||
elseif (file_exists(_PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template))
|
||||
return _PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template;
|
||||
else
|
||||
elseif (file_exists(_PS_MODULE_DIR_.$this->name.'/'.$template))
|
||||
return _PS_MODULE_DIR_.$this->name.'/'.$template;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function _getApplicableTemplateDir($template)
|
||||
@@ -1724,6 +1729,8 @@ abstract class ModuleCore
|
||||
protected function _clearCache($template, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
Tools::enableCache();
|
||||
if ($cache_id === null)
|
||||
$cache_id = Module::getCacheId($this->name);
|
||||
Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath($template), $cache_id, $compile_id);
|
||||
Tools::restoreCacheSettings();
|
||||
}
|
||||
@@ -2075,7 +2082,7 @@ abstract class ModuleCore
|
||||
|
||||
// Remplacer la ligne de declaration par "remove"
|
||||
foreach ($override_file as $line_number => &$line_content)
|
||||
if (preg_match('/(public|private|protected)\s+(static\s+)?\$'.$property->getName().'/i', $line_content))
|
||||
if (preg_match('/(public|private|protected|const)\s+(static\s+)?(\$)?'.$property->getName().'/i', $line_content))
|
||||
{
|
||||
$line_content = '#--remove--#';
|
||||
break;
|
||||
|
||||
@@ -305,7 +305,7 @@ class StockAvailableCore extends ObjectModel
|
||||
if (!Validate::isUnsignedId($id_product))
|
||||
return false;
|
||||
|
||||
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, (int)$id_product_attribute, (int)$id_shop);
|
||||
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, (int)$id_product_attribute, $id_shop);
|
||||
if ($existing_id > 0)
|
||||
{
|
||||
Db::getInstance()->update(
|
||||
|
||||
Reference in New Issue
Block a user