From 6824518b7423d29f5d5cb1d08e66f5e85c7157e0 Mon Sep 17 00:00:00 2001 From: Shagshag Date: Fri, 4 Jan 2013 17:07:36 +0100 Subject: [PATCH 01/68] Update classes/cache/CacheMemcache.php --- classes/cache/CacheMemcache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/cache/CacheMemcache.php b/classes/cache/CacheMemcache.php index 543a7e797..a7d825d7b 100755 --- a/classes/cache/CacheMemcache.php +++ b/classes/cache/CacheMemcache.php @@ -83,7 +83,7 @@ class CacheMemcacheCore extends Cache if (!$servers) return false; foreach ($servers as $server) - $this->memcache->addServer($server['ip'], $server['port'], $server['weight']); + $this->memcache->addServer($server['ip'], $server['port'], true, (int) $server['weight']); $this->is_connected = true; } From 868effab13cf9c1058418f2b2a1842ce6aa7d070 Mon Sep 17 00:00:00 2001 From: Shagshag Date: Tue, 8 Jan 2013 10:51:42 +0100 Subject: [PATCH 02/68] [-] Fix: OrderHistory::changeIdOrderState &$id_order break compatibility with existing codes : 1/ it's unnecessary : Objects are passed by references by default 2/ it causes fatal errors: ```PHP $foo->changeIdOrderState((int)$id_order_state, (int)$id_order); ``` Fatal error: Only variables can be passed by reference --- classes/order/OrderHistory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 43b425548..0b0489713 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -70,10 +70,10 @@ class OrderHistoryCore extends ObjectModel * Sets the new state of the given order * * @param int $new_order_state - * @param int $id_order + * @param int/object $id_order * @param bool $use_existing_payment */ - public function changeIdOrderState($new_order_state, &$id_order, $use_existing_payment = false) + public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false) { if (!$new_order_state || !$id_order) return; From 4fd990895345438cdf524484c90b1017a0cd3b3a Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Thu, 17 Jan 2013 22:00:44 +0100 Subject: [PATCH 03/68] [*] BO : use the employee lang --- controllers/admin/AdminLoginController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index 1f4e904b5..0e8c11f29 100755 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -215,7 +215,7 @@ class AdminLoginControllerCore extends AdminController '{passwd}' => $pwd ); - if (Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'password', Mail::l('Your new password', (int)Configuration::get('PS_LANG_DEFAULT')), $params, $employee->email, $employee->firstname.' '.$employee->lastname)) + if (Mail::Send($employee->id_lang, 'password', Mail::l('Your new password', $employee->id_lang), $params, $employee->email, $employee->firstname.' '.$employee->lastname)) { // Update employee only if the mail can be sent $result = $employee->update(); From db3be40c060c84c85ce3a34b4ff97b2a4109bc11 Mon Sep 17 00:00:00 2001 From: Samy Rabih Date: Tue, 22 Jan 2013 14:34:17 +0100 Subject: [PATCH 04/68] Disable search indexation Search indexation is very CPU-intensive, it should not be used here --- controllers/admin/AdminImportController.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 20e62134b..238eb6d12 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1464,9 +1464,6 @@ class AdminImportControllerCore extends AdminController } - if (Configuration::get('PS_SEARCH_INDEXATION')) - Search::indexation(true); - $this->closeCsvFile($handle); } From 310de3da5454499122a8859be1f51567f076b62d Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Mon, 28 Jan 2013 18:29:35 +0100 Subject: [PATCH 05/68] [-] FO : Fix #PSCFV-6356 recall adresses in cart after login --- controllers/front/AuthController.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 785529f56..ee36cf500 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -294,14 +294,16 @@ class AuthControllerCore extends FrontController $this->context->customer = $customer; if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0)) + { $this->context->cookie->id_cart = (int)Cart::lastNoneOrderedCart($this->context->customer->id); - - // Update cart address - $this->context->cart->id = $this->context->cookie->id_cart; - $this->context->cart->setDeliveryOption(null); - $this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id)); - - $this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id)); + $this->context->cart = new Cart((int)$this->context->cookie->id_cart); + } + else + { + $this->context->cart->setDeliveryOption(null); + $this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id)); + $this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id)); + } $this->context->cart->secure_key = $customer->secure_key; $this->context->cart->update(); $this->context->cart->autosetProductAddress(); From 2da4ae138e98061dac80cb01daa7871e617c69bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 28 Jan 2013 18:51:02 +0100 Subject: [PATCH 06/68] [-] Core: Fix Tools::file_get_contents for post and curl --- classes/Tools.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/classes/Tools.php b/classes/Tools.php index 3f8788106..9dd4f367d 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1289,6 +1289,16 @@ class ToolsCore curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $curl_timeout); curl_setopt($curl, CURLOPT_TIMEOUT, $curl_timeout); + $opts = stream_context_get_options($stream_context); + if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post') + { + curl_setopt($curl, CURLOPT_POST, true); + if (isset($opts['http']['content'])) + { + parse_str($opts['http']['content'], $datas); + curl_setopt($curl, CURLOPT_POSTFIELDS, $datas); + } + } $content = curl_exec($curl); curl_close($curl); return $content; From d920c050b412101aab3a25ea1dd9cf6efe4d8e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 28 Jan 2013 19:01:54 +0100 Subject: [PATCH 07/68] // Tools::file_get_contents load with file_get_content for local paths --- classes/Tools.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 9dd4f367d..e2217c6e5 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1277,10 +1277,9 @@ class ToolsCore public static function file_get_contents($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5) { - if ($stream_context == null) + if ($stream_context == null && !strstr($url, 'http')) $stream_context = @stream_context_create(array('http' => array('timeout' => 5))); - - if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1'))) + if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !strstr($url, 'http')) return @file_get_contents($url, $use_include_path, $stream_context); elseif (function_exists('curl_init')) { From 734b227a7fdaf8b4709559240f3df42ef2a3b1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 29 Jan 2013 10:13:34 +0100 Subject: [PATCH 08/68] // Tools::simplexml_load_file now use curl if allow_url_fopen is disabled --- classes/Tools.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index e2217c6e5..feb1bdb34 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1277,9 +1277,9 @@ class ToolsCore public static function file_get_contents($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5) { - if ($stream_context == null && !strstr($url, 'http')) - $stream_context = @stream_context_create(array('http' => array('timeout' => 5))); - if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !strstr($url, 'http')) + if ($stream_context == null && !preg_match('/^https?:\/\//', $url)) + $stream_context = @stream_context_create(array('http' => array('timeout' => $curl_timeout))); + if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $url)) return @file_get_contents($url, $use_include_path, $stream_context); elseif (function_exists('curl_init')) { @@ -1308,10 +1308,7 @@ class ToolsCore public static function simplexml_load_file($url, $class_name = null) { - if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1'))) - return @simplexml_load_string(Tools::file_get_contents($url), $class_name); - else - return false; + return @simplexml_load_string(Tools::file_get_contents($url), $class_name); } From 6f7e8cb7417b32b7d373cede90b161f743dbab29 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Thu, 24 Jan 2013 11:23:21 +0100 Subject: [PATCH 09/68] // Added comments in a function --- controllers/admin/AdminTranslationsController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 530d21dd0..1faa32306 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -604,22 +604,32 @@ class AdminTranslationsControllerCore extends AdminController $global = false; foreach ($lines as $line) { + // PHP tags if (in_array($line, array('', ''))) continue; + + // Global variable declaration if (!$global && preg_match('/^global\s+\$([a-z0-9-_]+)\s*;$/i', $line, $matches)) { $global = $matches[1]; continue; } + // Global variable initialization if ($global != false && preg_match('/^\$'.preg_quote($global, '/').'\s*=\s*array\(\s*\)\s*;$/i', $line)) continue; + + // Global variable initialization without declaration if (!$global && preg_match('/^\$([a-z0-9-_]+)\s*=\s*array\(\s*\)\s*;$/i', $line, $matches)) { $global = $matches[1]; continue; } + + // Assignation if (preg_match('/^\$'.preg_quote($global, '/').'\[\''._PS_TRANS_PATTERN_.'\'\]\s*=\s*\''._PS_TRANS_PATTERN_.'\'\s*;$/i', $line)) continue; + + // Sometimes the global variable is returned... if (preg_match('/^return\s+\$'.preg_quote($global, '/').'\s*;$/i', $line, $matches)) continue; return false; From 25a64e9098abefc7db0dbe54bb1a8ed5abd34219 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Tue, 29 Jan 2013 10:15:50 +0100 Subject: [PATCH 10/68] [-] BO : reduced error catching severity in the module tab --- config/alias.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/alias.php b/config/alias.php index 77ee8fac0..9c4cbb36a 100644 --- a/config/alias.php +++ b/config/alias.php @@ -74,7 +74,7 @@ function bqSQL($string) function displayFatalError() { $error = error_get_last(); - if ($error !== NULL) + if ($error !== NULL && in_array($error['type'], array(E_ERROR, E_PARSE))) echo '[PrestaShop] Fatal error in module '.substr(basename($error['file']), 0, -4).':
'.$error['message']; } From dca10cc17dbdbff75b4ddd75c20f3331478cf1c2 Mon Sep 17 00:00:00 2001 From: sLorenzini Date: Tue, 29 Jan 2013 10:30:53 +0100 Subject: [PATCH 11/68] [-] FO: fixed bug Change a little css code of global.css to solve a little issue on authentication page - #PSCFV-7527 --- themes/default/css/global.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themes/default/css/global.css b/themes/default/css/global.css index dffbfc7e8..8dd75b264 100644 --- a/themes/default/css/global.css +++ b/themes/default/css/global.css @@ -931,7 +931,7 @@ table#cart_summary .gift-icon { #authentication #create-account_form fieldset, #authentication #login_form fieldset { - height: 200px + min-height: 200px } #authentication #create-account_form .form_content, @@ -977,7 +977,8 @@ table#cart_summary .gift-icon { width:220px;/* 230 */ border:1px solid #ccc; color:#666; - background:url(../img/bg_discount_name.png) repeat-x 0 0 #fff + background:url(../img/bg_discount_name.png) repeat-x 0 0 #fff; + line-height:20px; } #create-account_form #SubmitCreate, From 5832c576a0ad6e4951330fc05f7b6d8caec3bf4d Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Tue, 29 Jan 2013 10:56:28 +0100 Subject: [PATCH 12/68] [-] FO : 'undefined' is undefined =) --- themes/default/js/order-opc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/default/js/order-opc.js b/themes/default/js/order-opc.js index a994f2eca..71ebb9863 100644 --- a/themes/default/js/order-opc.js +++ b/themes/default/js/order-opc.js @@ -305,9 +305,9 @@ function saveAddress(type) params += 'phone='+encodeURIComponent($('#phone'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; params += 'phone_mobile='+encodeURIComponent($('#phone_mobile'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; params += 'alias='+encodeURIComponent($('#alias'+(type === 'invoice' ? '_invoice' : '')).val())+'&'; - if (type === 'delivery' && $('#opc_id_address_delivery').val() != 'undefined' && parseInt($('#opc_id_address_delivery').val()) > 0) + if (type === 'delivery' && $('#opc_id_address_delivery').val() != undefined && parseInt($('#opc_id_address_delivery').val()) > 0) params += 'opc_id_address_delivery='+encodeURIComponent($('#opc_id_address_delivery').val())+'&'; - if (type === 'invoice' && $('#opc_id_address_invoice').val() != 'undefined' && parseInt($('#opc_id_address_invoice').val()) > 0) + if (type === 'invoice' && $('#opc_id_address_invoice').val() != undefined && parseInt($('#opc_id_address_invoice').val()) > 0) params += 'opc_id_address_invoice='+encodeURIComponent($('#opc_id_address_invoice').val())+'&'; // Clean the last & params = params.substr(0, params.length-1); From a97843353b6b9d4cdb1b3abb9274bd8dd61f9b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 29 Jan 2013 11:40:39 +0100 Subject: [PATCH 13/68] [-] FO: Fix Product::getProductName for multilang and multishop --- classes/Product.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/Product.php b/classes/Product.php index 0f0c85f65..b8fc758ef 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -4951,7 +4951,7 @@ class ProductCore extends ObjectModel { $query->from('product_attribute', 'pa'); $query->join(Shop::addSqlAssociation('product_attribute', 'pa')); - $query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang); + $query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')); $query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute'); $query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute'); $query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = '.(int)$id_lang); @@ -4962,6 +4962,7 @@ class ProductCore extends ObjectModel { $query->from('product_lang', 'pl'); $query->where('pl.id_product = '.(int)$id_product); + $query->where('pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')); } return Db::getInstance()->getValue($query); From 3f8e52d3f87fb0e3f86e9b99141a1b32e6938cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 29 Jan 2013 11:53:53 +0100 Subject: [PATCH 14/68] [-] BO: Fix warning when image is uploaded with PHP < 5.3 #PSCFV-7425 --- classes/ImageManager.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/ImageManager.php b/classes/ImageManager.php index cc89349f8..257c3356c 100644 --- a/classes/ImageManager.php +++ b/classes/ImageManager.php @@ -119,7 +119,10 @@ class ImageManagerCore */ public static function resize($src_file, $dst_file, $dst_width = null, $dst_height = null, $file_type = 'jpg', $force_type = false) { - clearstatcache(true, $src_file); + if (PHP_VERSION_ID < 50300) + clearstatcache(); + else + clearstatcache(true, $src_file); if (!file_exists($src_file) || !filesize($src_file)) return false; From 54fb5b7eb7a63c24d41b5336e5d5ec6cdda0e02d Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Tue, 29 Jan 2013 11:55:51 +0100 Subject: [PATCH 15/68] [-] Bo : Fix warnings #PSCFV-6648 --- controllers/admin/AdminImportController.php | 349 ++++++++++---------- 1 file changed, 182 insertions(+), 167 deletions(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 20e62134b..087d84b2f 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -644,10 +644,14 @@ class AdminImportControllerCore extends AdminController do $uniqid_path = _PS_UPLOAD_DIR_.uniqid(); while (file_exists($uniqid_path)); file_put_contents($uniqid_path, $field); - $fd = fopen($uniqid_path, 'r'); - $tab = fgetcsv($fd, MAX_LINE_SIZE, $separator); - fclose($fd); - unlink($uniqid_path); + $tab = ''; + if(!empty($uniqid_path)) + { + $fd = fopen($uniqid_path, 'r'); + $tab = fgetcsv($fd, MAX_LINE_SIZE, $separator); + fclose($fd); + unlink($uniqid_path); + } if (empty($tab) || (!is_array($tab))) return array(); @@ -727,8 +731,9 @@ class AdminImportControllerCore extends AdminController public static function getMaskedRow($row) { $res = array(); - foreach (self::$column_mask as $type => $nb) - $res[$type] = isset($row[$nb]) ? $row[$nb] : null; + if (is_array(self::$column_mask)) + foreach (self::$column_mask as $type => $nb) + $res[$type] = isset($row[$nb]) ? $row[$nb] : null; if (Tools::getValue('forceIds')) // if you choose to force table before import the column id is remove from the CSV file. unset($res['id']); @@ -972,8 +977,8 @@ class AdminImportControllerCore extends AdminController { $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - $info['name'], - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), + (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') ); $error_tmp = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError(); if ($error_tmp != '') @@ -1303,8 +1308,8 @@ class AdminImportControllerCore extends AdminController { $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - $info['name'], - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), + (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') ); $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -1347,7 +1352,7 @@ class AdminImportControllerCore extends AdminController $specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00'; $specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00'; if (!$specific_price->add()) - $this->addProductWarning($info['name'], $product->id, $this->l('Discount is invalid')); + $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid')); } if (isset($product->tags) && !empty($product->tags)) @@ -1363,7 +1368,7 @@ class AdminImportControllerCore extends AdminController $is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator); if (!$is_tag_added) { - $this->addProductWarning($info['name'], $product->id, $this->l('Tags list is invalid')); + $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid')); break; } } @@ -1380,7 +1385,7 @@ class AdminImportControllerCore extends AdminController $is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator); if (!$is_tag_added) { - $this->addProductWarning($info['name'], $product->id, 'Invalid tag(s) ('.$str.')'); + $this->addProductWarning(Tools::safeOutput($info['name']), (int)$product->id, 'Invalid tag(s) ('.$str.')'); break; } } @@ -1445,9 +1450,12 @@ class AdminImportControllerCore extends AdminController $feature_name = trim($tab_feature[0]); $feature_value = trim($tab_feature[1]); $position = isset($tab_feature[2]) ? $tab_feature[2]: false; - $id_feature = Feature::addFeatureImport($feature_name, $position); - $id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value); - Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value); + if(!empty($feature_name) && !empty($feature_value)) + { + $id_feature = Feature::addFeatureImport($feature_name, $position); + $id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value); + Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value); + } } // clean feature positions to avoid conflict Feature::cleanPositions(); @@ -1511,8 +1519,12 @@ class AdminImportControllerCore extends AdminController $id_shop_list[] = Shop::getIdByName($shop); else $id_shop_list[] = $shop; - - $product = new Product((int)$info['id_product'], false, $default_language); + + if(isset($info['id_product'])) + $product = new Product((int)$info['id_product'], false, $default_language); + else + continue; + $id_image = null; //delete existing images if "delete_existing_images" is set to 1 @@ -1577,53 +1589,54 @@ class AdminImportControllerCore extends AdminController $id_attribute_group = 0; // groups $groups_attributes = array(); - foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) - { - $tab_group = explode(':', $group); - $group = trim($tab_group[0]); - if (!isset($tab_group[1])) - $type = 'select'; - else - $type = trim($tab_group[1]); - - // sets group - $groups_attributes[$key]['group'] = $group; - - // if position is filled - if (isset($tab_group[2])) - $position = trim($tab_group[2]); - else - $position = false; - - if (!isset($groups[$group])) + if(isset($info['group'])) + foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) { - $obj = new AttributeGroup(); - $obj->is_color_group = false; - $obj->group_type = pSQL($type); - $obj->name[$default_language] = $group; - $obj->public_name[$default_language] = $group; - $obj->position = (!$position) ? AttributeGroup::getHigherPosition() + 1 : $position; - - if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && - ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) - { - $obj->add(); - $obj->associateTo($id_shop_list); - $groups[$group] = $obj->id; - } + $tab_group = explode(':', $group); + $group = trim($tab_group[0]); + if (!isset($tab_group[1])) + $type = 'select'; else - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''); - - // fils groups attributes - $id_attribute_group = $obj->id; - $groups_attributes[$key]['id'] = $id_attribute_group; + $type = trim($tab_group[1]); + + // sets group + $groups_attributes[$key]['group'] = $group; + + // if position is filled + if (isset($tab_group[2])) + $position = trim($tab_group[2]); + else + $position = false; + + if (!isset($groups[$group])) + { + $obj = new AttributeGroup(); + $obj->is_color_group = false; + $obj->group_type = pSQL($type); + $obj->name[$default_language] = $group; + $obj->public_name[$default_language] = $group; + $obj->position = (!$position) ? AttributeGroup::getHigherPosition() + 1 : $position; + + if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && + ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) + { + $obj->add(); + $obj->associateTo($id_shop_list); + $groups[$group] = $obj->id; + } + else + $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''); + + // fils groups attributes + $id_attribute_group = $obj->id; + $groups_attributes[$key]['id'] = $id_attribute_group; + } + else // alreay exists + { + $id_attribute_group = $groups[$group]; + $groups_attributes[$key]['id'] = $id_attribute_group; + } } - else // alreay exists - { - $id_attribute_group = $groups[$group]; - $groups_attributes[$key]['id'] = $id_attribute_group; - } - } // inits attribute $id_product_attribute = 0; @@ -1631,116 +1644,118 @@ class AdminImportControllerCore extends AdminController $attributes_to_add = array(); // for each attribute - foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) - { - $tab_attribute = explode(':', $attribute); - $attribute = trim($tab_attribute[0]); - // if position is filled - if (isset($tab_attribute[1])) - $position = trim($tab_attribute[1]); - else - $position = false; - - if (isset($groups_attributes[$key])) + if(isset($info['attribute'])) + foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) { - $group = $groups_attributes[$key]['group']; - if (!isset($attributes[$group.'_'.$attribute]) && count($groups_attributes[$key]) == 2) + $tab_attribute = explode(':', $attribute); + $attribute = trim($tab_attribute[0]); + // if position is filled + if (isset($tab_attribute[1])) + $position = trim($tab_attribute[1]); + else + $position = false; + + if (isset($groups_attributes[$key])) { - $id_attribute_group = $groups_attributes[$key]['id']; - $obj = new Attribute(); - // sets the proper id (corresponding to the right key) - $obj->id_attribute_group = $groups_attributes[$key]['id']; - $obj->name[$default_language] = str_replace('\n', '', str_replace('\r', '', $attribute)); - $obj->position = (!$position) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position; - - if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && - ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) + $group = $groups_attributes[$key]['group']; + if (!isset($attributes[$group.'_'.$attribute]) && count($groups_attributes[$key]) == 2) { - $obj->add(); - $obj->associateTo($id_shop_list); - $attributes[$group.'_'.$attribute] = $obj->id; - } - else - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''); - } - - $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int)$info['minimal_quantity'] : 1; - - $info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']); - $info['price'] = str_replace(',', '.', $info['price']); - $info['ecotax'] = str_replace(',', '.', $info['ecotax']); - $info['weight'] = str_replace(',', '.', $info['weight']); - - // if a reference is specified for this product, get the associate id_product_attribute to UPDATE - if (isset($info['reference']) && !empty($info['reference'])) - { - $id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference'])); - - // updates the attribute - if ($id_product_attribute) - { - // gets all the combinations of this product - $attribute_combinations = $product->getAttributeCombinations($default_language); - foreach ($attribute_combinations as $attribute_combination) + $id_attribute_group = $groups_attributes[$key]['id']; + $obj = new Attribute(); + // sets the proper id (corresponding to the right key) + $obj->id_attribute_group = $groups_attributes[$key]['id']; + $obj->name[$default_language] = str_replace('\n', '', str_replace('\r', '', $attribute)); + $obj->position = (!$position && isset($groups[$group])) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position; + + if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && + ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { - if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination)) + $obj->add(); + $obj->associateTo($id_shop_list); + $attributes[$group.'_'.$attribute] = $obj->id; + } + else + $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''); + } + + $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int)$info['minimal_quantity'] : 1; + + $info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']); + $info['price'] = str_replace(',', '.', $info['price']); + $info['ecotax'] = str_replace(',', '.', $info['ecotax']); + $info['weight'] = str_replace(',', '.', $info['weight']); + + // if a reference is specified for this product, get the associate id_product_attribute to UPDATE + if (isset($info['reference']) && !empty($info['reference'])) + { + $id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference'])); + + // updates the attribute + if ($id_product_attribute) + { + // gets all the combinations of this product + $attribute_combinations = $product->getAttributeCombinations($default_language); + foreach ($attribute_combinations as $attribute_combination) { - $product->updateAttribute( - $id_product_attribute, - (float)$info['wholesale_price'], - (float)$info['price'], - (float)$info['weight'], - 0, - (float)$info['ecotax'], - $id_image, - strval($info['reference']), - strval($info['ean13']), - (int)$info['default_on'], - 0, - strval($info['upc']), - (int)$info['minimal_quantity'], - 0, - null, - $id_shop_list - ); - - $id_product_attribute_update = true; + if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination)) + { + $product->updateAttribute( + $id_product_attribute, + (float)$info['wholesale_price'], + (float)$info['price'], + (float)$info['weight'], + 0, + (float)$info['ecotax'], + $id_image, + strval($info['reference']), + strval($info['ean13']), + (int)$info['default_on'], + 0, + strval($info['upc']), + (int)$info['minimal_quantity'], + 0, + null, + $id_shop_list + ); + + $id_product_attribute_update = true; + } } } } + + // if no attribute reference is specified, creates a new one + if (!$id_product_attribute) + { + $id_product_attribute = $product->addCombinationEntity( + (float)$info['wholesale_price'], + (float)$info['price'], + (float)$info['weight'], + 0, + (float)$info['ecotax'], + (int)$info['quantity'], + $id_image, + strval($info['reference']), + 0, + strval($info['ean13']), + (int)$info['default_on'], + 0, + strval($info['upc']), + (int)$info['minimal_quantity'], + $id_shop_list + ); + } + + // fills our attributes array, in order to add the attributes to the product_attribute afterwards + if(isset($attributes[$group.'_'.$attribute])) + $attributes_to_add[] = (int)$attributes[$group.'_'.$attribute]; + + // after insertion, we clean attribute position and group attribute position + $obj = new Attribute(); + $obj->cleanPositions((int)$id_attribute_group, false); + AttributeGroup::cleanPositions(); } - - // if no attribute reference is specified, creates a new one - if (!$id_product_attribute) - { - $id_product_attribute = $product->addCombinationEntity( - (float)$info['wholesale_price'], - (float)$info['price'], - (float)$info['weight'], - 0, - (float)$info['ecotax'], - (int)$info['quantity'], - $id_image, - strval($info['reference']), - 0, - strval($info['ean13']), - (int)$info['default_on'], - 0, - strval($info['upc']), - (int)$info['minimal_quantity'], - $id_shop_list - ); - } - - // fills our attributes array, in order to add the attributes to the product_attribute afterwards - $attributes_to_add[] = (int)$attributes[$group.'_'.$attribute]; - - // after insertion, we clean attribute position and group attribute position - $obj = new Attribute(); - $obj->cleanPositions((int)$id_attribute_group, false); - AttributeGroup::cleanPositions(); } - } $product->checkDefaultAttributes(); if (!$product->cache_default_attribute) @@ -2188,10 +2203,10 @@ class AdminImportControllerCore extends AdminController { $this->errors[] = Db::getInstance()->getMsgError().' '.sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - $info['name'], - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), + (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -2235,8 +2250,8 @@ class AdminImportControllerCore extends AdminController if (!$res) $this->errors[] = Db::getInstance()->getMsgError().' '.sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - $info['name'], - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), + (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') ); else { From b51bf1af256ca90d06c52c5d6ae48bf3f701aee9 Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Tue, 29 Jan 2013 12:21:33 +0100 Subject: [PATCH 16/68] [-] BO : Fiw warning on $current_order_state --- controllers/admin/AdminOrdersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 257db3ca5..060209413 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1292,7 +1292,7 @@ class AdminOrdersControllerCore extends AdminController // display warning if there are products out of stock $display_out_of_stock_warning = false; $current_order_state = $order->getCurrentOrderState(); - if ($current_order_state->delivery != 1 && $current_order_state->shipped != 1) + if (!Validate::isLoadedObject($current_order_state) || ($current_order_state->delivery != 1 && $current_order_state->shipped != 1)) $display_out_of_stock_warning = true; // products current stock (from stock_available) From d38ed338bf129db9cbd2dee864ea1c9c87f4d8e1 Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Tue, 29 Jan 2013 12:33:15 +0100 Subject: [PATCH 17/68] [-] BO : Fix warnings when importing #PSCFV-6648 again --- controllers/admin/AdminImportController.php | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 087d84b2f..3a7be5290 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -904,7 +904,7 @@ class AdminImportControllerCore extends AdminController $category_to_create->name[$default_language_id], (isset($category_to_create->id) ? $category_to_create->id : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -980,7 +980,7 @@ class AdminImportControllerCore extends AdminController (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') ); - $error_tmp = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError(); + $error_tmp = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError(); if ($error_tmp != '') $this->errors[] = $error_tmp; } @@ -1104,7 +1104,7 @@ class AdminImportControllerCore extends AdminController $manufacturer->name, (isset($manufacturer->id) ? $manufacturer->id : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -1135,7 +1135,7 @@ class AdminImportControllerCore extends AdminController $supplier->name, (isset($supplier->id) ? $supplier->id : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -1181,7 +1181,7 @@ class AdminImportControllerCore extends AdminController $category_to_create->name[$default_language_id], (isset($category_to_create->id) ? $category_to_create->id : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -1213,7 +1213,7 @@ class AdminImportControllerCore extends AdminController $category_to_create->name[$default_language_id], (isset($category_to_create->id) ? $category_to_create->id : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -1311,7 +1311,7 @@ class AdminImportControllerCore extends AdminController (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } @@ -1564,7 +1564,7 @@ class AdminImportControllerCore extends AdminController Tools::displayError('%s cannot be saved'), (isset($image->id_product) ? ' ('.$image->id_product.')' : '') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').mysql_error(); + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').mysql_error(); } } elseif (isset($info['image_position']) && $info['image_position']) @@ -1625,7 +1625,7 @@ class AdminImportControllerCore extends AdminController $groups[$group] = $obj->id; } else - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''); + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); // fils groups attributes $id_attribute_group = $obj->id; @@ -1675,7 +1675,7 @@ class AdminImportControllerCore extends AdminController $attributes[$group.'_'.$attribute] = $obj->id; } else - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''); + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int)$info['minimal_quantity'] : 1; @@ -1922,7 +1922,7 @@ class AdminImportControllerCore extends AdminController $info['email'], (isset($info['id']) ? $info['id'] : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -1969,7 +1969,7 @@ class AdminImportControllerCore extends AdminController else { $this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $country->name[$default_language_id]); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -1999,7 +1999,7 @@ class AdminImportControllerCore extends AdminController else { $this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $state->name); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -2068,7 +2068,7 @@ class AdminImportControllerCore extends AdminController $manufacturer->name, (isset($manufacturer->id) ? $manufacturer->id : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -2089,7 +2089,7 @@ class AdminImportControllerCore extends AdminController $supplier->name, (isset($supplier->id) ? $supplier->id : 'null') ); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); } } @@ -2278,7 +2278,7 @@ class AdminImportControllerCore extends AdminController else { $this->errors[] = $this->l('Supplier is invalid').' ('.$supplier->name.')'; - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''); + $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } } $this->closeCsvFile($handle); From 6ad12164b5db1cb69d189a0b3d92cc483ec0225b Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Tue, 29 Jan 2013 12:43:47 +0100 Subject: [PATCH 18/68] [-] MO : Fix bug #PSCFV-6364 pagination in loyalty module, thankx Matthieu@202-ecommerce.com --- modules/loyalty/controllers/front/default.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/loyalty/controllers/front/default.php b/modules/loyalty/controllers/front/default.php index 8286f3ea4..6f926fadb 100644 --- a/modules/loyalty/controllers/front/default.php +++ b/modules/loyalty/controllers/front/default.php @@ -183,7 +183,8 @@ class LoyaltyDefaultModuleFrontController extends ModuleFrontController 'page' => ((int)Tools::getValue('p') > 0 ? (int)Tools::getValue('p') : 1), 'nbpagination' => ((int)Tools::getValue('n') > 0 ? (int)Tools::getValue('n') : 10), 'nArray' => array(10, 20, 50), - 'max_page' => floor(count($orders) / ((int)Tools::getValue('n') > 0 ? (int)Tools::getValue('n') : 10)) + 'max_page' => floor(count($orders) / ((int)Tools::getValue('n') > 0 ? (int)Tools::getValue('n') : 10)), + 'pagination_link' => $this->getSummaryPaginationLink(array(), $this->context->smarty) )); /* Discounts */ From 0dc94f163b7cc653b566c4b85c650f04a6340bd0 Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 29 Jan 2013 13:43:12 +0100 Subject: [PATCH 19/68] Fixes Syntax Error in Line 126 There was a Typo / Syntax Error in Line 116. --- controllers/admin/AdminSearchConfController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminSearchConfController.php b/controllers/admin/AdminSearchConfController.php index 34b294c5b..274543f5f 100644 --- a/controllers/admin/AdminSearchConfController.php +++ b/controllers/admin/AdminSearchConfController.php @@ -113,7 +113,7 @@ class AdminSearchConfControllerCore extends AdminController 'title' => $this->l('Blacklisted words'), 'size' => 35, 'validation' => 'isGenericName', - 'desc' => $this->l('Please enter the index words separated by a "|".'|".'), + 'desc' => $this->l('Please enter the index words separated by a "|".'), 'type' => 'textLang' ) ), From cf83821c60ff9199ffaf7b22bbc5fc366c73a47c Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Tue, 29 Jan 2013 15:59:31 +0100 Subject: [PATCH 20/68] [-] Core : prepend/append are now a little more optionnal in the routes for the dispatcher --- classes/Dispatcher.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php index 000037882..a0381064c 100644 --- a/classes/Dispatcher.php +++ b/classes/Dispatcher.php @@ -468,7 +468,7 @@ class DispatcherCore if ($keywords) { $transform_keywords = array(); - preg_match_all('#\\\{(([^{}]+)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]+))?\\\}#', $regexp, $m); + preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $m); for ($i = 0, $total = count($m[0]); $i < $total; $i++) { $prepend = $m[2][$i]; @@ -537,7 +537,7 @@ class DispatcherCore if (!isset($this->routes[$id_lang]) && !isset($this->routes[$id_lang][$route_id])) return false; - return preg_match('#\{([^{}]+:)?'.preg_quote($keyword, '#').'(:[^{}])?\}#', $this->routes[$id_lang][$route_id]['rule']); + return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_lang][$route_id]['rule']); } /** @@ -554,7 +554,7 @@ class DispatcherCore return false; foreach ($this->default_routes[$route_id]['keywords'] as $keyword => $data) - if (isset($data['param']) && !preg_match('#\{([^{}]+:)?'.$keyword.'(:[^{}])?\}#', $rule)) + if (isset($data['param']) && !preg_match('#\{([^{}]*:)?'.$keyword.'(:[^{}]*)?\}#', $rule)) $errors[] = $keyword; return (count($errors)) ? false : true; @@ -614,10 +614,10 @@ class DispatcherCore $replace = $route['keywords'][$key]['prepend'].$params[$key].$route['keywords'][$key]['append']; else $replace = ''; - $url = preg_replace('#\{([^{}]+:)?'.$key.'(:[^{}])?\}#', $replace, $url); + $url = preg_replace('#\{([^{}]*:)?'.$key.'(:[^{}]*)?\}#', $replace, $url); } } - $url = preg_replace('#\{([^{}]+:)?[a-z0-9_]+?(:[^{}])?\}#', '', $url); + $url = preg_replace('#\{([^{}]*:)?[a-z0-9_]+?(:[^{}]*)?\}#', '', $url); if (count($add_param)) $url .= '?'.http_build_query($add_param, '', '&'); } From 40b417bd4473f576fbf236fa689cff04b0d51f09 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Wed, 30 Jan 2013 10:15:39 +0100 Subject: [PATCH 21/68] // Fixed profiling tool --- tools/profiling/Hook.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/profiling/Hook.php b/tools/profiling/Hook.php index 5963077cd..9e69e66dd 100644 --- a/tools/profiling/Hook.php +++ b/tools/profiling/Hook.php @@ -43,11 +43,11 @@ class Hook extends HookCore return self::$hookMemoryUsage; } - public static function exec($hook_name, $hookArgs = array(), $id_module = null) + public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true) { $memoryUsage = memory_get_usage(); $t0 = microtime(true); - $result = parent::exec($hook_name, $hookArgs, $id_module); + $result = parent::exec($hook_name, $hookArgs, $id_module, $array_return, $check_exceptions); self::$hookTime[$hook_name] = microtime(true) - $t0; self::$hookMemoryUsage[$hook_name] = memory_get_usage() - $memoryUsage; return $result; From 3c004e854e5f4af0c5949747e3c971b7e2431cef Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Wed, 30 Jan 2013 10:17:00 +0100 Subject: [PATCH 22/68] // Fixed profiling tool --- tools/profiling/Hook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/profiling/Hook.php b/tools/profiling/Hook.php index 9e69e66dd..b5da985db 100644 --- a/tools/profiling/Hook.php +++ b/tools/profiling/Hook.php @@ -47,7 +47,7 @@ class Hook extends HookCore { $memoryUsage = memory_get_usage(); $t0 = microtime(true); - $result = parent::exec($hook_name, $hookArgs, $id_module, $array_return, $check_exceptions); + $result = parent::exec($hook_name, $hook_args, $id_module, $array_return, $check_exceptions); self::$hookTime[$hook_name] = microtime(true) - $t0; self::$hookMemoryUsage[$hook_name] = memory_get_usage() - $memoryUsage; return $result; From f39d623f2721958c769cf26e77d854ee62ab5ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 30 Jan 2013 11:29:59 +0100 Subject: [PATCH 23/68] [-] BO: Fix #PSCFV-7523 htaccess generation for SSL domain --- classes/Tools.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/classes/Tools.php b/classes/Tools.php index feb1bdb34..a6e4b3118 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1541,6 +1541,18 @@ class ToolsCore 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop ); + + if ($shop_url->domain == $shop_url->domain_ssl) + continue; + + if (!isset($domains[$shop_url->domain_ssl])) + $domains[$shop_url->domain_ssl] = array(); + + $domains[$shop_url->domain_ssl][] = array( + 'physical' => $shop_url->physical_uri, + 'virtual' => $shop_url->virtual_uri, + 'id_shop' => $shop_url->id_shop + ); } // Write data in .htaccess file From edd4bb0323c6c4799ef8abc00364664ec299249d Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Wed, 30 Jan 2013 14:56:54 +0100 Subject: [PATCH 24/68] // fix warning --- classes/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Product.php b/classes/Product.php index b8fc758ef..d76a1ac3a 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -902,7 +902,7 @@ class ProductCore extends ObjectModel ); $return = Db::getInstance()->delete('category_product', 'id_product = '.(int)$this->id); - if ($clean_positions === true) + if ($clean_positions === true && is_array($result)) foreach ($result as $row) $return &= $this->cleanPositions((int)$row['id_category']); From 808c2864682024844f1aa538d795cb9caedddba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 30 Jan 2013 15:08:24 +0100 Subject: [PATCH 25/68] [-] BO: Fix #PSCFV-7522 update cover image after deleting it --- controllers/admin/AdminProductsController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 201e39d3d..a3b1045bf 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1422,8 +1422,9 @@ class AdminProductsControllerCore extends AdminController if (!Image::getCover($image->id_product)) { $res &= Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'image_shop` image_shop - SET image_shop.`cover` = 1 + UPDATE `'._DB_PREFIX_.'image_shop` image_shop, '._DB_PREFIX_.'image i + SET image_shop.`cover` = 1, + i.cover = 1 WHERE image_shop.`id_image` = (SELECT id_image FROM (SELECT image_shop.id_image FROM '._DB_PREFIX_.'image i'. @@ -1431,7 +1432,8 @@ class AdminProductsControllerCore extends AdminController WHERE i.id_product ='.(int)$image->id_product.' LIMIT 1 ) tmpImage) AND id_shop='.(int)$this->context->shop->id.' - LIMIT 1'); + AND i.id_image = image_shop.id_image + '); } if (file_exists(_PS_TMP_IMG_DIR_.'product_'.$image->id_product.'.jpg')) From a97a265649aae055cd627ea386209cc3c2bd25f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 30 Jan 2013 15:57:02 +0100 Subject: [PATCH 26/68] [-] FO: Fix #PSCFV-6375 always display the vat_number field for registration even if the european vat number module is disabled --- themes/default/address.tpl | 10 +---- themes/default/authentication.tpl | 28 ++++++------- themes/default/mobile/address.tpl | 24 ++++++------ themes/default/mobile/authentication.tpl | 30 +++++++------- themes/default/order-opc-new-account.tpl | 50 ++++++++++++------------ 5 files changed, 63 insertions(+), 79 deletions(-) diff --git a/themes/default/address.tpl b/themes/default/address.tpl index b3ec1221a..1457760c1 100644 --- a/themes/default/address.tpl +++ b/themes/default/address.tpl @@ -46,7 +46,6 @@ var countriesNeedZipCode = new Array(); $(function(){ldelim} $('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}{if isset($address->id_state)}{$address->id_state|intval}{/if}{/if}]').attr('selected', true); {rdelim}); -{if $vat_management} {literal} $(document).ready(function() { $('#company').blur(function(){ @@ -62,7 +61,6 @@ $(function(){ldelim} } }); {/literal} -{/if} //]]> @@ -104,13 +102,7 @@ $(function(){ldelim}

- {if $vat_display == 2} -
- {elseif $vat_display == 1} -