diff --git a/admin-dev/themes/default/template/footer.tpl b/admin-dev/themes/default/template/footer.tpl index 8caf2c64a..66fefae89 100644 --- a/admin-dev/themes/default/template/footer.tpl +++ b/admin-dev/themes/default/template/footer.tpl @@ -39,7 +39,8 @@ {/if} | {l s='Contact'}{l s='Bug Tracker'} - | {l s='Forum'} + | {l s='Forum'} + | {l s='Addons'} diff --git a/classes/Employee.php b/classes/Employee.php index 78c0dac5a..3f390d7ca 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -249,7 +249,7 @@ 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, Context::getContext()->cookie->passwd) - && (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP')) + && (!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; } diff --git a/classes/Product.php b/classes/Product.php index d2d49913e..404dfc4ab 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -4493,7 +4493,7 @@ class ProductCore extends ObjectModel return true; } - /* + /** * Webservice getter : get virtual field default combination * diff --git a/classes/ProductSale.php b/classes/ProductSale.php index cc1922ef0..2f8166a4d 100644 --- a/classes/ProductSale.php +++ b/classes/ProductSale.php @@ -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); diff --git a/classes/Search.php b/classes/Search.php index eb3f0985e..32025f14b 100644 --- a/classes/Search.php +++ b/classes/Search.php @@ -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 : '').' @@ -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)) { diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index e36804246..21abf5180 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1813,7 +1813,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 : ''); diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 3117d655f..c5ce065ad 100755 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -114,21 +114,18 @@ class FrontControllerCore extends Controller $css_files = $this->css_files; $js_files = $this->js_files; - if ($this->ssl && !Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) - { + // 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'); - header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); + if ($this->ssl) + header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); + else + header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']); exit(); } - elseif (Configuration::get('PS_SSL_ENABLED') && Tools::usingSecureMode() && !($this->ssl)) - { - header('HTTP/1.1 301 Moved Permanently'); - header('Cache-Control: no-cache'); - header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']); - exit(); - } - + if ($this->ajax) { $this->display_header = false; diff --git a/classes/module/Module.php b/classes/module/Module.php index b323204b6..8fcbddd8c 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -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).'\''); } /** diff --git a/classes/pdf/HTMLTemplateOrderSlip.php b/classes/pdf/HTMLTemplateOrderSlip.php index 95d9b9f1f..e84725f57 100644 --- a/classes/pdf/HTMLTemplateOrderSlip.php +++ b/classes/pdf/HTMLTemplateOrderSlip.php @@ -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, (int)$this->order->id_lang); $this->title = HTMLTemplateOrderSlip::l('Slip #').Configuration::get('PS_CREDIT_SLIP_PREFIX', Context::getContext()->language->id).sprintf('%06d', (int)$this->order_slip->id); // footer informations diff --git a/controllers/admin/AdminCarrierWizardController.php b/controllers/admin/AdminCarrierWizardController.php index 2c85f8c40..c5a331648 100644 --- a/controllers/admin/AdminCarrierWizardController.php +++ b/controllers/admin/AdminCarrierWizardController.php @@ -716,7 +716,8 @@ class AdminCarrierWizardControllerCore extends AdminController if ($logo && !empty($logo['tmp_name']) && $logo['tmp_name'] != 'none' && (!isset($logo['error']) || !$logo['error']) && preg_match('/\.(jpe?g|gif|png)$/', $logo['name']) - && is_uploaded_file($logo['tmp_name'])) + && is_uploaded_file($logo['tmp_name']) + && ImageManager::isRealImage($logo['tmp_name'])) { $file = $logo['tmp_name']; do $tmp_name = uniqid().'.jpg'; diff --git a/controllers/admin/AdminHomeController.php b/controllers/admin/AdminHomeController.php index 6922490a4..45797273e 100644 --- a/controllers/admin/AdminHomeController.php +++ b/controllers/admin/AdminHomeController.php @@ -499,7 +499,7 @@ class AdminHomeControllerCore extends AdminController // DISCOVER PRESTASHOP $result['discover_prestashop'] = '
'.$this->getBlockDiscover().'
'; - $result['discover_prestashop'] .= '
'; + $result['discover_prestashop'] .= '
'; // SHOW TIPS OF THE DAY $content = Tools::file_get_contents($protocol.'api.prestashop.com/partner/tipsoftheday/?iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser), false, $stream_context); diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index f76c9133b..dc2b3cdd9 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -630,9 +630,8 @@ class AdminModulesControllerCore extends AdminController if (!$download_ok) $this->errors[] = $this->l('Error on downloading the lastest version'); - else - if(!$this->extractArchive(_PS_MODULE_DIR_.$modaddons->name.'.zip', false)) - $this->errors[] = $this->l(sprintf("Module %s can't be upgraded: ", $modaddons->name)); + elseif (!$this->extractArchive(_PS_MODULE_DIR_.$modaddons->name.'.zip', false)) + $this->errors[] = $this->l(sprintf("Module %s can't be upgraded: ", $modaddons->name)); } } } @@ -674,18 +673,18 @@ class AdminModulesControllerCore extends AdminController // Get the return value of current method $echo = $module->{$method}(); - + // After a successful install of a single module that has a configuration method, to the configuration page if ($key == 'install' && $echo === true && strpos(Tools::getValue('install'), '|') === false && method_exists($module, 'getContent')) Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&configure='.$module->name.'&conf=12'); } - + // If the method called is "configure" (getContent method), we show the html code of configure page if ($key == 'configure' && Module::isInstalled($module->name)) { if (isset($module->multishop_context)) $this->multishop_context = $module->multishop_context; - + $backlink = self::$currentIndex.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name; $hooklink = 'index.php?tab=AdminModulesPositions&token='.Tools::getAdminTokenLite('AdminModulesPositions').'&show_modules='.(int)$module->id; $tradlink = 'index.php?tab=AdminTranslations&token='.Tools::getAdminTokenLite('AdminTranslations').'&type=modules&lang='; @@ -768,10 +767,8 @@ class AdminModulesControllerCore extends AdminController Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(isset($modules_list_save) ? '&modules_list='.$modules_list_save : '').$params); } - if(isset($_GET['update'])) - { + if (isset($_GET['update'])) Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&updated=1tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(isset($modules_list_save) ? '&modules_list='.$modules_list_save : '').$params); - } } public function postProcess() @@ -779,7 +776,6 @@ class AdminModulesControllerCore extends AdminController // Parent Post Process parent::postProcess(); - // Get the list of installed module ans prepare it for ajax call. if (($list = Tools::getValue('installed_modules'))) Context::getContext()->smarty->assign('installed_modules', Tools::jsonEncode(explode('|', $list))); diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 828238c7c..c9d01abe6 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -33,6 +33,7 @@ class CartControllerCore extends FrontController protected $id_address_delivery; protected $customization_id; protected $qty; + public $ssl = false; protected $ajax_refresh = false; diff --git a/js/admin_carrier_wizard.js b/js/admin_carrier_wizard.js index c43431d6a..540de14ba 100644 --- a/js/admin_carrier_wizard.js +++ b/js/admin_carrier_wizard.js @@ -44,7 +44,8 @@ function initCarrierWizard() 'onLeaveStep' : onLeaveStepCallback, 'onFinish' : onFinishCallback, 'transitionEffect' : 'slideleft', - 'enableAllSteps' : enableAllSteps + 'enableAllSteps' : enableAllSteps, + 'keyNavigation' : false }); displayRangeType(); } diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index b2a18e831..859337e26 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -445,14 +445,21 @@ class BlockLayered extends Module static $_MODULES = array(); global $_MODULE; - $file = _PS_MODULE_DIR_.$this->name.'/'.Language::getIsoById($id_lang).'.php'; if (!array_key_exists($id_lang, $_MODULES)) { - if (!file_exists($file)) + if (file_exists($file1 = _PS_MODULE_DIR_.$this->name.'/translations/'.Language::getIsoById($id_lang).'.php')) + { + include($file1); + $_MODULES[$id_lang] = $_MODULE; + } + elseif (file_exists($file2 = _PS_MODULE_DIR_.$this->name.'/'.Language::getIsoById($id_lang).'.php')) + { + include($file2); + $_MODULES[$id_lang] = $_MODULE; + } + else return $string; - include($file); - $_MODULES[$id_lang] = $_MODULE; } $string = str_replace('\'', '\\\'', $string); @@ -936,25 +943,25 @@ class BlockLayered extends Module SELECT count(DISTINCT p.`id_product`) FROM '._DB_PREFIX_.'product p INNER JOIN `'._DB_PREFIX_.'product_shop` ps - ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1)'); + ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1 AND ps.`visibility` IN ("both", "catalog"))'); else $nb_products = (int)Db::getInstance()->getValue(' SELECT count(DISTINCT p.`id_product`) FROM '._DB_PREFIX_.'product p - WHERE `active` = 1'); + WHERE `active` = 1 AND `visibility` IN ("both", "catalog")'); else if (version_compare(_PS_VERSION_,'1.5','>')) $nb_products = (int)Db::getInstance()->getValue(' SELECT COUNT(DISTINCT p.`id_product`) FROM `'._DB_PREFIX_.'product` p INNER JOIN `'._DB_PREFIX_.'product_shop` ps - ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1) + ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1 AND ps.`visibility` IN ("both", "catalog")) LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) WHERE psi.id_product IS NULL'); else $nb_products = (int)Db::getInstance()->getValue(' SELECT COUNT(DISTINCT p.`id_product`) FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) - WHERE `active` = 1 AND psi.id_product IS NULL'); + WHERE `active` = 1 AND `visibility` IN ("both", "catalog") AND psi.id_product IS NULL'); $max_executiontime = @ini_get('max_execution_time'); if ($max_executiontime > 5 || $max_executiontime <= 0) @@ -1015,14 +1022,14 @@ class BlockLayered extends Module SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p INNER JOIN `'._DB_PREFIX_.'product_shop` ps - ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1) + ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1 AND ps.`visibility` IN ("both", "catalog")) GROUP BY p.`id_product` ORDER BY p.`id_product` LIMIT '.(int)$cursor.','.(int)$length; else $query = ' SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p - WHERE `active` = 1 + WHERE `active` = 1 AND `visibility` IN ("both", "catalog") GROUP BY p.`id_product` ORDER BY p.`id_product` LIMIT '.(int)$cursor.','.(int)$length; else @@ -1031,7 +1038,7 @@ class BlockLayered extends Module SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p INNER JOIN `'._DB_PREFIX_.'product_shop` ps - ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1) + ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1 AND ps.`visibility` IN ("both", "catalog")) LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) WHERE psi.id_product IS NULL GROUP BY p.`id_product` @@ -1041,7 +1048,7 @@ class BlockLayered extends Module SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) - WHERE `active` = 1 AND psi.id_product IS NULL + WHERE `active` = 1 AND `visibility` IN ("both", "catalog") AND psi.id_product IS NULL GROUP BY p.`id_product` ORDER BY p.`id_product` LIMIT 0,'.(int)$length; @@ -2322,7 +2329,7 @@ class BlockLayered extends Module $alias_where = 'p'; if (version_compare(_PS_VERSION_,'1.5','>')) $alias_where = 'product_shop'; - $query_filters_where = ' AND '.$alias_where.'.`active` = 1'; + $query_filters_where = ' AND '.$alias_where.'.`active` = 1 AND '.$alias_where.'.`visibility` IN ("both", "catalog")'; $query_filters_from = ''; $parent = new Category((int)$id_parent); @@ -2518,7 +2525,7 @@ class BlockLayered extends Module '.($alias_where == 'p' ? '' : 'product_shop.*,' ).' '.$alias_where.'.id_category_default, pl.*, - i.id_image, + image_shop.`id_image`, il.legend, m.name manufacturer_name, DATEDIFF('.$alias_where.'.`date_add`, DATE_SUB(NOW(), INTERVAL '.(int)$nb_day_new_product.' DAY)) > 0 AS new @@ -2527,12 +2534,12 @@ class BlockLayered extends Module LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '.$join.' LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.Shop::addSqlRestrictionOnLang('pl').' AND pl.id_lang = '.(int)$cookie->id_lang.') - LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1) - LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = '.(int)($cookie->id_lang).') + LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' + LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$cookie->id_lang.') LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) - WHERE '.$alias_where.'.`active` = 1 AND - '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' - AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' + WHERE (i.id_image IS NULL OR image_shop.id_shop='.(int)Context::getContext()->shop->id.') + AND '.$alias_where.'.`active` = 1 AND '.$alias_where.'.`visibility` IN ("both", "catalog") + AND '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' AND c.active = 1 AND p.id_product IN ('.implode(',', $product_id_list).') GROUP BY cp.id_product @@ -2632,10 +2639,10 @@ class BlockLayered extends Module { $sql_query['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)$this->context->shop->id.') '; - $sql_query['where'] = 'WHERE product_shop.`active` = 1 '; + $sql_query['where'] = 'WHERE product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "catalog") '; } else - $sql_query['where'] = 'WHERE p.`active` = 1 '; + $sql_query['where'] = 'WHERE p.`active` = 1 AND p.`visibility` IN ("both", "catalog") '; $sql_query['group'] = ' GROUP BY p.id_product '; break; @@ -2650,8 +2657,8 @@ class BlockLayered extends Module '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' AND c.active = 1 - AND '.$alias.'.active = 1'; - $sql_query['group'] = ' GROUP BY p.id_manufacturer '; + AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog")'; + $sql_query['group'] = ' GROUP BY p.id_manufacturer ORDER BY m.name'; if (!Configuration::get('PS_LAYERED_HIDE_0_VALUES')) { @@ -2667,8 +2674,8 @@ class BlockLayered extends Module WHERE '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' AND c.active = 1 - AND '.$alias.'.active = 1 - GROUP BY p.id_manufacturer'; + AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") + GROUP BY p.id_manufacturer ORDER BY m.name'; } break; @@ -2698,13 +2705,15 @@ class BlockLayered extends Module $sql_query['where'] = 'WHERE a.id_attribute_group = '.(int)$filter['id_value']; if (version_compare(_PS_VERSION_,'1.5','>')) $sql_query['where'] .= ' AND lpa.`id_shop` = '.(int)Context::getContext()->shop->id; - $sql_query['where'] .= ' AND '.$alias.'.active = 1 AND p.id_product IN ( - SELECT id_product - FROM '._DB_PREFIX_.'category_product cp - INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND - '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' - AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' - AND c.active = 1)) '; + $sql_query['where'] .= ' AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") + AND p.id_product IN ( + SELECT id_product + FROM '._DB_PREFIX_.'category_product cp + INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND + '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' + AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' + AND c.active = 1) + ) '; $sql_query['group'] = ' GROUP BY lpa.id_attribute ORDER BY ag.`position` ASC, a.`position` ASC'; @@ -2713,31 +2722,28 @@ class BlockLayered extends Module { $sql_query['second_query'] = ' SELECT 0 nbr, lpa.id_attribute_group, - a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group, - liagl.url_name name_url_name, liagl.meta_title name_meta_title, lial.url_name value_url_name, lial.meta_title value_meta_title - + a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group, + liagl.url_name name_url_name, liagl.meta_title name_meta_title, lial.url_name value_url_name, lial.meta_title value_meta_title FROM '._DB_PREFIX_.'layered_product_attribute lpa '.(version_compare(_PS_VERSION_,'1.5','>') ? Shop::addSqlAssociation('product', 'lpa') : '').' INNER JOIN '._DB_PREFIX_.'attribute a - ON a.id_attribute = lpa.id_attribute + ON a.id_attribute = lpa.id_attribute INNER JOIN '._DB_PREFIX_.'attribute_lang al - ON al.id_attribute = a.id_attribute - AND al.id_lang = '.$id_lang.' + ON al.id_attribute = a.id_attribute AND al.id_lang = '.$id_lang.' INNER JOIN '._DB_PREFIX_.'product as p - ON p.id_product = lpa.id_product + ON p.id_product = lpa.id_product INNER JOIN '._DB_PREFIX_.'attribute_group ag - ON ag.id_attribute_group = lpa.id_attribute_group + ON ag.id_attribute_group = lpa.id_attribute_group INNER JOIN '._DB_PREFIX_.'attribute_group_lang agl - ON agl.id_attribute_group = lpa.id_attribute_group + ON agl.id_attribute_group = lpa.id_attribute_group AND agl.id_lang = '.$id_lang.' LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value liagl - ON (liagl.id_attribute_group = lpa.id_attribute_group AND liagl.id_lang = '.$id_lang.') + ON (liagl.id_attribute_group = lpa.id_attribute_group AND liagl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_lang_value lial - ON (lial.id_attribute = lpa.id_attribute AND lial.id_lang = '.$id_lang.') - - WHERE '.$alias.'.active = 1 AND a.id_attribute_group = '.(int)$filter['id_value'].' + ON (lial.id_attribute = lpa.id_attribute AND lial.id_lang = '.$id_lang.') + WHERE '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") + AND a.id_attribute_group = '.(int)$filter['id_value'].' '.(version_compare(_PS_VERSION_,'1.5','>') ? 'AND lpa.`id_shop` = '.(int)Context::getContext()->shop->id : '').' - GROUP BY lpa.id_attribute ORDER BY id_attribute_group, id_attribute'; } @@ -2757,7 +2763,8 @@ class BlockLayered extends Module ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_value_lang_value lifvl ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = '.$id_lang.') '; - $sql_query['where'] = 'WHERE '.$alias.'.`active` = 1 AND fp.id_feature = '.(int)$filter['id_value'].' + $sql_query['where'] = 'WHERE '.$alias.'.`active` = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") + AND fp.id_feature = '.(int)$filter['id_value'].' AND p.id_product IN ( SELECT id_product FROM '._DB_PREFIX_.'category_product cp @@ -2781,10 +2788,11 @@ class BlockLayered extends Module INNER JOIN '._DB_PREFIX_.'feature_value fv ON (fv.id_feature_value = fp.id_feature_value AND (fv.custom IS NULL OR fv.custom = 0)) LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_lang_value lifl - ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = '.$id_lang.') + ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_value_lang_value lifvl - ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = '.$id_lang.') - WHERE '.$alias.'.`active` = 1 AND fp.id_feature = '.(int)$filter['id_value'].' + ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = '.$id_lang.') + WHERE '.$alias.'.`active` = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") + AND fp.id_feature = '.(int)$filter['id_value'].' GROUP BY fv.id_feature_value'; } @@ -2801,7 +2809,8 @@ class BlockLayered extends Module FROM '._DB_PREFIX_.'category_product cp LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product) '; $sql_query['where'] = ' - WHERE cp.id_category = c.id_category AND '.$alias.'.active = 1 '; + WHERE cp.id_category = c.id_category + AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog")'; $sql_query['group'] = ') count_products FROM '._DB_PREFIX_.'category c LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category AND cl.id_lang = '.$id_lang.') @@ -3855,10 +3864,9 @@ class BlockLayered extends Module public function ajaxCall() { - global $smarty; + global $smarty, $cookie; $selected_filters = $this->getSelectedFilters(); - $this->getProducts($selected_filters, $products, $nb_products, $p, $n, $pages_nb, $start, $stop, $range); // Add pagination variable @@ -3871,8 +3879,8 @@ class BlockLayered extends Module array( 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'nb_products' => $nb_products, - 'category' => (object)array('id' => Tools::getValue('id_category_layered', 1)), - 'pages_nb' => (int)($pages_nb), + 'category' => new Category(Tools::getValue('id_category_layered', 1), (int)$cookie->id_lang), + 'pages_nb' => (int)$pages_nb, 'p' => (int)$p, 'n' => (int)$n, 'range' => (int)$range, @@ -4013,8 +4021,8 @@ class BlockLayered extends Module LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category) WHERE c.active = 1'. (count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : '').' - AND '.$alias.'.active = 1'. - (count($products_ids) ? ' AND p.id_product IN ('.implode(',', $products_ids).')' : '')); + AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") + '.(count($products_ids) ? 'AND p.id_product IN ('.implode(',', $products_ids).')' : '')); $attribute_groups_by_id = array(); while ($row = $db->nextRow($attribute_groups)) @@ -4029,7 +4037,7 @@ class BlockLayered extends Module LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product) LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category) WHERE (fv.custom IS NULL OR fv.custom = 0) AND c.active = 1'.(count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : '').' - AND '.$alias.'.active = 1'.(count($products_ids) ? ' AND p.id_product IN ('.implode(',', $products_ids).')' : '')); + AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") '.(count($products_ids) ? 'AND p.id_product IN ('.implode(',', $products_ids).')' : '')); $features_by_id = array(); while ($row = $db->nextRow($features)) @@ -4048,9 +4056,9 @@ class BlockLayered extends Module LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON (pa.id_product = p.id_product) '.$join_product.$join_product_attribute.' LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute) - WHERE c.active = 1'.(count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : ''). - ' AND '.$alias.'.active = 1'. - (count($products_ids) ? ' AND p.id_product IN ('.implode(',', $products_ids).')' : ''). + WHERE c.active = 1'.(count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : '').' + AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") + '.(count($products_ids) ? 'AND p.id_product IN ('.implode(',', $products_ids).')' : ''). ' AND (fv.custom IS NULL OR fv.custom = 0) GROUP BY p.id_product'); diff --git a/modules/blocklayered/config.xml b/modules/blocklayered/config.xml index da98eb84b..e6b78b59b 100644 --- a/modules/blocklayered/config.xml +++ b/modules/blocklayered/config.xml @@ -1,9 +1,9 @@ blocklayered - + - + 1 diff --git a/modules/blockmyaccountfooter/blockmyaccount.css b/modules/blockmyaccountfooter/blockmyaccount.css index 0d416fbcf..38720d562 100644 --- a/modules/blockmyaccountfooter/blockmyaccount.css +++ b/modules/blockmyaccountfooter/blockmyaccount.css @@ -1,6 +1,7 @@ /* block myaccount */ -.myaccount ul {margin-bottom:10px} -.myaccount li {border-bottom: 1px solid #eee} +.myaccount ul {margin-bottom:10px;} +.myaccount .bullet .icon {display: none;} +.myaccount li {border-bottom: 1px solid #eee;} .myaccount li a { display: block; padding: 7px 11px 5px 22px; @@ -10,16 +11,14 @@ .myaccount p.logout { padding-bottom:0; font-weight:bold; - text-align:right + text-align:right; } - - /* block myaccount in footer */ #footer .myaccount .title_block, #footer .myaccount h4 {background: none;} #footer .myaccount .logout {display:none;} #footer .myaccount .title_block, #footer .myaccount h4 { padding:0 0 10px 0; - background:none + background:none; } #footer .myaccount ul {margin-bottom:0} #footer .myaccount li {border-bottom:none} @@ -27,7 +26,6 @@ display: block; padding:0; color: #fff; - background: none -} -#footer .myaccount li.lnk_wishlist img {display:none + background: none; } +#footer .myaccount li.lnk_wishlist img {display:none;} \ No newline at end of file diff --git a/modules/blocktopmenu/blocktopmenu.php b/modules/blocktopmenu/blocktopmenu.php index eeecaf4d4..724ea4da3 100644 --- a/modules/blocktopmenu/blocktopmenu.php +++ b/modules/blocktopmenu/blocktopmenu.php @@ -52,7 +52,7 @@ class Blocktopmenu extends Module { $this->name = 'blocktopmenu'; $this->tab = 'front_office_features'; - $this->version = 1.5; + $this->version = 1.6; $this->author = 'PrestaShop'; parent::__construct(); @@ -69,6 +69,7 @@ class Blocktopmenu extends Module !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1') || !$this->registerHook('actionObjectCategoryUpdateAfter') || !$this->registerHook('actionObjectCategoryDeleteAfter') || + !$this->registerHook('actionObjectCategoryAddAfter') || !$this->registerHook('actionObjectCmsUpdateAfter') || !$this->registerHook('actionObjectCmsDeleteAfter') || !$this->registerHook('actionObjectSupplierUpdateAfter') || @@ -797,7 +798,11 @@ class Blocktopmenu extends Module return Db::getInstance()->executeS($sql); } - + + public function hookActionObjectCategoryAddAfter($params) + { + $this->clearMenuCache(); + } public function hookActionObjectCategoryUpdateAfter($params) { diff --git a/modules/blocktopmenu/config.xml b/modules/blocktopmenu/config.xml index f1508b13b..0b21e24e8 100644 --- a/modules/blocktopmenu/config.xml +++ b/modules/blocktopmenu/config.xml @@ -2,7 +2,7 @@ blocktopmenu - + diff --git a/modules/blocktopmenu/upgrade/install-1.6.php b/modules/blocktopmenu/upgrade/install-1.6.php new file mode 100644 index 000000000..90183557b --- /dev/null +++ b/modules/blocktopmenu/upgrade/install-1.6.php @@ -0,0 +1,9 @@ +registerHook('actionObjectCategoryAddAfter')); +} diff --git a/modules/homeslider/upgrade/install-1.2.1.php b/modules/homeslider/upgrade/install-1.2.1.php index 7817ecaf7..2d3d12abd 100644 --- a/modules/homeslider/upgrade/install-1.2.1.php +++ b/modules/homeslider/upgrade/install-1.2.1.php @@ -16,9 +16,9 @@ function upgrade_module_1_2_1($object) function homeslider_stripslashes_field($field) { - $quotes = array('\'\\\\\'\'', '\'\\\'\''); - $dquotes = array('\'\\"\'', '\'"\''); - $backslashes = array('\'\\\\\'', '\'\\\''); + $quotes = array('"\\\'"', '"\'"'); + $dquotes = array('\'\\\\"\'', '\'"\''); + $backslashes = array('"\\\\\\\\"', '"\\\\"'); return '`'.bqSQL($field).'` = replace(replace(replace(`'.bqSQL($field).'`, '.$quotes[0].', '.$quotes[1].'), '.$dquotes[0].', '.$dquotes[1].'), '.$backslashes[0].', '.$backslashes[1].')'; } \ No newline at end of file diff --git a/themes/live_edit.tpl b/themes/live_edit.tpl index 52f28163b..fe6497ede 100644 --- a/themes/live_edit.tpl +++ b/themes/live_edit.tpl @@ -24,11 +24,11 @@ *}