Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
+8
-12
@@ -54,6 +54,8 @@ class Autoload
|
||||
$this->root_dir = dirname(dirname(__FILE__)).'/';
|
||||
if (file_exists($this->root_dir.Autoload::INDEX_FILE))
|
||||
$this->index = include($this->root_dir.Autoload::INDEX_FILE);
|
||||
else
|
||||
$this->generateIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,9 +82,8 @@ class Autoload
|
||||
if (strpos(strtolower($classname), 'smarty_') === 0)
|
||||
return;
|
||||
|
||||
// regenerate the class index if the requested class is not found in the index or if the requested file doesn't exists
|
||||
if (!isset($this->index[$classname])
|
||||
|| ($this->index[$classname] && !is_file($this->root_dir.$this->index[$classname]))
|
||||
// regenerate the class index if the requested file doesn't exists
|
||||
if ((isset($this->index[$classname]) && $this->index[$classname] && !is_file($this->root_dir.$this->index[$classname]))
|
||||
|| (isset($this->index[$classname.'Core']) && $this->index[$classname.'Core'] && !is_file($this->root_dir.$this->index[$classname.'Core'])))
|
||||
$this->generateIndex();
|
||||
|
||||
@@ -138,18 +139,14 @@ class Autoload
|
||||
{
|
||||
$filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
|
||||
if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE)
|
||||
{
|
||||
{
|
||||
@rename($filename_tmp, $filename);
|
||||
@chmod($filename, 0664);
|
||||
@chmod($filename, 0666);
|
||||
}
|
||||
else
|
||||
{
|
||||
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated),
|
||||
// no need to die.
|
||||
else
|
||||
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
|
||||
error_log('Cannot write temporary file '.$filename_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
$this->index = $classes;
|
||||
}
|
||||
|
||||
@@ -192,4 +189,3 @@ class Autoload
|
||||
return isset($this->index[$classname]) ? $this->index[$classname] : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-6
@@ -762,10 +762,11 @@ class CartCore extends ObjectModel
|
||||
{
|
||||
// You can't add a cart rule that does not exist
|
||||
$cartRule = new CartRule($id_cart_rule, Context::getContext()->language->id);
|
||||
|
||||
if (!Validate::isLoadedObject($cartRule))
|
||||
return false;
|
||||
|
||||
if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$this->id))
|
||||
if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart_rule = '.(int)$id_cart_rule.' AND id_cart = '.(int)$this->id))
|
||||
return false;
|
||||
|
||||
// Add the cart rule to the cart
|
||||
@@ -3415,6 +3416,7 @@ class CartCore extends ObjectModel
|
||||
*/
|
||||
public function setNoMultishipping()
|
||||
{
|
||||
$emptyCache = $result = false;
|
||||
if (Configuration::get('PS_ALLOW_MULTISHIPPING'))
|
||||
{
|
||||
// Upgrading quantities
|
||||
@@ -3433,7 +3435,9 @@ class CartCore extends ObjectModel
|
||||
AND `id_shop` = '.(int)$this->id_shop.'
|
||||
AND id_product = '.$product['id_product'].'
|
||||
AND id_product_attribute = '.$product['id_product_attribute'];
|
||||
Db::getInstance()->execute($sql);
|
||||
$result = Db::getInstance()->execute($sql);
|
||||
if ($result)
|
||||
$emptyCache = true;
|
||||
}
|
||||
|
||||
// Merging multiple lines
|
||||
@@ -3451,15 +3455,18 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
|
||||
// Update delivery address for each product line
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'cart_product`
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
|
||||
SET `id_address_delivery` = (
|
||||
SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart`
|
||||
WHERE `id_cart` = '.(int)$this->id.' AND `id_shop` = '.(int)$this->id_shop.'
|
||||
)
|
||||
WHERE `id_cart` = '.(int)$this->id.'
|
||||
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : ''));
|
||||
|
||||
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '');
|
||||
|
||||
$result = Db::getInstance()->execute($sql);
|
||||
if ($result)
|
||||
$emptyCache = true;
|
||||
|
||||
if (Customization::isFeatureActive())
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'customization`
|
||||
@@ -3468,6 +3475,9 @@ class CartCore extends ObjectModel
|
||||
WHERE `id_cart` = '.(int)$this->id.'
|
||||
)
|
||||
WHERE `id_cart` = '.(int)$this->id);
|
||||
|
||||
if ($emptyCache)
|
||||
$this->_products = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1190,7 +1190,7 @@ class CartRuleCore extends ObjectModel
|
||||
SELECT cr.*, crl.*
|
||||
FROM '._DB_PREFIX_.'cart_rule cr
|
||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang = '.(int)$id_lang.')
|
||||
WHERE code LIKE \'%'.pSQL($name).'%\'
|
||||
WHERE code LIKE \'%'.pSQL($name).'%\' OR name LIKE \'%'.pSQL($name).'%\'
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class ConnectionCore extends ObjectModel
|
||||
'id_connections' => (int)$cookie->id_connections,
|
||||
'id_page' => (int)$id_page,
|
||||
'time_start' => $time_start
|
||||
));
|
||||
), false, true, Db::INSERT_IGNORE);
|
||||
|
||||
// This array is serialized and used by the ajax request to identify the page
|
||||
return array(
|
||||
@@ -114,7 +114,7 @@ class ConnectionCore extends ObjectModel
|
||||
// This is a bot and we have to retrieve its connection ID
|
||||
$sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).'
|
||||
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
||||
AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `date_add` DESC';
|
||||
if ($id_connections = Db::getInstance()->getValue($sql))
|
||||
@@ -128,7 +128,7 @@ class ConnectionCore extends ObjectModel
|
||||
$sql = 'SELECT `id_guest`
|
||||
FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE `id_guest` = '.(int)$cookie->id_guest.'
|
||||
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
||||
AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `date_add` DESC';
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
@@ -369,7 +369,7 @@ class DispatcherCore
|
||||
|
||||
// If there are several languages, get language from uri
|
||||
if ($this->use_routes && Language::isMultiLanguageActivated())
|
||||
if (preg_match('#^/([a-z]{2})/#', $this->request_uri, $m))
|
||||
if (preg_match('#^/([a-z]{2})/?#', $this->request_uri, $m))
|
||||
{
|
||||
$_GET['isolang'] = $m[1];
|
||||
$this->request_uri = substr($this->request_uri, 3);
|
||||
@@ -549,7 +549,7 @@ class DispatcherCore
|
||||
if ($id_shop === null)
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
|
||||
if ($this->use_routes && !isset($this->routes[$id_shop]))
|
||||
if (!isset($this->routes[$id_shop]))
|
||||
$this->loadRoutes($id_shop);
|
||||
|
||||
if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id]))
|
||||
@@ -594,9 +594,9 @@ class DispatcherCore
|
||||
if ($id_shop === null)
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
|
||||
if ($this->use_routes && !isset($this->routes[$id_shop]))
|
||||
if (!isset($this->routes[$id_shop]))
|
||||
$this->loadRoutes($id_shop);
|
||||
|
||||
|
||||
if (!isset($this->routes[$id_shop][$id_lang][$route_id]))
|
||||
{
|
||||
$query = http_build_query($params, '', '&');
|
||||
|
||||
+34
-53
@@ -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)
|
||||
{
|
||||
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
|
||||
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = $base.$shop->domain.$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)
|
||||
{
|
||||
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
|
||||
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = $base.$shop->domain.$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,16 +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://' : 'http://';
|
||||
$url .= $shop->domain.$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)
|
||||
@@ -642,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -50,10 +50,11 @@ class MailCore
|
||||
* @param bool $modeSMTP
|
||||
* @param string $template_path
|
||||
* @param bool $die
|
||||
* @param string $bcc Bcc recipient
|
||||
*/
|
||||
public static function Send($id_lang, $template, $subject, $template_vars, $to,
|
||||
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
|
||||
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null)
|
||||
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null)
|
||||
{
|
||||
$configuration = Configuration::getMultiple(array(
|
||||
'PS_SHOP_EMAIL',
|
||||
@@ -127,9 +128,9 @@ class MailCore
|
||||
}
|
||||
|
||||
/* Construct multiple recipients list if needed */
|
||||
$to_list = new Swift_RecipientList();
|
||||
if (is_array($to) && isset($to))
|
||||
{
|
||||
$to_list = new Swift_RecipientList();
|
||||
foreach ($to as $key => $addr)
|
||||
{
|
||||
$to_name = null;
|
||||
@@ -153,17 +154,20 @@ class MailCore
|
||||
$to_list->addTo($addr, self::mimeEncode($to_name));
|
||||
}
|
||||
$to_plugin = $to[0];
|
||||
$to = $to_list;
|
||||
} else {
|
||||
/* Simple recipient, one address */
|
||||
$to_plugin = $to;
|
||||
if ($to_name == null)
|
||||
$to_name = $to;
|
||||
if (function_exists('mb_encode_mimeheader'))
|
||||
$to = new Swift_Address($to, mb_encode_mimeheader($to_name, 'utf-8'));
|
||||
$to_list->addTo($to, mb_encode_mimeheader($to_name, 'utf-8'));
|
||||
else
|
||||
$to = new Swift_Address($to, self::mimeEncode($to_name));
|
||||
$to_list->addTo($to, self::mimeEncode($to_name));
|
||||
}
|
||||
if(isset($bcc)) {
|
||||
$to_list->addBcc($bcc);
|
||||
}
|
||||
$to = $to_list;
|
||||
try {
|
||||
/* Connect with the appropriate configuration */
|
||||
if ($configuration['PS_MAIL_METHOD'] == 2)
|
||||
@@ -445,4 +449,4 @@ class MailCore
|
||||
|
||||
return $start . $string . $end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class MediaCore
|
||||
'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
|
||||
'ui.autocomplete' => array('fileName' => 'jquery.ui.autocomplete.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
|
||||
'ui.button' => array('fileName' => 'jquery.ui.button.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
|
||||
'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
|
||||
'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position','ui.button'), 'theme' => true),
|
||||
'ui.slider' => array('fileName' => 'jquery.ui.slider.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
|
||||
'ui.tabs' => array('fileName' => 'jquery.ui.tabs.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
|
||||
'ui.datepicker' => array('fileName' => 'jquery.ui.datepicker.min.js', 'dependencies' => array('ui.core'), 'theme' => true),
|
||||
|
||||
+5
-2
@@ -68,8 +68,11 @@ class MetaCore extends ObjectModel
|
||||
{
|
||||
if ($file != 'index.php' && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages))
|
||||
{
|
||||
$reflection = new ReflectionClass(str_replace('.php', '', $file));
|
||||
$properties = $reflection->getDefaultProperties();
|
||||
$class_name = str_replace('.php', '', $file);
|
||||
if (class_exists($class_name))
|
||||
$reflection = new ReflectionClass(str_replace('.php', '', $file));
|
||||
if (isset($reflection) && $reflection)
|
||||
$properties = $reflection->getDefaultProperties();
|
||||
if (isset($properties['php_self']))
|
||||
$selected_pages[$properties['php_self']] = $properties['php_self'];
|
||||
else if (preg_match('/^[a-z0-9_.-]*\.php$/i', $file))
|
||||
|
||||
+8
-8
@@ -3055,18 +3055,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.'
|
||||
|
||||
+12
-21
@@ -1260,6 +1260,13 @@ class ToolsCore
|
||||
return Tools::strtoupper(Tools::substr($str, 0, 1)).Tools::substr($str, 1);
|
||||
}
|
||||
|
||||
public static function ucwords($str)
|
||||
{
|
||||
if (function_exists('mb_convert_case'))
|
||||
return mb_convert_case($str, MB_CASE_TITLE);
|
||||
return ucwords(strtolower($str));
|
||||
}
|
||||
|
||||
public static function orderbyPrice(&$array, $order_way)
|
||||
{
|
||||
foreach ($array as &$row)
|
||||
@@ -1401,26 +1408,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1596,7 +1586,8 @@ class ToolsCore
|
||||
|
||||
if (self::$_cache_nb_media_servers && ($id_media_server = (abs(crc32($filename)) % self::$_cache_nb_media_servers + 1)))
|
||||
return constant('_MEDIA_SERVER_'.$id_media_server.'_');
|
||||
return Tools::getShopDomain();
|
||||
|
||||
return Tools::usingSecureMode() ? Tools::getShopDomainSSL() : Tools::getShopDomain();
|
||||
}
|
||||
|
||||
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2159,8 +2159,11 @@ class AdminControllerCore extends Controller
|
||||
|| !Validate::isUnsignedId($id_lang))
|
||||
throw new PrestaShopException('get list params is not valid');
|
||||
|
||||
if (isset($this->fields_list[$order_by]) && isset($this->fields_list[$order_by]['filter_key']))
|
||||
$order_by = $this->fields_list[$order_by]['filter_key'];
|
||||
if (!isset($this->fields_list[$order_by]['order_key']) && isset($this->fields_list[$order_by]['filter_key']))
|
||||
$this->fields_list[$order_by]['order_key'] = $this->fields_list[$order_by]['filter_key'];
|
||||
|
||||
if (isset($this->fields_list[$order_by]) && isset($this->fields_list[$order_by]['order_key']))
|
||||
$order_by = $this->fields_list[$order_by]['order_key'];
|
||||
|
||||
/* Determine offset from current page */
|
||||
if ((isset($_POST['submitFilter'.$this->list_id]) ||
|
||||
|
||||
@@ -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();
|
||||
@@ -597,7 +600,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 = (($this->ssl) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$match_url = rawurldecode($match_url);
|
||||
if (!preg_match('/^'.Tools::pRegexp(rawurldecode($canonical_url), '/').'([&?].*)?$/', $match_url))
|
||||
{
|
||||
@@ -667,6 +670,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();
|
||||
|
||||
@@ -456,7 +459,7 @@ class HelperListCore extends Helper
|
||||
);
|
||||
|
||||
if ($this->specificConfirmDelete !== false)
|
||||
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : addcslashes(Tools::htmlentitiesDecodeUTF8(self::$cache_lang['DeleteItem'].$name), '\'');
|
||||
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : Tools::safeOutput(addcslashes(self::$cache_lang['DeleteItem'].$name, '\''));
|
||||
|
||||
$tpl->assign(array_merge($this->tpl_delete_link_vars, $data));
|
||||
|
||||
@@ -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));
|
||||
|
||||
+26
-10
@@ -118,6 +118,9 @@ abstract class ModuleCore
|
||||
|
||||
/** @var Smarty_Data */
|
||||
protected $smarty;
|
||||
|
||||
/** @var currentSmartySubTemplate */
|
||||
protected $current_subtemplate = null;
|
||||
|
||||
|
||||
const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
|
||||
@@ -1653,20 +1656,35 @@ abstract class ModuleCore
|
||||
if ($cacheId !== null)
|
||||
Tools::enableCache();
|
||||
|
||||
$smarty_subtemplate = $this->context->smarty->createTemplate(
|
||||
$this->getTemplatePath($template),
|
||||
$cacheId,
|
||||
$compileId,
|
||||
$this->smarty
|
||||
);
|
||||
$result = $smarty_subtemplate->fetch();
|
||||
$result = $this->getCurrentSubTemplate($template, $cacheId, $compileId)->fetch();
|
||||
|
||||
if ($cacheId !== null)
|
||||
Tools::restoreCacheSettings();
|
||||
|
||||
$this->resetCurrentSubTemplate($template, $cacheId, $compileId);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCurrentSubTemplate($template, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
if (!isset($this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id]))
|
||||
{
|
||||
$this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id] = $this->context->smarty->createTemplate(
|
||||
$this->getTemplatePath($template),
|
||||
$cache_id,
|
||||
$compile_id,
|
||||
$this->smarty
|
||||
);
|
||||
}
|
||||
return $this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id];
|
||||
}
|
||||
|
||||
protected function resetCurrentSubTemplate($template, $cache_id, $compile_id)
|
||||
{
|
||||
$this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get realpath of a template of current module (check if template is overriden too)
|
||||
@@ -1696,10 +1714,8 @@ abstract class ModuleCore
|
||||
|
||||
public function isCached($template, $cacheId = null, $compileId = null)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
Tools::enableCache();
|
||||
$is_cached = $context->smarty->isCached($this->getTemplatePath($template), $cacheId, $compileId);
|
||||
$is_cached = $this->getCurrentSubTemplate($this->getTemplatePath($template), $cacheId, $compileId)->isCached($this->getTemplatePath($template), $cacheId, $compileId);
|
||||
Tools::restoreCacheSettings();
|
||||
|
||||
return $is_cached;
|
||||
|
||||
@@ -363,10 +363,12 @@ class ShopCore extends ObjectModel
|
||||
// Define some $_SERVER variables like HTTP_HOST if PHP is launched with php-cli
|
||||
if (Tools::isPHPCLI())
|
||||
{
|
||||
if(!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
|
||||
if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
|
||||
$_SERVER['HTTP_HOST'] = $shop->domain;
|
||||
if(!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME']))
|
||||
if (!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME']))
|
||||
$_SERVER['SERVER_NAME'] = $shop->domain;
|
||||
if (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR']))
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -305,11 +305,7 @@ class StockAvailableCore extends ObjectModel
|
||||
if (!Validate::isUnsignedId($id_product))
|
||||
return false;
|
||||
|
||||
if ($id_shop === null)
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, (int)$id_product_attribute, (int)$id_shop);
|
||||
|
||||
if ($existing_id > 0)
|
||||
{
|
||||
Db::getInstance()->update(
|
||||
|
||||
@@ -80,7 +80,7 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface
|
||||
if (!empty($this->address->postcode))
|
||||
$postcode = $this->address->postcode;
|
||||
|
||||
if (!isset(self::$cache_tax_calculator[$postcode.'-'.$this->type]))
|
||||
if (!isset(self::$cache_tax_calculator[(int)$this->address->id_country.'-'.$postcode.'-'.$this->type]))
|
||||
{
|
||||
$rows = Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
|
||||
@@ -1289,9 +1289,8 @@ class WebserviceRequestCore
|
||||
$check = ' WHERE ('.implode('OR', $OR).') AND `'.bqSQL($this->resourceConfiguration['fields']['id']['sqlId']).'` = '.(int)$this->urlSegment[1];
|
||||
if (!Db::getInstance()->getValue($sql.$check))
|
||||
$this->setError(404, 'This '.$this->resourceConfiguration['retrieveData']['className'].' ('.(int)$this->urlSegment[1].') does not exists on this shop', 131);
|
||||
else
|
||||
return $objects;
|
||||
}
|
||||
return $objects;
|
||||
}
|
||||
if (!count($this->errors))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user