//MERGE branche release
This commit is contained in:
@@ -142,12 +142,15 @@ class AttributeGroupCore extends ObjectModel
|
||||
if (!AttributeGroup::cleanDeadCombinations())
|
||||
return false;
|
||||
/* Also delete related attributes */
|
||||
if (Db::getInstance()->execute('
|
||||
if (count($to_remove))
|
||||
if (!Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'attribute_lang`
|
||||
WHERE `id_attribute`
|
||||
IN (SELECT id_attribute FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id.')') === false ||
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id) === false)
|
||||
return false;
|
||||
WHERE `id_attribute` IN ('.implode(',', $to_remove).')') ||
|
||||
!Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'attribute_shop`
|
||||
WHERE `id_attribute` IN ('.implode(',', $to_remove).')') ||
|
||||
!Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id))
|
||||
return false;
|
||||
$this->cleanPositions();
|
||||
}
|
||||
$return = parent::delete();
|
||||
|
||||
+1
-1
@@ -1291,7 +1291,7 @@ class CarrierCore extends ObjectModel
|
||||
{
|
||||
if ($delete)
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$this->id);
|
||||
if (!count($groups))
|
||||
if (!is_array($groups) || !count($groups))
|
||||
return true;
|
||||
$sql = 'INSERT INTO '._DB_PREFIX_.'carrier_group (id_carrier, id_group) VALUES ';
|
||||
foreach ($groups as $id_group)
|
||||
|
||||
@@ -135,6 +135,7 @@ class CombinationCore extends ObjectModel
|
||||
{
|
||||
$result = Db::getInstance()->delete('product_attribute_combination', '`id_product_attribute` = '.(int)$this->id);
|
||||
$result &= Db::getInstance()->delete('cart_product', '`id_product_attribute` = '.(int)$this->id);
|
||||
$result &= Db::getInstance()->delete('product_attribute_image', '`id_product_attribute` = '.(int)$this->id);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -549,6 +549,9 @@ class DispatcherCore
|
||||
if ($id_shop === null)
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
|
||||
if ($this->use_routes && !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]))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -248,8 +248,8 @@ class EmployeeCore extends ObjectModel
|
||||
{
|
||||
/* Employee is valid only if it can be load and if cookie password is the same as database one */
|
||||
Cache::store('isLoggedBack'.$this->id, (
|
||||
$this->id && Validate::isUnsignedId($this->id) && Employee::checkPassword($this->id, $this->passwd)
|
||||
&& (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP'))
|
||||
$this->id && Validate::isUnsignedId($this->id) && Employee::checkPassword($this->id, Context::getContext()->cookie->passwd)
|
||||
&& (!isset(Context::getContext()->cookie->remote_addr) || Context::getContext()->cookie->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP'))
|
||||
));
|
||||
}
|
||||
return Cache::retrieve('isLoggedBack'.$this->id);
|
||||
@@ -261,7 +261,10 @@ class EmployeeCore extends ObjectModel
|
||||
public function logout()
|
||||
{
|
||||
if (isset(Context::getContext()->cookie))
|
||||
{
|
||||
Context::getContext()->cookie->logout();
|
||||
Context::getContext()->cookie->write();
|
||||
}
|
||||
$this->id = null;
|
||||
}
|
||||
|
||||
|
||||
+11
-8
@@ -70,7 +70,7 @@ class LanguageCore extends ObjectModel
|
||||
/** @var array Languages cache */
|
||||
protected static $_checkedLangs;
|
||||
protected static $_LANGUAGES;
|
||||
protected static $countActiveLanguages;
|
||||
protected static $countActiveLanguages = array();
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectNodeName' => 'language',
|
||||
@@ -756,15 +756,18 @@ class LanguageCore extends ObjectModel
|
||||
return (isset(self::$_cache_language_installation[$iso_code]) ? self::$_cache_language_installation[$iso_code] : false);
|
||||
}
|
||||
|
||||
public static function countActiveLanguages()
|
||||
public static function countActiveLanguages($id_shop = null)
|
||||
{
|
||||
if (!self::$countActiveLanguages)
|
||||
self::$countActiveLanguages = Db::getInstance()->getValue('
|
||||
if ($id_shop === null)
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
|
||||
if (!isset(self::$countActiveLanguages[$id_shop]))
|
||||
self::$countActiveLanguages[$id_shop] = Db::getInstance()->getValue('
|
||||
SELECT COUNT(DISTINCT l.id_lang) FROM `'._DB_PREFIX_.'lang` l
|
||||
'.Shop::addSqlAssociation('lang', 'l').'
|
||||
JOIN '._DB_PREFIX_.'lang_shop lang_shop ON (lang_shop.id_lang = l.id_lang AND lang_shop.id_shop = '.(int)$id_shop.')
|
||||
WHERE l.`active` = 1
|
||||
');
|
||||
return self::$countActiveLanguages;
|
||||
return self::$countActiveLanguages[$id_shop];
|
||||
}
|
||||
|
||||
public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null)
|
||||
@@ -819,8 +822,8 @@ class LanguageCore extends ObjectModel
|
||||
* @since 1.5.0
|
||||
* @return bool
|
||||
*/
|
||||
public static function isMultiLanguageActivated()
|
||||
public static function isMultiLanguageActivated($id_shop = null)
|
||||
{
|
||||
return (Language::countActiveLanguages() > 1);
|
||||
return (Language::countActiveLanguages($id_shop) > 1);
|
||||
}
|
||||
}
|
||||
+27
-16
@@ -96,14 +96,14 @@ class LinkCore
|
||||
else
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
if (!is_object($product))
|
||||
{
|
||||
if (is_array($product) && isset($product['id_product']))
|
||||
$product = new Product($product['id_product'], false, $id_lang);
|
||||
$product = new Product($product['id_product'], false, $id_lang, $id_shop);
|
||||
elseif ((int)$product)
|
||||
$product = new Product((int)$product, false, $id_lang);
|
||||
$product = new Product((int)$product, false, $id_lang, $id_shop);
|
||||
else
|
||||
throw new PrestaShopException('Invalid product vars');
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class LinkCore
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
if (!is_object($category))
|
||||
$category = new Category($category, $id_lang);
|
||||
@@ -210,7 +210,7 @@ class LinkCore
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
if (!is_object($cms_category))
|
||||
@@ -250,7 +250,7 @@ class LinkCore
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
@@ -294,7 +294,7 @@ class LinkCore
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
if (!is_object($supplier))
|
||||
@@ -331,7 +331,7 @@ class LinkCore
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||
|
||||
$dispatcher = Dispatcher::getInstance();
|
||||
if (!is_object($manufacturer))
|
||||
@@ -371,17 +371,18 @@ class LinkCore
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
$shop = new Shop($id_shop);
|
||||
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
|
||||
// Set available keywords
|
||||
$params['module'] = $module;
|
||||
$params['controller'] = $controller ? $controller : 'default';
|
||||
$url = $base.$shop->domain.$shop->getBaseURI().$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))
|
||||
return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params);
|
||||
else
|
||||
{
|
||||
// Set available keywords
|
||||
$params['module'] = $module;
|
||||
$params['controller'] = $controller ? $controller : 'default';
|
||||
return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow, '', $id_shop);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,7 +476,7 @@ class LinkCore
|
||||
|
||||
$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).ltrim($uri_path, '/');
|
||||
$url .= $shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/');
|
||||
|
||||
return $url;
|
||||
}
|
||||
@@ -509,6 +510,7 @@ class LinkCore
|
||||
unset($params['id_lang']);
|
||||
|
||||
$controller = Dispatcher::getInstance()->getController();
|
||||
|
||||
if (!empty(Context::getContext()->controller->php_self))
|
||||
$controller = Context::getContext()->controller->php_self;
|
||||
|
||||
@@ -524,6 +526,15 @@ class LinkCore
|
||||
return $this->getCMSLink((int)$params['id_cms'], null, false, (int)$id_lang);
|
||||
elseif ($controller == 'cms' && isset($params['id_cms_category']))
|
||||
return $this->getCMSCategoryLink((int)$params['id_cms_category'], null, (int)$id_lang);
|
||||
elseif (isset($params['fc']) && $params['fc'] == 'module')
|
||||
{
|
||||
$module = Validate::isModuleName(Tools::getValue('module')) ? Tools::getValue('module') : '';
|
||||
if (!empty($module))
|
||||
{
|
||||
unset($params['fc'], $params['module']);
|
||||
return $this->getModuleLink($module, $controller, $params, false, (int)$id_lang);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getPageLink($controller, false, $id_lang, $params);
|
||||
}
|
||||
@@ -618,12 +629,12 @@ class LinkCore
|
||||
return $url.(!strstr($url, '?') ? '?' : '&').'orderby='.urlencode($orderby).'&orderway='.urlencode($orderway);
|
||||
}
|
||||
|
||||
protected function getLangLink($id_lang = null, Context $context = null)
|
||||
protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
if (!$this->allow || !Language::isMultiLanguageActivated())
|
||||
if ((!$this->allow && in_array($id_shop, array($context->shop->id, null))) || !Language::isMultiLanguageActivated($id_shop) || !(int)Configuration::get('PS_REWRITING_SETTINGS', null, null, $id_shop))
|
||||
return '';
|
||||
|
||||
if (!$id_lang)
|
||||
|
||||
+6
-2
@@ -111,7 +111,8 @@ class MediaCore
|
||||
// In this case, we don't compress the content
|
||||
if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR)
|
||||
{
|
||||
error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
|
||||
if (_PS_MODE_DEV_)
|
||||
error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
|
||||
return $html_content_copy;
|
||||
}
|
||||
return $html_content;
|
||||
@@ -270,7 +271,10 @@ class MediaCore
|
||||
|
||||
if ($add_no_conflict)
|
||||
$return[] = Media::getJSPath(_PS_JS_DIR_.'jquery/jquery.noConflict.php?version='.$version);
|
||||
|
||||
|
||||
//added query migrate for compatibility with new version of jquery will be removed in ps 1.6
|
||||
$return[] = Media::getJSPath(_PS_JS_DIR_.'jquery/jquery-migrate-1.2.1.js');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1354,7 +1354,7 @@ class ProductCore extends ObjectModel
|
||||
$supplier_reference = '';
|
||||
|
||||
//Try to set the default supplier reference
|
||||
if (($id_supplier > 0) && ($id_product > 0))
|
||||
if (($id_supplier > 0) && ($this->id > 0))
|
||||
{
|
||||
$id_product_supplier = (int)ProductSupplier::getIdByProductAndSupplier($this->id, $id_product_attribute, $id_supplier);
|
||||
|
||||
@@ -4493,7 +4493,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
|
||||
/**
|
||||
* Webservice getter : get virtual field default combination
|
||||
*
|
||||
|
||||
@@ -66,7 +66,10 @@ class ProductSaleCore
|
||||
if ($page_number < 0) $page_number = 0;
|
||||
if ($nb_products < 1) $nb_products = 10;
|
||||
$final_order_by = $order_by;
|
||||
$order_table = '';
|
||||
if (is_null($order_by) || $order_by == 'position' || $order_by == 'price') $order_by = 'sales';
|
||||
if ($order_by == 'date_add' || $order_by == 'date_upd')
|
||||
$order_table = 'product_shop';
|
||||
if (is_null($order_way) || $order_by == 'sales') $order_way = 'DESC';
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||
@@ -108,7 +111,7 @@ class ProductSaleCore
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY '.$prefix.'`'.pSQL($order_by).'` '.pSQL($order_way).'
|
||||
ORDER BY '.(!empty($order_table) ? '`'.pSQL($order_table).'`.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).'
|
||||
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
+39
-13
@@ -93,8 +93,12 @@ define('PREG_CLASS_CJK', '\x{3041}-\x{30ff}\x{31f0}-\x{31ff}\x{3400}-\x{4db5}\x{
|
||||
|
||||
class SearchCore
|
||||
{
|
||||
public static function sanitize($string, $id_lang, $indexation = false)
|
||||
public static function sanitize($string, $id_lang, $indexation = false, $iso_code = false)
|
||||
{
|
||||
$string = trim($string);
|
||||
if (empty($string))
|
||||
return '';
|
||||
|
||||
$string = Tools::strtolower(strip_tags($string));
|
||||
$string = html_entity_decode($string, ENT_NOQUOTES, 'utf-8');
|
||||
|
||||
@@ -138,14 +142,34 @@ class SearchCore
|
||||
|
||||
if ($indexation)
|
||||
{
|
||||
$minWordLen = (int)Configuration::get('PS_SEARCH_MINWORDLEN');
|
||||
if ($minWordLen > 1)
|
||||
// If the language is constituted with symbol and there is no "words", then split every chars
|
||||
if (in_array($iso_code, array('zh', 'tw', 'ja')) && function_exists('mb_strlen'))
|
||||
{
|
||||
$minWordLen -= 1;
|
||||
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}(?=\s)/Su', ' ', $string);
|
||||
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}(?=\s)/Su', '', $string);
|
||||
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
||||
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
||||
// Cut symbols from letters
|
||||
$symbols = '';
|
||||
$letters = '';
|
||||
foreach (explode(' ', $string) as $mb_word)
|
||||
if (strlen(Tools::replaceAccentedChars($mb_word)) == mb_strlen(Tools::replaceAccentedChars($mb_word)))
|
||||
$letters .= $mb_word.' ';
|
||||
else
|
||||
$symbols .= $mb_word.' ';
|
||||
|
||||
if (preg_match_all('/./u', $symbols, $matches))
|
||||
$symbols = implode(' ', $matches[0]);
|
||||
|
||||
$string = $letters.$symbols;
|
||||
}
|
||||
else
|
||||
{
|
||||
$minWordLen = (int)Configuration::get('PS_SEARCH_MINWORDLEN');
|
||||
if ($minWordLen > 1)
|
||||
{
|
||||
$minWordLen -= 1;
|
||||
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}(?=\s)/Su', ' ', $string);
|
||||
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}(?=\s)/Su', '', $string);
|
||||
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
||||
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +199,7 @@ class SearchCore
|
||||
|
||||
$intersect_array = array();
|
||||
$score_array = array();
|
||||
$words = explode(' ', Search::sanitize($expr, $id_lang));
|
||||
$words = explode(' ', Search::sanitize($expr, $id_lang, false, $context->language->iso_code));
|
||||
|
||||
foreach ($words as $key => $word)
|
||||
if (!empty($word) && strlen($word) >= (int)Configuration::get('PS_SEARCH_MINWORDLEN'))
|
||||
@@ -383,7 +407,7 @@ class SearchCore
|
||||
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT p.id_product, pl.id_lang, pl.id_shop, pl.name pname, p.reference, p.ean13, p.upc,
|
||||
pl.description_short, pl.description, cl.name cname, m.name mname
|
||||
pl.description_short, pl.description, cl.name cname, m.name mname, l.iso_code
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl
|
||||
ON p.id_product = pl.id_product
|
||||
@@ -392,6 +416,8 @@ class SearchCore
|
||||
ON (cl.id_category = product_shop.id_category_default AND pl.id_lang = cl.id_lang AND cl.id_shop = product_shop.id_shop)
|
||||
LEFT JOIN '._DB_PREFIX_.'manufacturer m
|
||||
ON m.id_manufacturer = p.id_manufacturer
|
||||
LEFT JOIN '._DB_PREFIX_.'lang l
|
||||
ON l.id_lang = pl.id_lang
|
||||
WHERE product_shop.indexed = 0
|
||||
AND product_shop.visibility IN ("both", "search")
|
||||
'.($id_product ? 'AND p.id_product = '.(int)$id_product : '').'
|
||||
@@ -452,7 +478,6 @@ class SearchCore
|
||||
// Those are kind of global variables required to save the processed data in the database every X occurrences, in order to avoid overloading MySQL
|
||||
$count_words = 0;
|
||||
$query_array3 = array();
|
||||
$products_array = array();
|
||||
|
||||
// Every indexed words are cached into a PHP array
|
||||
$word_ids = $db->executeS('
|
||||
@@ -472,6 +497,7 @@ class SearchCore
|
||||
// Products are processed 50 by 50 in order to avoid overloading MySQL
|
||||
while (($products = Search::getProductsToIndex($total_languages, $id_product, 50)) && (count($products) > 0))
|
||||
{
|
||||
$products_array = array();
|
||||
// Now each non-indexed product is processed one by one, langage by langage
|
||||
foreach ($products as $product)
|
||||
{
|
||||
@@ -482,9 +508,9 @@ class SearchCore
|
||||
// Data must be cleaned of html, bad characters, spaces and anything, then if the resulting words are long enough, they're added to the array
|
||||
$product_array = array();
|
||||
foreach ($product as $key => $value)
|
||||
if (strncmp($key, 'id_', 3))
|
||||
if (strncmp($key, 'id_', 3) && isset($weight_array[$key]))
|
||||
{
|
||||
$words = explode(' ', Search::sanitize($value, (int)$product['id_lang'], true));
|
||||
$words = explode(' ', Search::sanitize($value, (int)$product['id_lang'], true, $product['iso_code']));
|
||||
foreach ($words as $word)
|
||||
if (!empty($word))
|
||||
{
|
||||
|
||||
@@ -704,6 +704,18 @@ class ToolsCore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear smarty cache folders
|
||||
*/
|
||||
public static function clearSmartyCache()
|
||||
{
|
||||
foreach (array(_PS_CACHE_DIR_.'smarty/cache', _PS_CACHE_DIR_.'smarty/compile') as $dir)
|
||||
if (file_exists($dir))
|
||||
foreach (scandir($dir) as $file)
|
||||
if ($file[0] != '.' && $file != 'index.php')
|
||||
self::deleteDirectory($dir.DIRECTORY_SEPARATOR.$file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an error according to an error code
|
||||
|
||||
@@ -399,10 +399,10 @@ class ValidateCore
|
||||
$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
|
||||
$events .= '|onselectstart|onstart|onstop';
|
||||
|
||||
if (preg_match('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
|
||||
if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
|
||||
return false;
|
||||
|
||||
if (!$allow_iframe && preg_match('/<[ \t\n]*(i?frame|form|input|embed|object)/ims', $html))
|
||||
if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
Vendored
+16
-7
@@ -44,11 +44,19 @@ class CacheMemcacheCore extends Cache
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
// Get keys (this code comes from Doctrine 2 project)
|
||||
$this->keys = array();
|
||||
$servers = self::getMemcachedServers();
|
||||
|
||||
if(is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats'))
|
||||
if(is_array($servers) && count($servers) > 0)
|
||||
{
|
||||
$this->keys = $this->memcache->get(_COOKIE_IV_);
|
||||
if (!is_array($this->keys))
|
||||
$this->keys = array();
|
||||
}
|
||||
|
||||
/*
|
||||
// Get keys (this code comes from Doctrine 2 project)
|
||||
if(is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats'))
|
||||
$all_slabs = $this->memcache->getStats('slabs');
|
||||
|
||||
if(isset($all_slabs) && is_array($all_slabs))
|
||||
@@ -56,11 +64,11 @@ class CacheMemcacheCore extends Cache
|
||||
{
|
||||
if (is_array($slabs))
|
||||
{
|
||||
foreach (array_keys($slabs) as $slab_id)
|
||||
foreach (array_keys($slabs) as $i => $slab_id) // $slab_id is not an int but a string, using the key instead ?
|
||||
{
|
||||
if(is_int($slab_id))
|
||||
{
|
||||
$dump = $this->memcache->getStats('cachedump', (int)$slab_id);
|
||||
if(is_int($i))
|
||||
{
|
||||
$dump = $this->memcache->getStats('cachedump', (int)$i);
|
||||
if ($dump)
|
||||
{
|
||||
foreach ($dump as $entries)
|
||||
@@ -73,7 +81,7 @@ class CacheMemcacheCore extends Cache
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
@@ -145,6 +153,7 @@ class CacheMemcacheCore extends Cache
|
||||
*/
|
||||
protected function _writeKeys()
|
||||
{
|
||||
$this->memcache->set(_COOKIE_IV_, $this->keys);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -387,7 +387,7 @@ class AdminControllerCore extends Controller
|
||||
$filter = '';
|
||||
foreach ($this->fields_list AS $field => $t)
|
||||
{
|
||||
if ($val = Tools::getValue($this->table.'Filter_'.$field))
|
||||
if ($val = htmlspecialchars(Tools::getValue($this->table.'Filter_'.$field), ENT_QUOTES, 'UTF-8'))
|
||||
{
|
||||
if(!is_array($val) && !empty($val))
|
||||
$filter .= ($filter ? ', ' : $this->l(' filter by ')).$t['title'].' : ';
|
||||
@@ -1192,6 +1192,9 @@ class AdminControllerCore extends Controller
|
||||
|
||||
protected function filterToField($key, $filter)
|
||||
{
|
||||
if (!isset($this->fields_list))
|
||||
return false;
|
||||
|
||||
foreach ($this->fields_list as $field)
|
||||
if (array_key_exists('filter_key', $field) && $field['filter_key'] == $key)
|
||||
return $field;
|
||||
@@ -1813,7 +1816,11 @@ class AdminControllerCore extends Controller
|
||||
$this->context->employee->logout();
|
||||
|
||||
if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack()))
|
||||
{
|
||||
if (isset($this->context->employee))
|
||||
$this->context->employee->logout();
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminLogin').((!isset($_GET['logout']) && $this->controller_name != 'AdminNotFound') ? '&redirect='.$this->controller_name : ''));
|
||||
}
|
||||
|
||||
// Set current index
|
||||
$current_index = 'index.php'.(($controller = Tools::getValue('controller')) ? '?controller='.$controller : '');
|
||||
|
||||
@@ -116,16 +116,16 @@ class FrontControllerCore extends Controller
|
||||
|
||||
// If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol
|
||||
if (Configuration::get('PS_SSL_ENABLED') && ($_SERVER['REQUEST_METHOD'] != 'POST') && $this->ssl != Tools::usingSecureMode())
|
||||
{
|
||||
{
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Cache-Control: no-cache');
|
||||
if ($this->ssl)
|
||||
if ($this->ssl)
|
||||
header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
|
||||
else
|
||||
else
|
||||
header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if ($this->ajax)
|
||||
{
|
||||
$this->display_header = false;
|
||||
@@ -333,7 +333,8 @@ class FrontControllerCore extends Controller
|
||||
'opc' => (bool)Configuration::get('PS_ORDER_PROCESS_TYPE'),
|
||||
'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE') || !(bool)Group::getCurrent()->show_prices,
|
||||
'b2b_enable' => (bool)Configuration::get('PS_B2B_ENABLE'),
|
||||
'request' => $link->getPaginationLink(false, false, false, true)
|
||||
'request' => $link->getPaginationLink(false, false, false, true),
|
||||
'PS_STOCK_MANAGEMENT' => Configuration::get('PS_STOCK_MANAGEMENT')
|
||||
));
|
||||
|
||||
// Add the tpl files directory for mobile
|
||||
@@ -593,7 +594,7 @@ class FrontControllerCore extends Controller
|
||||
|
||||
protected function canonicalRedirection($canonical_url = '')
|
||||
{
|
||||
if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET')
|
||||
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'];
|
||||
@@ -1137,4 +1138,4 @@ class FrontControllerCore extends Controller
|
||||
'logo_url' => $logo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ class HelperListCore extends Helper
|
||||
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)$tr['id_image'] : '').'.'.$this->imageType;
|
||||
else
|
||||
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.Image::getImgFolderStatic($tr['id_image']).(int)$tr['id_image'].'.'.$this->imageType;
|
||||
$this->_list[$index][$key] = ImageManager::thumbnail($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
|
||||
$this->_list[$index][$key] = ImageManager::thumbnail($path_to_image, $this->table.'_mini_'.$item_id.'_'.$this->context->shop->id.'.'.$this->imageType, 45, $this->imageType);
|
||||
}
|
||||
elseif (isset($params['icon']) && isset($tr[$key]) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
|
||||
{
|
||||
|
||||
+19
-14
@@ -292,15 +292,17 @@ abstract class ModuleCore
|
||||
else
|
||||
{
|
||||
if (!$upgrade_detail['number_upgraded'])
|
||||
$this->_errors[] = $this->l('None upgrades have been applied');
|
||||
$this->_errors[] = $this->l('No upgrade has been applied');
|
||||
else
|
||||
{
|
||||
$this->_errors[] = $this->l('Upgraded from: ').$upgrade_detail['upgraded_from'].$this->l(' to ').
|
||||
$upgrade_detail['upgraded_to'];
|
||||
$this->_errors[] = sprintf($this->l('Upgraded from: %S to %s'), $upgrade_detail['upgraded_from'], $upgrade_detail['upgraded_to']);
|
||||
$this->_errors[] = $upgrade_detail['number_upgrade_left'].' '.$this->l('upgrade left');
|
||||
}
|
||||
|
||||
$this->_errors[] = $this->l('To prevent any problem, this module has been turned off');
|
||||
if ($upgrade_detail['duplicate'])
|
||||
$this->_errors[] = sprintf(Tools::displayError('Module %s cannot be upgraded this time: please refresh this page to update it.'), $this->name);
|
||||
else
|
||||
$this->_errors[] = $this->l('To prevent any problem, this module has been turned off');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,19 +350,21 @@ abstract class ModuleCore
|
||||
$upgrade = &self::$modules_cache[$this->name]['upgrade'];
|
||||
foreach ($upgrade['upgrade_file_left'] as $num => $file_detail)
|
||||
{
|
||||
// Default variable required in the included upgrade file need to be set by default there:
|
||||
// upgrade_version, success_upgrade
|
||||
$upgrade_result = false;
|
||||
if (function_exists($file_detail['upgrade_function']))
|
||||
{
|
||||
$upgrade['success'] = false;
|
||||
$upgrade['duplicate'] = true;
|
||||
break;
|
||||
}
|
||||
include($file_detail['file']);
|
||||
|
||||
// Call the upgrade function if defined
|
||||
$upgrade['success'] = false;
|
||||
if (function_exists($file_detail['upgrade_function']))
|
||||
$upgrade_result = $file_detail['upgrade_function']($this);
|
||||
|
||||
$upgrade['success'] = $upgrade_result;
|
||||
$upgrade['success'] = $file_detail['upgrade_function']($this);
|
||||
|
||||
// Set detail when an upgrade succeed or failed
|
||||
if ($upgrade_result)
|
||||
if ($upgrade['success'])
|
||||
{
|
||||
$upgrade['number_upgraded'] += 1;
|
||||
$upgrade['upgraded_to'] = $file_detail['version'];
|
||||
@@ -378,6 +382,7 @@ abstract class ModuleCore
|
||||
}
|
||||
|
||||
$upgrade['number_upgrade_left'] = count($upgrade['upgrade_file_left']);
|
||||
|
||||
// Update module version in DB with the last succeed upgrade
|
||||
if ($upgrade['upgraded_to'])
|
||||
Module::upgradeModuleVersion($this->name, $upgrade['upgraded_to']);
|
||||
@@ -396,9 +401,9 @@ abstract class ModuleCore
|
||||
public static function upgradeModuleVersion($name, $version)
|
||||
{
|
||||
return Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'module` m
|
||||
SET m.version = \''.bqSQL($version).'\'
|
||||
WHERE m.name = \''.bqSQL($name).'\'');
|
||||
UPDATE `'._DB_PREFIX_.'module` m
|
||||
SET m.version = \''.bqSQL($version).'\'
|
||||
WHERE m.name = \''.bqSQL($name).'\'');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,8 +125,8 @@ class OrderHistoryCore extends ObjectModel
|
||||
.'&id_order='.(int)$order->id
|
||||
.'&secure_key='.$order->secure_key;
|
||||
$assign[$key]['link'] = $dl_link;
|
||||
if (isset($virtual_product['date_expiration']) && $virtual_product['date_expiration'] != '0000-00-00 00:00:00')
|
||||
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['date_expiration ']);
|
||||
if (isset($virtual_product['download_deadline']) && $virtual_product['download_deadline'] != '0000-00-00 00:00:00')
|
||||
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline ']);
|
||||
if ($product_download->nb_downloadable != 0)
|
||||
$assign[$key]['downloadable'] = (int)$product_download->nb_downloadable;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class HTMLTemplateOrderReturnCore extends HTMLTemplate
|
||||
|
||||
// header informations
|
||||
$this->date = Tools::displayDate($this->order->invoice_date);
|
||||
$this->title = HTMLTemplateOrderReturn::l('Order Return ').sprintf('%06d', $this->order_return->id);
|
||||
$this->title = sprintf(HTMLTemplateOrderReturn::l('Order Return %s'), sprintf('%06d', $this->order_return->id));
|
||||
|
||||
// footer informations
|
||||
$this->shop = new Shop((int)$this->order->id_shop);
|
||||
|
||||
@@ -45,7 +45,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
|
||||
$this->smarty = $smarty;
|
||||
|
||||
// header informations
|
||||
$this->date = Tools::displayDate($this->order->invoice_date, (int)$this->order->id_lang);
|
||||
$this->date = Tools::displayDate($this->order_slip->date_add);
|
||||
$this->title = HTMLTemplateOrderSlip::l('Slip #').Configuration::get('PS_CREDIT_SLIP_PREFIX', Context::getContext()->language->id).sprintf('%06d', (int)$this->order_slip->id);
|
||||
|
||||
// footer informations
|
||||
|
||||
@@ -45,7 +45,7 @@ class HTMLTemplateSupplyOrderFormCore extends HTMLTemplate
|
||||
$this->address_supplier = new Address(Address::getAddressIdBySupplierId((int)$supply_order->id_supplier));
|
||||
|
||||
// header informations
|
||||
$this->date = Tools::displayDate($supply_order->date_add, (int)$this->supply_order->id_lang);
|
||||
$this->date = Tools::displayDate($supply_order->date_add);
|
||||
$this->title = HTMLTemplateSupplyOrderForm::l('Supply order form');
|
||||
}
|
||||
|
||||
|
||||
@@ -53,22 +53,15 @@ class TaxRulesGroupCore extends ObjectModel
|
||||
|
||||
protected static $_taxes = array();
|
||||
|
||||
public static function getTaxRulesGroups($only_active = true, $multiShop = false)
|
||||
public static function getTaxRulesGroups($only_active = true)
|
||||
{
|
||||
if ((bool)$multiShop) {
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT DISTINCT g.id_tax_rules_group, g.name, g.active
|
||||
FROM `'._DB_PREFIX_.'tax_rules_group` g'
|
||||
.Shop::addSqlAssociation('tax_rules_group', 'g')
|
||||
.($only_active ? ' WHERE g.`active` = 1' : '').'
|
||||
ORDER BY name ASC');
|
||||
} else {
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'tax_rules_group` g'
|
||||
.($only_active ? ' WHERE g.`active` = 1' : '').'
|
||||
ORDER BY name ASC');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1264,14 +1264,22 @@ class WebserviceRequestCore
|
||||
$assoc = Shop::getAssoTable($this->resourceConfiguration['retrieveData']['table']);
|
||||
if ($assoc !== false)
|
||||
{
|
||||
$check_shop_group = false;
|
||||
|
||||
$sql = 'SELECT 1
|
||||
FROM `'.bqSQL(_DB_PREFIX_.$this->resourceConfiguration['retrieveData']['table']);
|
||||
if ($assoc['type'] != 'fk_shop')
|
||||
$sql .= '_'.$assoc['type'];
|
||||
else
|
||||
{
|
||||
$def = ObjectModel::getDefinition($this->resourceConfiguration['retrieveData']['className']);
|
||||
if (isset($def['fields']) && isset($def['fields']['id_shop_group']))
|
||||
$check_shop_group = true;
|
||||
}
|
||||
$sql .= '`';
|
||||
|
||||
foreach (self::$shopIDs as $id_shop)
|
||||
$OR[] = ' id_shop = '.(int)$id_shop.' ';
|
||||
$OR[] = ' (id_shop = '.(int)$id_shop.($check_shop_group ? ' OR (id_shop = 0 AND id_shop_group='.(int)Shop::getGroupFromShop((int)$id_shop).')' : '').') ';
|
||||
|
||||
$check = ' WHERE ('.implode('OR', $OR).') AND `'.bqSQL($this->resourceConfiguration['fields']['id']['sqlId']).'` = '.(int)$this->urlSegment[1];
|
||||
if (!Db::getInstance()->getValue($sql.$check))
|
||||
|
||||
Reference in New Issue
Block a user