From 6b080e1f02933fdba41611e9a6e681e2be93f909 Mon Sep 17 00:00:00 2001 From: sjousse Date: Thu, 5 Sep 2013 18:24:02 +0200 Subject: [PATCH 01/72] Optimize image copy in ShopImport module 2 things : - copy images to new folder structure instead of legacy one since it's a PS 1.5 branch - don't create all sizes of images at migration, there's an Admin controller for that (Admin > Settings > Images). That's speed up the import and remove duplicate code (less code to support). + some cleaning of unused variables --- modules/shopimporter/shopimporter.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index 7b6a7cd02..a4709d701 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -844,19 +844,15 @@ class shopimporter extends ImportModule default: case 'Product': $path = _PS_PROD_IMG_DIR_; - $type = 'products'; break; case 'Category': $path = _PS_CAT_IMG_DIR_; - $type = 'categories'; break; case 'Manufacturer': $path = _PS_MANU_IMG_DIR_; - $type = 'manufacturers'; break; case 'Supplier': $path = _PS_SUPP_IMG_DIR_; - $type = 'suppliers'; break; } $cover = 1; @@ -865,11 +861,8 @@ class shopimporter extends ImportModule foreach($item['images'] as $key => $image) { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'import'); - if (@copy(str_replace(' ', '%20', $image), $tmpfile)) + if (@copy(str_replace(' ', '%20', $image), $tmpfile)) { - - $imagesTypes = ImageType::getImagesTypes($type); - ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'.jpg'); if ($className == 'Product') { $image = new Image(); @@ -884,13 +877,13 @@ class shopimporter extends ImportModule $legend[Configuration::get('PS_LANG_DEFAULT')] = Tools::link_rewrite($val); $image->legend = $legend; $image->add(); - ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'-'.(int)$image->id.'.jpg'); - foreach ($imagesTypes AS $k => $imageType) - ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'-'.(int)$image->id.'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']); + $path = $image->getPathForCreation(); + ImageManager::resize($tmpfile, $path.'.jpg'); } else - foreach ($imagesTypes as $imageType) - ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']); + { + ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'.jpg'); + } } else @unlink($tmpfile); From 54f7c6516558ce1a5e55c963546a69480bb8c63d Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 9 Sep 2013 12:20:38 +0200 Subject: [PATCH 02/72] [-] BO : Display the old image system migration tool if product images are in _PS_PROD_IMG_DIR_ --- controllers/admin/AdminImagesController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminImagesController.php b/controllers/admin/AdminImagesController.php index 13b505f0f..922fcf050 100644 --- a/controllers/admin/AdminImagesController.php +++ b/controllers/admin/AdminImagesController.php @@ -52,8 +52,17 @@ class AdminImagesControllerCore extends AdminController 'stores' => array('title' => $this->l('Stores'), 'width' => 50, 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false) ); - // No need to display the old image system if the install has been made later than 2013-03-26 - $this->display_move = (!Configuration::get('PS_LEGACY_IMAGES') && defined('_PS_CREATION_DATE_') && strtotime(_PS_CREATION_DATE_) > strtotime('2013-03-26')) ? false : true; + // No need to display the old image system migration tool except if product images are in _PS_PROD_IMG_DIR_ + $this->display_move = false; + $dir = _PS_PROD_IMG_DIR_; + if (is_dir($dir)) + if ($dh = opendir($dir)) + { + while (($file = readdir($dh)) !== false && $this->display_move == false) + if (!is_dir($dir.DIRECTORY_SEPARATOR.$file) && $file[0] != '.' && is_numeric($file[0])) + $this->display_move = true; + closedir($dh); + } $this->fields_options = array( 'images' => array( From c502c9766f8c9fa100e112f564a9268e879c8f48 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Mon, 9 Sep 2013 15:04:14 +0200 Subject: [PATCH 03/72] [-] BO : FixBug PSCFV-10331 - Tax rules Pagination --- .../tax_rules/helpers/list/list_header.tpl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl b/admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl index d6ab3b6d8..00bae4d83 100644 --- a/admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl +++ b/admin-dev/themes/default/template/controllers/tax_rules/helpers/list/list_header.tpl @@ -33,22 +33,22 @@ {/if}
- + @@ -66,7 +66,7 @@
{if $page > 1} -   - +   + {/if} {l s='Page'} {$page} / {$total_pages} {if $page < $total_pages} -   - +   + {/if} | {l s='Display'} - {* Choose number of results per page *} {foreach $pagination AS $value} @@ -57,7 +57,7 @@ / {$list_total} {l s='result(s)'} - + @@ -84,7 +84,7 @@ {foreach $fields_display AS $key => $params} From 242556e176502ec61271a3945e1337917bc88f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 9 Sep 2013 15:12:26 +0200 Subject: [PATCH 04/72] [-] MO: Fix unifunc smarty errors if module is displayed on multiplehook without cache --- classes/module/Module.php | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/classes/module/Module.php b/classes/module/Module.php index 0dfdd6535..79ec715c1 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -118,6 +118,9 @@ abstract class ModuleCore /** @var Smarty_Data */ protected $smarty; + + /** @var currentSmartySubTemplate */ + protected $current_subtemplate = null; const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml'; @@ -1653,20 +1656,35 @@ abstract class ModuleCore if ($cacheId !== null) Tools::enableCache(); - $smarty_subtemplate = $this->context->smarty->createTemplate( - $this->getTemplatePath($template), - $cacheId, - $compileId, - $this->smarty - ); - $result = $smarty_subtemplate->fetch(); + $result = $this->getCurrentSubTemplate($template, $cacheId, $compileId)->fetch(); if ($cacheId !== null) Tools::restoreCacheSettings(); + $this->resetCurrentSubTemplate($template, $cacheId, $compileId); + return $result; } } + + protected function getCurrentSubTemplate($template, $cache_id = null, $compile_id = null) + { + if (!isset($this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id])) + { + $this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id] = $this->context->smarty->createTemplate( + $this->getTemplatePath($template), + $cache_id, + $compile_id, + $this->smarty + ); + } + return $this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id]; + } + + protected function resetCurrentSubTemplate($template, $cache_id, $compile_id) + { + $this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id] = null; + } /** * Get realpath of a template of current module (check if template is overriden too) @@ -1696,10 +1714,8 @@ abstract class ModuleCore public function isCached($template, $cacheId = null, $compileId = null) { - $context = Context::getContext(); - Tools::enableCache(); - $is_cached = $context->smarty->isCached($this->getTemplatePath($template), $cacheId, $compileId); + $is_cached = $this->getCurrentSubTemplate($this->getTemplatePath($template), $cacheId, $compileId)->isCached($this->getTemplatePath($template), $cacheId, $compileId); Tools::restoreCacheSettings(); return $is_cached; From e6d0a3e5a4d14792b7caeda848c6f8e3de63449a Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 9 Sep 2013 15:11:55 +0200 Subject: [PATCH 05/72] // revert form https://github.com/PrestaShop/PrestaShop/commit/2874f1498352228c84df969c42e9d8f699a8afc5 --- tools/smarty/sysplugins/smarty_internal_templatebase.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/smarty/sysplugins/smarty_internal_templatebase.php b/tools/smarty/sysplugins/smarty_internal_templatebase.php index 84315b2d6..2da7e0f5f 100644 --- a/tools/smarty/sysplugins/smarty_internal_templatebase.php +++ b/tools/smarty/sysplugins/smarty_internal_templatebase.php @@ -278,9 +278,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { // // render cached template // - /* PrestaShop related to PSCFV-10040 - http://www.smarty.net/forums/viewtopic.php?p=76467 */ - if (isset($_template->properties['unifunc'])) - $_template->properties['unifunc']($_template); + $_template->properties['unifunc']($_template); // any unclosed {capture} tags ? if (isset($_template->_capture_stack[0][0])) { $_template->capture_error(); From 990a889b1cd66331eb46abc035aba5382320a09c Mon Sep 17 00:00:00 2001 From: sjousse Date: Mon, 9 Sep 2013 17:08:17 +0200 Subject: [PATCH 06/72] Add some fields to Orders in Import module --- modules/shopimporter/shopimporter.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index 7b6a7cd02..0620403cd 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -1505,6 +1505,20 @@ class shopimporter extends ImportModule $order->valid = 1; else $order->valid = 0; + + if (array_key_exists('current_state', $item)) + $order->current_state = $item['current_state']; + if (array_key_exists('reference', $item)) + $order->reference = $item['reference']; + if (array_key_exists('invoice_number', $item)) + $order->invoice_number = $item['invoice_number']; + if (array_key_exists('delivery_number', $item)) + $order->delivery_number = $item['delivery_number']; + if (array_key_exists('invoice_date', $item)) + $order->invoice_date = $item['invoice_date']; + if (array_key_exists('delivery_date', $item)) + $order->delivery_date = $item['delivery_date']; + $order->save(false, false); $this->saveMatchId('order', (int)$order->id, (int)$item['id_cart']); From 00f304569013dbdc1d7190e6dbb9bf4165d2dfa4 Mon Sep 17 00:00:00 2001 From: sjousse Date: Mon, 9 Sep 2013 17:24:27 +0200 Subject: [PATCH 07/72] fix imported prices --- modules/shopimporter/shopimporter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index 0620403cd..39cfdb822 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -1490,9 +1490,11 @@ class shopimporter extends ImportModule $order->total_products_wt = (float)$item['total_products_wt']; $order->total_discounts = (float)$item['total_discounts']; $order->total_shipping = (float)$item['total_shipping']; + $order->total_shipping_tax_incl = (float)$item['total_shipping']; $order->carrier_tax_rate = (float)$carrier->getTaxesRate(new Address((int)$item[Configuration::get('PS_TAX_ADDRESS_TYPE')])); $order->total_wrapping = (float)$item['total_wrapping']; $order->total_paid = (float)$item['total_paid']; + $order->total_paid_tax_incl = (float)$item['total_paid']; $order->total_paid_real = (float)$item['total_paid_real']; $order->invoice_date = '0000-00-00 00:00:00'; $order->delivery_date = '0000-00-00 00:00:00'; From 4968a792b4943a6c9b99770140480bb060a26abe Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 10 Sep 2013 01:12:52 +0200 Subject: [PATCH 08/72] [-] IN : Remove notice when upgrading from --- install-dev/upgrade/php/create_multistore.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install-dev/upgrade/php/create_multistore.php b/install-dev/upgrade/php/create_multistore.php index c09b2916b..d0ecbf7b8 100755 --- a/install-dev/upgrade/php/create_multistore.php +++ b/install-dev/upgrade/php/create_multistore.php @@ -29,7 +29,8 @@ require_once(_PS_INSTALLER_PHP_UPGRADE_DIR_.'add_new_tab.php'); function create_multistore() { $res = true; - + if (!defined('_THEME_NAME_')) + define('_THEME_NAME_', 'default'); // @todo : use _PS_ROOT_DIR_ if (defined('__PS_BASE_URI__')) $INSTALLER__PS_BASE_URI = __PS_BASE_URI__; From 021790a3e2dfb8f95ceb26b918e8e80d367660fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 10 Sep 2013 10:15:52 +0200 Subject: [PATCH 09/72] [-] FO: Fix SSL links on domain_ssl instead domain --- classes/Link.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/classes/Link.php b/classes/Link.php index 21e6201ea..03cf66c36 100644 --- a/classes/Link.php +++ b/classes/Link.php @@ -241,8 +241,6 @@ class LinkCore */ public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null, $id_shop = null) { - $base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://'); - if (!$id_lang) $id_lang = Context::getContext()->language->id; @@ -250,7 +248,9 @@ class LinkCore $shop = Context::getContext()->shop; else $shop = new Shop($id_shop); - $url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop); + + $base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain); + $url = $base.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop); $dispatcher = Dispatcher::getInstance(); @@ -362,8 +362,6 @@ class LinkCore */ public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null, $id_shop = null) { - $base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://'); - if (!$id_lang) $id_lang = Context::getContext()->language->id; @@ -371,7 +369,9 @@ class LinkCore $shop = Context::getContext()->shop; else $shop = new Shop($id_shop); - $url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop); + + $base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain); + $url = $base.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop); // If the module has its own route ... just use it ! if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop)) @@ -475,8 +475,9 @@ class LinkCore $shop = new Shop($id_shop); $uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request, false, '', $id_shop); - $url = ($ssl && $this->ssl_enable) ? 'https://' : 'http://'; - $url .= $shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/'); + + $url = ($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain; + $url .= $shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/'); return $url; } From c4681c1fb1a1d6ee3e458820a2d1554b3b64f209 Mon Sep 17 00:00:00 2001 From: Nicolas Sorosac Date: Tue, 10 Sep 2013 10:24:40 +0200 Subject: [PATCH 10/72] [*] MO : MailAlerts : multishop/multilang full compatibility Customers will receive alerts based on the real context of the moment they subscribed to the alert (sho, theme & language) SQL update table : `ps_mailalert_customer_oos` ========================================= ALTER TABLE `ps_mailalert_customer_oos` ADD `id_lang` INT( 10 ) UNSIGNED NOT NULL , DROP PRIMARY KEY , ADD PRIMARY KEY ( `id_customer` , `customer_email` , `id_product` , `id_product_attribute` , `id_shop` ) ; --- modules/mailalerts/MailAlert.php | 63 ++++-- .../mailalerts/controllers/front/actions.php | 38 ++-- modules/mailalerts/mailalerts.php | 193 +++++++++++------- 3 files changed, 182 insertions(+), 112 deletions(-) diff --git a/modules/mailalerts/MailAlert.php b/modules/mailalerts/MailAlert.php index a0124326d..5f089c58e 100644 --- a/modules/mailalerts/MailAlert.php +++ b/modules/mailalerts/MailAlert.php @@ -36,6 +36,8 @@ class MailAlert extends ObjectModel public $id_shop; + public $id_lang; + /** * @see ObjectModel::$definition */ @@ -47,15 +49,19 @@ class MailAlert extends ObjectModel 'customer_email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true), 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), 'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true) + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true) ), ); - public static function customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop = null) + public static function customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop = null, $id_lang = null) { if ($id_shop == null) $id_shop = Context::getContext()->shop->id; + if ($id_lang == null) + $id_lang = Context::getContext()->language->id; + $customer = new Customer($id_customer); $customer_email = $customer->email; @@ -70,14 +76,15 @@ class MailAlert extends ObjectModel return count(Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)); } - public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute) + public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute, $id_shop) { $sql = ' DELETE FROM `'._DB_PREFIX_.self::$definition['table'].'` WHERE '.(($id_customer > 0) ? '(`customer_email` = \''.pSQL($customer_email).'\' OR `id_customer` = '.(int)$id_customer.')' : '`customer_email` = \''.pSQL($customer_email).'\''). ' AND `id_product` = '.(int)$id_product.' - AND `id_product_attribute` = '.(int)$id_product_attribute; + AND `id_product_attribute` = '.(int)$id_product_attribute.' + AND `id_shop` = '.(int)$id_shop; return Db::getInstance()->execute($sql); } @@ -160,17 +167,23 @@ class MailAlert extends ObjectModel public static function sendCustomerAlert($id_product, $id_product_attribute) { $link = new Link(); - - $id_lang = (int)Context::getContext()->language->id; - $product = new Product((int)$id_product, false, $id_lang); - $templateVars = array( - '{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), - '{product_link}' => $link->getProductLink($product) - ); - + $context = Context::getContext()->cloneContext(); $customers = self::getCustomers($id_product, $id_product_attribute); + foreach ($customers as $customer) { + $id_shop = (int)$customer['id_shop']; + $id_lang = (int)$customer['id_lang']; + $context->shop->id = $id_shop; + $context->language->id = $id_lang; + + $product = new Product((int)$id_product, false, $id_lang, $id_shop); + $product_link = $link->getProductLink($product, $product->link_rewrite, null, null, $id_lang, $id_shop); + $templateVars = array( + '{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), + '{product_link}' => $product_link + ); + if ($customer['id_customer']) { $customer = new Customer((int)$customer['id_customer']); @@ -182,14 +195,30 @@ class MailAlert extends ObjectModel $customer_id = 0; $customer_email = $customer['customer_email']; } + $iso = Language::getIsoById($id_lang); - + if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.txt') && file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.html')) - Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'customer_qty', Mail::l('Product available', $id_lang), $templateVars, strval($customer_email), NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/'); + Mail::Send( + $id_lang, + 'customer_qty', + Mail::l('Product available', $id_lang), + $templateVars, + strval($customer_email), + NULL, + strval(Configuration::get('PS_SHOP_EMAIL', null, null, $id_shop)), + strval(Configuration::get('PS_SHOP_NAME', null, null, $id_shop)), + NULL, + NULL, + dirname(__FILE__).'/mails/', + false, + $id_shop + ); - Hook::exec('actionModuleMailAlertSendCustomer', array('product' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), 'link' => $link->getProductLink($product), 'customer' => $customer, 'product_obj' => $product)); - self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute); + Hook::exec('actionModuleMailAlertSendCustomer', array('product' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), 'link' => $product_link, 'customer' => $customer, 'product_obj' => $product)); + + self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute, $id_shop); } } @@ -244,7 +273,7 @@ class MailAlert extends ObjectModel public static function getCustomers($id_product, $id_product_attribute) { $sql = ' - SELECT id_customer, customer_email + SELECT id_customer, customer_email, id_shop, id_lang FROM `'._DB_PREFIX_.self::$definition['table'].'` WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute; diff --git a/modules/mailalerts/controllers/front/actions.php b/modules/mailalerts/controllers/front/actions.php index a1ff41a55..51c654de3 100644 --- a/modules/mailalerts/controllers/front/actions.php +++ b/modules/mailalerts/controllers/front/actions.php @@ -64,8 +64,10 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController if (!Validate::isLoadedObject($product)) die('0'); - if (MailAlert::deleteAlert((int)Context::getContext()->customer->id, (int)Context::getContext()->customer->email, (int)$product->id, (int)$this->id_product_attribute)) + $context = Context::getContext(); + if (MailAlert::deleteAlert((int)$context->customer->id, (int)$context->customer->email, (int)$product->id, (int)$this->id_product_attribute)) die('0'); + die(1); } @@ -74,29 +76,32 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController */ public function processAdd() { - if (Context::getContext()->customer->isLogged()) + $context = Context::getContext(); + + if ($context->customer->isLogged()) { - $id_customer = (int)Context::getContext()->customer->id; + $id_customer = (int)$context->customer->id; $customer = new Customer($id_customer); $customer_email = strval($customer->email); } else { $customer_email = strval(Tools::getValue('customer_email')); - $customer = Context::getContext()->customer->getByEmail($customer_email); + $customer = $context->customer->getByEmail($customer_email); $id_customer = (isset($customer->id) && ($customer->id != null)) ? (int)$customer->id : null; } $id_product = (int)Tools::getValue('id_product'); $id_product_attribute = (int)Tools::getValue('id_product_attribute'); - $id_shop = (int)Context::getContext()->shop->id; - $product = new Product($id_product, null, null, $id_shop, Context::getContext()); + $id_shop = (int)$context->shop->id; + $id_lang = (int)$context->language->id; + $product = new Product($id_product, false, $id_lang, $id_shop, $context); $mailAlert = MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop); if ($mailAlert) die('2'); - else if (!Validate::isLoadedObject($product)) + elseif (!Validate::isLoadedObject($product)) die('0'); $mailAlert = new MailAlert(); @@ -106,10 +111,11 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController $mailAlert->id_product = (int)$id_product; $mailAlert->id_product_attribute = (int)$id_product_attribute; $mailAlert->id_shop = (int)$id_shop; + $mailAlert->id_lang = (int)$id_lang; if ($mailAlert->add() !== false) die('1'); - + die('0'); } @@ -122,15 +128,15 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController die('0'); $id_customer = (int)$this->context->customer->id; - - if (!$id_product = (int)(Tools::getValue('id_product'))) - die ('0'); - $id_product_attribute = (int)(Tools::getValue('id_product_attribute')); - $id_shop = (int)Context::getContext()->shop->id; - if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$id_shop)) - die ('1'); - + if (!$id_product = (int)(Tools::getValue('id_product'))) + die('0'); + + $id_product_attribute = (int)(Tools::getValue('id_product_attribute')); + + if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$this->context->shop->id)) + die('1'); + die('0'); } } \ No newline at end of file diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php index 417ae3fa9..abb4321ad 100644 --- a/modules/mailalerts/mailalerts.php +++ b/modules/mailalerts/mailalerts.php @@ -40,13 +40,13 @@ class MailAlerts extends Module private $_merchant_coverage; private $_product_coverage; - const __MA_MAIL_DELIMITOR__ = ','; + const __MA_MAIL_DELIMITOR__ = "\n"; public function __construct() { $this->name = 'mailalerts'; $this->tab = 'administration'; - $this->version = '2.4'; + $this->version = '2.5'; $this->author = 'PrestaShop'; $this->need_instance = 0; @@ -100,7 +100,8 @@ class MailAlerts extends Module `id_product` int(10) unsigned NOT NULL, `id_product_attribute` int(10) unsigned NOT NULL, `id_shop` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_customer`,`customer_email`,`id_product`,`id_product_attribute`) + `id_lang` int(10) unsigned NOT NULL, + PRIMARY KEY (`id_customer`,`customer_email`,`id_product`,`id_product_attribute`,`id_shop`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; if (!Db::getInstance()->execute($sql)) @@ -161,7 +162,7 @@ class MailAlerts extends Module $errors[] = $this->l('Invalid e-mail:').' '.Tools::safeOutput($email); break; } - else if (!empty($email) && count($email) > 0) + elseif (!empty($email) && count($email) > 0) $emails[$k] = $email; else unset($emails[$k]); @@ -171,15 +172,15 @@ class MailAlerts extends Module if (!Configuration::updateValue('MA_MERCHANT_MAILS', strval($emails))) $errors[] = $this->l('Cannot update settings'); - else if (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('mA_merchand_order'))) + elseif (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('mA_merchand_order'))) $errors[] = $this->l('Cannot update settings'); - else if (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('mA_merchand_oos'))) + elseif (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('mA_merchand_oos'))) $errors[] = $this->l('Cannot update settings'); - else if (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES'))) + elseif (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES'))) $errors[] = $this->l('Cannot update settings'); - else if (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('mA_merchant_coverage'))) + elseif (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('mA_merchant_coverage'))) $errors[] = $this->l('Cannot update settings'); - else if (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE'))) + elseif (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE'))) $errors[] = $this->l('Cannot update settings'); } } @@ -262,14 +263,16 @@ class MailAlerts extends Module return; // Getting differents vars - $id_lang = (int)Context::getContext()->language->id; + $context = Context::getContext(); + $id_lang = (int)$context->language->id; + $id_shop = (int)$context->shop->id; $currency = $params['currency']; - $configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME')); $order = $params['order']; $customer = $params['customer']; + $configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR'), $id_lang, null, $id_shop); $delivery = new Address((int)$order->id_address_delivery); $invoice = new Address((int)$order->id_address_invoice); - $order_date_text = Tools::displayDate($order->date_add); + $order_date_text = Tools::displayDate($order->date_add, (int)$id_lang); $carrier = new Carrier((int)$order->id_carrier); $message = $order->getFirstMessage(); @@ -288,7 +291,6 @@ class MailAlerts extends Module $customization_text = ''; if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']])) { - foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']] as $customization) { if (isset($customization['datas'][_CUSTOMIZE_TEXTFIELD_])) @@ -339,11 +341,11 @@ class MailAlerts extends Module '{delivery_block_txt}' => MailAlert::getFormatedAddress($delivery, "\n"), '{invoice_block_txt}' => MailAlert::getFormatedAddress($invoice, "\n"), '{delivery_block_html}' => MailAlert::getFormatedAddress($delivery, '
', array( - 'firstname' => '%s', - 'lastname' => '%s')), + 'firstname' => '%s', + 'lastname' => '%s')), '{invoice_block_html}' => MailAlert::getFormatedAddress($invoice, '
', array( - 'firstname' => '%s', - 'lastname' => '%s')), + 'firstname' => '%s', + 'lastname' => '%s')), '{delivery_company}' => $delivery->company, '{delivery_firstname}' => $delivery->firstname, '{delivery_lastname}' => $delivery->lastname, @@ -353,9 +355,7 @@ class MailAlerts extends Module '{delivery_postal_code}' => $delivery->postcode, '{delivery_country}' => $delivery->country, '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', - '{delivery_phone}' => $delivery->phone, - '{delivery_phone_mobile}' => $delivery->phone_mobile, - '{delivery_vat_number}' => $delivery->vat_number, + '{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile, '{delivery_other}' => $delivery->other, '{invoice_company}' => $invoice->company, '{invoice_firstname}' => $invoice->firstname, @@ -366,21 +366,18 @@ class MailAlerts extends Module '{invoice_postal_code}' => $invoice->postcode, '{invoice_country}' => $invoice->country, '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', - '{invoice_phone}' => $invoice->phone, - '{invoice_phone_mobile}' => $invoice->phone_mobile, - '{invoice_vat_number}' => $invoice->vat_number, + '{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile, '{invoice_other}' => $invoice->other, '{order_name}' => sprintf('%06d', $order->id), - '{shop_name}' => Configuration::get('PS_SHOP_NAME'), + '{shop_name}' => $configuration['PS_SHOP_NAME'], '{date}' => $order_date_text, - '{carrier}' => (($carrier->name == '0') ? Configuration::get('PS_SHOP_NAME') : $carrier->name), + '{carrier}' => (($carrier->name == '0') ? $configuration['PS_SHOP_NAME'] : $carrier->name), '{payment}' => Tools::substr($order->payment, 0, 32), '{items}' => $items_table, '{total_paid}' => Tools::displayPrice($order->total_paid, $currency), '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency), '{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency), '{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency), - '{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $currency, false), '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency), '{currency}' => $currency->sign, '{message}' => $message @@ -390,19 +387,28 @@ class MailAlerts extends Module if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') && file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html')) - Mail::Send( - $id_lang, - $template, - sprintf(Mail::l('New order - #%06d', $id_lang), $order->id), - $template_vars, - explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails), - null, - $configuration['PS_SHOP_EMAIL'], - $configuration['PS_SHOP_NAME'], - null, - null, - dirname(__FILE__).'/mails/' - ); + { + // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients + $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails); + foreach ($merchant_mails as $merchant_mail) + { + Mail::Send( + $id_lang, + $template, + sprintf(Mail::l('New order - #%06d', $id_lang), $order->id), + $template_vars, + $merchant_mail, + null, + $configuration['PS_SHOP_EMAIL'], + $configuration['PS_SHOP_NAME'], + null, + null, + dirname(__FILE__).'/mails/', + null, + $id_shop + ); + } + } } public function hookActionProductOutOfStock($params) @@ -410,18 +416,20 @@ class MailAlerts extends Module if (!$this->_customer_qty || !Configuration::get('PS_STOCK_MANAGEMENT') || Product::isAvailableWhenOutOfStock($params['product']->out_of_stock)) return; + $context = Context::getContext(); $id_product = (int)$params['product']->id; $id_product_attribute = 0; - $id_customer = (int)Context::getContext()->customer->id; + $id_customer = (int)$context->customer->id; - if (!(int)Context::getContext()->customer->isLogged()) + if ((int)$context->customer->id <= 0) $this->context->smarty->assign('email', 1); - else if (MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute)) + elseif (MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, (int)$context->shop->id)) return; $this->context->smarty->assign(array( - 'id_product' => $id_product, - 'id_product_attribute' => $id_product_attribute)); + 'id_product' => $id_product, + 'id_product_attribute' => $id_product_attribute + )); return $this->display(__FILE__, 'product.tpl'); } @@ -431,33 +439,47 @@ class MailAlerts extends Module $id_product = (int)$params['id_product']; $id_product_attribute = (int)$params['id_product_attribute']; $quantity = (int)$params['quantity']; - $id_shop = (int)Context::getContext()->shop->id; - $id_lang = (int)Context::getContext()->language->id; - $product = new Product($id_product, true, $id_lang, $id_shop, Context::getContext()); - $ma_last_qties = (int)Configuration::get('MA_LAST_QTIES'); + $context = Context::getContext(); + $id_shop = (int)$context->shop->id; + $id_lang = (int)$context->language->id; + $product = new Product($id_product, true, $id_lang, $id_shop, $context); + $configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), $id_lang, null, $id_shop); + $ma_last_qties = (int)$configuration['MA_LAST_QTIES']; - if ($product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && Configuration::get('PS_STOCK_MANAGEMENT')) + if ($product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT']) { $iso = Language::getIsoById($id_lang); $product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang); $template_vars = array( - '{qty}' => $quantity, - '{last_qty}' => $ma_last_qties, - '{product}' => $product_name); + '{qty}' => $quantity, + '{last_qty}' => $ma_last_qties, + '{product}' => $product_name + ); if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.txt') && file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.html')) - Mail::Send($id_lang, - 'productoutofstock', - Mail::l('Product out of stock', $id_lang), - $template_vars, - explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails), - null, - strval(Configuration::get('PS_SHOP_EMAIL')), - strval(Configuration::get('PS_SHOP_NAME')), - null, - null, - dirname(__FILE__).'/mails/'); + { + // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients + $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails); + foreach ($merchant_mails as $merchant_mail) + { + Mail::Send( + $id_lang, + 'productoutofstock', + Mail::l('Product out of stock', $id_lang), + $template_vars, + $merchant_mail, + null, + strval($configuration['PS_SHOP_EMAIL']), + strval($configuration['PS_SHOP_NAME']), + null, + null, + dirname(__FILE__).'/mails/', + false, + $id_shop + ); + } + } } if ($this->_customer_qty && $quantity > 0) @@ -541,31 +563,44 @@ class MailAlerts extends Module $coverage = StockManagerFactory::getManager()->getProductCoverage($id_product, $id_product_attribute, $warning_coverage, $id_warehouse); // if we need to send a notification - if ($product->active == 1 && $coverage !== -1 && ($coverage < $warning_coverage) && !empty($this->_merchant_mails) && + if ($product->active == 1 && + ($coverage < $warning_coverage) && !empty($this->_merchant_mails) && Configuration::getGlobalValue('MA_MERCHANT_COVERAGE')) { - $id_lang = (int)Context::getContext()->language->id; + $context = Context::getContext(); + $id_lang = (int)$context->language->id; + $id_shop = (int)$context->shop->id; $iso = Language::getIsoById($id_lang); $product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang); $template_vars = array( - '{current_coverage}' => $coverage, - '{warning_coverage}' => $warning_coverage, - '{product}' => pSQL($product_name)); + '{current_coverage}' => $coverage, + '{warning_coverage}' => $warning_coverage, + '{product}' => pSQL($product_name) + ); if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.txt') && file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.html')) { - Mail::Send($id_lang, - 'productcoverage', - Mail::l('Stock coverage', $id_lang), - $template_vars, - explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails), - null, - strval(Configuration::get('PS_SHOP_EMAIL')), - strval(Configuration::get('PS_SHOP_NAME')), - null, - null, - dirname(__FILE__).'/mails/'); + // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients + $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails); + foreach ($merchant_mails as $merchant_mail) + { + Mail::Send( + $id_lang, + 'productcoverage', + Mail::l('Stock coverage', $id_lang), + $template_vars, + $merchant_mail, + null, + strval(Configuration::get('PS_SHOP_EMAIL')), + strval(Configuration::get('PS_SHOP_NAME')), + null, + null, + dirname(__FILE__).'/mails/', + null, + $id_shop + ); + } } } } From 3c090535a9d9e3d08950e2760e98f18898e66196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 10 Sep 2013 10:39:03 +0200 Subject: [PATCH 11/72] // small fix for image SSL links --- classes/Tools.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/Tools.php b/classes/Tools.php index d8ead1538..31adb3bbf 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1596,7 +1596,8 @@ class ToolsCore if (self::$_cache_nb_media_servers && ($id_media_server = (abs(crc32($filename)) % self::$_cache_nb_media_servers + 1))) return constant('_MEDIA_SERVER_'.$id_media_server.'_'); - return Tools::getShopDomain(); + + return Tools::usingSecureMode() ? Tools::getShopDomainSSL() : Tools::getShopDomain(); } public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null) From f30a088848766461b4cb465df75759ff7d087e18 Mon Sep 17 00:00:00 2001 From: Nicolas Sorosac Date: Tue, 10 Sep 2013 11:01:11 +0200 Subject: [PATCH 12/72] [*] MO : MailAlerts : Add SQL update script for v2.5 --- modules/mailalerts/upgrade/install-2.5.php | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 modules/mailalerts/upgrade/install-2.5.php diff --git a/modules/mailalerts/upgrade/install-2.5.php b/modules/mailalerts/upgrade/install-2.5.php new file mode 100644 index 000000000..8696a4a2b --- /dev/null +++ b/modules/mailalerts/upgrade/install-2.5.php @@ -0,0 +1,29 @@ +execute(' + ALTER TABLE '._DB_PREFIX_.'mailalert_customer_oos + ADD '.mailalerts_stripslashes_field('id_lang').' INT( 10 ) UNSIGNED NOT NULL , + DROP PRIMARY KEY , + ADD PRIMARY KEY ( + '.mailalerts_stripslashes_field('id_customer').' , + '.mailalerts_stripslashes_field('customer_email').' , + '.mailalerts_stripslashes_field('id_product').' , + '.mailalerts_stripslashes_field('id_product_attribute').' , + '.mailalerts_stripslashes_field('id_shop').' + )' + ); +} + +function mailalerts_stripslashes_field($field) +{ + $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 From 332d68c7ec89bbc39ee89fa76d2e2ee899a15ef8 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 10 Sep 2013 11:08:57 +0200 Subject: [PATCH 13/72] [-] MO : Statsdata, exception on duplicate entry --- classes/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Connection.php b/classes/Connection.php index 4b171b1f0..23514695b 100644 --- a/classes/Connection.php +++ b/classes/Connection.php @@ -97,7 +97,7 @@ class ConnectionCore extends ObjectModel 'id_connections' => (int)$cookie->id_connections, 'id_page' => (int)$id_page, 'time_start' => $time_start - )); + ), false, true, Db::INSERT_IGNORE); // This array is serialized and used by the ajax request to identify the page return array( From c5afbc75bd153d9d68c86857ec4f0c675a08dd2f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Sep 2013 12:01:38 +0200 Subject: [PATCH 14/72] [-] MO : carriercompare fixed bug, override template's files in theme. Ticket #PNM-1691 --- modules/carriercompare/carriercompare.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/carriercompare/carriercompare.php b/modules/carriercompare/carriercompare.php index 910088a43..8b82e30a6 100755 --- a/modules/carriercompare/carriercompare.php +++ b/modules/carriercompare/carriercompare.php @@ -72,7 +72,7 @@ class CarrierCompare extends Module $this->postProcess(); $this->smarty->assign('refresh_method', Configuration::get('SE_RERESH_METHOD')); - return $this->smarty->fetch($this->template_directory .'configuration.tpl'); + return $this->display(__FILE__, 'template/configuration.tpl'); } public function postProcess() @@ -155,7 +155,7 @@ class CarrierCompare extends Module 'refresh_method' => ($refresh_method === false) ? 0 : $refresh_method )); - return $this->smarty->fetch($this->template_directory.'carriercompare.tpl'); + return $this->display(__FILE__, 'template/carriercompare.tpl'); } /* From 9713f93075d051b9247267017100547021f15148 Mon Sep 17 00:00:00 2001 From: Nils-Helge Garli Hegvik Date: Tue, 10 Sep 2013 17:11:34 +0200 Subject: [PATCH 15/72] Add Bcc support in Mail class --- classes/Mail.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/classes/Mail.php b/classes/Mail.php index d53498b32..c4367878a 100644 --- a/classes/Mail.php +++ b/classes/Mail.php @@ -50,10 +50,11 @@ class MailCore * @param bool $modeSMTP * @param string $template_path * @param bool $die + * @param string $bcc Bcc recipient */ public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, - $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null) + $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null) { $configuration = Configuration::getMultiple(array( 'PS_SHOP_EMAIL', @@ -127,9 +128,9 @@ class MailCore } /* Construct multiple recipients list if needed */ + $to_list = new Swift_RecipientList(); if (is_array($to) && isset($to)) { - $to_list = new Swift_RecipientList(); foreach ($to as $key => $addr) { $to_name = null; @@ -153,17 +154,20 @@ class MailCore $to_list->addTo($addr, self::mimeEncode($to_name)); } $to_plugin = $to[0]; - $to = $to_list; } else { /* Simple recipient, one address */ $to_plugin = $to; if ($to_name == null) $to_name = $to; if (function_exists('mb_encode_mimeheader')) - $to = new Swift_Address($to, mb_encode_mimeheader($to_name, 'utf-8')); + $to_list->addTo($to, mb_encode_mimeheader($to_name, 'utf-8')); else - $to = new Swift_Address($to, self::mimeEncode($to_name)); + $to_list->addTo($to, self::mimeEncode($to_name)); } + if(isset($bcc)) { + $to_list->addBcc($bcc); + } + $to = $to_list; try { /* Connect with the appropriate configuration */ if ($configuration['PS_MAIL_METHOD'] == 2) @@ -445,4 +449,4 @@ class MailCore return $start . $string . $end; } -} \ No newline at end of file +} From f94f0f14a4b94708ac175e2d3867c75f5f2f7a59 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 10 Sep 2013 18:48:28 +0200 Subject: [PATCH 16/72] [-] FO : Fix bug #PSCFV-8917 taxes calculation when changing delivery address --- classes/Cart.php | 17 ++++++++++++----- classes/tax/TaxRulesTaxManager.php | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index e57509cc3..828bda26c 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -3415,6 +3415,7 @@ class CartCore extends ObjectModel */ public function setNoMultishipping() { + $emptyCache = $result = false; if (Configuration::get('PS_ALLOW_MULTISHIPPING')) { // Upgrading quantities @@ -3433,7 +3434,9 @@ class CartCore extends ObjectModel AND `id_shop` = '.(int)$this->id_shop.' AND id_product = '.$product['id_product'].' AND id_product_attribute = '.$product['id_product_attribute']; - Db::getInstance()->execute($sql); + $result = Db::getInstance()->execute($sql); + if ($result) + $emptyCache = true; } // Merging multiple lines @@ -3451,15 +3454,16 @@ class CartCore extends ObjectModel } // Update delivery address for each product line - Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'cart_product` + $sql = 'UPDATE `'._DB_PREFIX_.'cart_product` SET `id_address_delivery` = ( SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart` WHERE `id_cart` = '.(int)$this->id.' AND `id_shop` = '.(int)$this->id_shop.' ) WHERE `id_cart` = '.(int)$this->id.' - '.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '')); - + '.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : ''); + + $emptyCache = Db::getInstance()->execute($sql); + if (Customization::isFeatureActive()) Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'customization` @@ -3468,6 +3472,9 @@ class CartCore extends ObjectModel WHERE `id_cart` = '.(int)$this->id.' ) WHERE `id_cart` = '.(int)$this->id); + + if ($emptyCache) + $this->_products = null; } /** diff --git a/classes/tax/TaxRulesTaxManager.php b/classes/tax/TaxRulesTaxManager.php index dcb78419e..99cbea94d 100644 --- a/classes/tax/TaxRulesTaxManager.php +++ b/classes/tax/TaxRulesTaxManager.php @@ -80,7 +80,7 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface if (!empty($this->address->postcode)) $postcode = $this->address->postcode; - if (!isset(self::$cache_tax_calculator[$postcode.'-'.$this->type])) + if (!isset(self::$cache_tax_calculator[(int)$this->address->id_country.'-'.$postcode.'-'.$this->type])) { $rows = Db::getInstance()->executeS(' SELECT * From 85a471a6905cbf3867acdfdafdcce6b2d622b7b2 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 10 Sep 2013 18:51:20 +0200 Subject: [PATCH 17/72] //bad commit , sorry for that --- classes/Cart.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/Cart.php b/classes/Cart.php index 828bda26c..f477f38b0 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -3462,7 +3462,9 @@ class CartCore extends ObjectModel WHERE `id_cart` = '.(int)$this->id.' '.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : ''); - $emptyCache = Db::getInstance()->execute($sql); + $result = Db::getInstance()->execute($sql); + if ($result) + $emptyCache = true; if (Customization::isFeatureActive()) Db::getInstance()->execute(' From 614e56283a3f944fbd31dac3370e4037c70860a2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 11 Sep 2013 10:49:34 +0800 Subject: [PATCH 18/72] Update mailalerts.php Fixes issue where customization data is not included in new order email. --- modules/mailalerts/mailalerts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php index 417ae3fa9..f0be4a5a3 100644 --- a/modules/mailalerts/mailalerts.php +++ b/modules/mailalerts/mailalerts.php @@ -289,7 +289,7 @@ class MailAlerts extends Module if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']])) { - foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']] as $customization) + foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization) { if (isset($customization['datas'][_CUSTOMIZE_TEXTFIELD_])) foreach ($customization['datas'][_CUSTOMIZE_TEXTFIELD_] as $text) From 9f12ff15be440e42ff65fa5f4a51c9fa8d98e38c Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 11 Sep 2013 10:30:40 +0200 Subject: [PATCH 19/72] [-] BO : Fix possible Uncaught exception 'ReflectionException' when viewing AdminMeta --- classes/Meta.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/classes/Meta.php b/classes/Meta.php index e4c3b3147..76933c88b 100644 --- a/classes/Meta.php +++ b/classes/Meta.php @@ -68,8 +68,11 @@ class MetaCore extends ObjectModel { if ($file != 'index.php' && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages)) { - $reflection = new ReflectionClass(str_replace('.php', '', $file)); - $properties = $reflection->getDefaultProperties(); + $class_name = str_replace('.php', '', $file); + if (class_exists($class_name)) + $reflection = new ReflectionClass(str_replace('.php', '', $file)); + if (isset($reflection) && $reflection) + $properties = $reflection->getDefaultProperties(); if (isset($properties['php_self'])) $selected_pages[$properties['php_self']] = $properties['php_self']; else if (preg_match('/^[a-z0-9_.-]*\.php$/i', $file)) From 01be908e517d37b1aad9595fd81b9bc897fe82d5 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 11 Sep 2013 14:50:42 +0200 Subject: [PATCH 20/72] [-] CORE : Could not add several cart rules --- classes/Cart.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/Cart.php b/classes/Cart.php index f477f38b0..d19fb0ab0 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -762,10 +762,11 @@ class CartCore extends ObjectModel { // You can't add a cart rule that does not exist $cartRule = new CartRule($id_cart_rule, Context::getContext()->language->id); + if (!Validate::isLoadedObject($cartRule)) return false; - if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$this->id)) + if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart_rule = '.(int)$id_cart_rule.' AND id_cart = '.(int)$this->id)) return false; // Add the cart rule to the cart From 3e750490feef2d55855c5713310e1e4f852725ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 11 Sep 2013 15:16:15 +0200 Subject: [PATCH 21/72] // chmod class_index 666 instead of 664 --- classes/Autoload.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/classes/Autoload.php b/classes/Autoload.php index 585ad858e..91864a22d 100644 --- a/classes/Autoload.php +++ b/classes/Autoload.php @@ -138,18 +138,14 @@ class Autoload { $filename_tmp = tempnam(dirname($filename), basename($filename.'.')); if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE) - { + { @rename($filename_tmp, $filename); - @chmod($filename, 0664); + @chmod($filename, 0666); } - else - { - // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), - // no need to die. + else + // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die. error_log('Cannot write temporary file '.$filename_tmp); - } } - $this->index = $classes; } @@ -191,5 +187,4 @@ class Autoload { return isset($this->index[$classname]) ? $this->index[$classname] : null; } -} - +} \ No newline at end of file From 669c3791b5cb94cd7323fd10931bb4ebbfb70e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 11 Sep 2013 15:55:25 +0200 Subject: [PATCH 22/72] [-] BO: Fix preview url with multishop --- classes/Dispatcher.php | 6 +- controllers/admin/AdminProductsController.php | 61 ++----------------- 2 files changed, 7 insertions(+), 60 deletions(-) diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php index c96926263..de874eb67 100644 --- a/classes/Dispatcher.php +++ b/classes/Dispatcher.php @@ -549,7 +549,7 @@ class DispatcherCore if ($id_shop === null) $id_shop = (int)Context::getContext()->shop->id; - if ($this->use_routes && !isset($this->routes[$id_shop])) + if (!isset($this->routes[$id_shop])) $this->loadRoutes($id_shop); if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id])) @@ -594,9 +594,9 @@ class DispatcherCore if ($id_shop === null) $id_shop = (int)Context::getContext()->shop->id; - if ($this->use_routes && !isset($this->routes[$id_shop])) + if (!isset($this->routes[$id_shop])) $this->loadRoutes($id_shop); - + if (!isset($this->routes[$id_shop][$id_lang][$route_id])) { $query = http_build_query($params, '', '&'); diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index b95d88942..c2239130c 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1736,27 +1736,7 @@ class AdminProductsControllerCore extends AdminController // Save and preview if (Tools::isSubmit('submitAddProductAndPreview')) - { - $preview_url = $this->context->link->getProductLink( - $this->getFieldValue($this->object, 'id'), - $this->getFieldValue($this->object, 'link_rewrite', $this->context->language->id), - Category::getLinkRewrite($this->getFieldValue($this->object, 'id_category_default'), $this->context->language->id), - null, - null, - Context::getContext()->shop->id, - 0, - (bool)Configuration::get('PS_REWRITING_SETTINGS') - ); - - if (!$this->object->active) - { - $admin_dir = dirname($_SERVER['PHP_SELF']); - $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); - $preview_url .= '&adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id; - } - - $this->redirect_after = $preview_url; - } + $this->redirect_after = $this->getPreviewUrl($this->object); // Save and stay on same form if ($this->display == 'edit') @@ -1901,30 +1881,8 @@ class AdminProductsControllerCore extends AdminController // Save and preview if (Tools::isSubmit('submitAddProductAndPreview')) - { - $preview_url = $this->context->link->getProductLink( - $this->getFieldValue($object, 'id'), - $this->getFieldValue($object, 'link_rewrite', $this->context->language->id), - Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $this->context->language->id), - null, - null, - Context::getContext()->shop->id, - 0, - (bool)Configuration::get('PS_REWRITING_SETTINGS') - ); + $this->redirect_after = $this->getPreviewUrl($object);; - if (!$object->active) - { - $admin_dir = dirname($_SERVER['PHP_SELF']); - $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); - if (strpos($preview_url, '?') === false) - $preview_url .= '?'; - else - $preview_url .= '&'; - $preview_url .= 'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id; - } - $this->redirect_after = $preview_url; - } else { // Save and stay on same form @@ -2625,30 +2583,19 @@ class AdminProductsControllerCore extends AdminController $preview_url = $this->context->link->getProductLink( $product, $this->getFieldValue($product, 'link_rewrite', $this->context->language->id), - Category::getLinkRewrite($product->id_category_default, $this->context->language->id), + Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id), null, $id_lang, - Context::getContext()->shop->id, + (int)Context::getContext()->shop->id, 0, $is_rewrite_active ); if (!$product->active) { - $preview_url = $this->context->link->getProductLink( - $product, - $this->getFieldValue($product, 'link_rewrite', $this->default_form_language), - Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id), - null, - $id_lang, - Context::getContext()->shop->id, - 0, - $is_rewrite_active - ); $admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); $preview_url .= ((strpos($preview_url, '?') === false) ? '?' : '&').'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id; - } return $preview_url; From c42d71b8f5ae034f90a60ab8013610a68be7e82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 11 Sep 2013 16:06:23 +0200 Subject: [PATCH 23/72] // oups --- controllers/admin/AdminProductsController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index c2239130c..187a8ce49 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1881,8 +1881,7 @@ class AdminProductsControllerCore extends AdminController // Save and preview if (Tools::isSubmit('submitAddProductAndPreview')) - $this->redirect_after = $this->getPreviewUrl($object);; - + $this->redirect_after = $this->getPreviewUrl($object); else { // Save and stay on same form From 4a3e0c50754d94a8f86ed70cacc92d8fe58b26c8 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Wed, 11 Sep 2013 16:11:16 +0200 Subject: [PATCH 24/72] // Updated README.md --- README.md | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0d1f0df50..f11b82139 100644 --- a/README.md +++ b/README.md @@ -2,47 +2,48 @@ README ====== ![PrestaShop](http://www.prestashop.com/images/banners/general/prestashop_728x90.png "PrestaShop") -PREPARATION +ABOUT -------- -To install PrestaShop, you need a remote web server or on your computer (MAMP), with access to a database like MySQL. -You'll need access to phpMyAdmin to create a database and to indicate the information in the database in the installer. +PrestaShop is a free and open-source e-commerce web application, committed to providing the best shopping cart experience for both merchants and consumers. + + +SERVER CONFIGURATION +-------- + +To install PrestaShop, you need a web server running PHP5 and any flavor of MySQL5 (MySQL, MariaDB, Percona Server...). +You will also need a database administration tool, such as phpMyAdmin, in order to create a database for PrestaShop. +We recommend the Apache or Nginx web servers. + +If your host does not offer PHP5 by default, here are a few [explanations][2] about PHP5 or the .htaccess file for certain hosting services (1&1, Free, Lycos, OVH, Infomaniak, Amen, GoDaddy, etc). + +If you want your online store ready to go, visit [http://www.prestabox.com][1]: it lets you create your online store in less than 10 minutes without any technical knowledge. -If you do not host and unable to create your store, we offer a turnkey store, which lets you create your online store in less than 10 minutes without any technical knowledge. -We invite you to visit: [http://www.prestabox.com][1] INSTALLATION -------- -Simply go to your PrestaShop web directory and use installer :-) +With your web browser, go to the root of your PrestaShop directory, and the installer will start. Follow the instructions until PrestaShop is installed. -If you have any PHP error, perhaps you don't have PHP5 or you need to activate it on your web host. -Please go to our forum to find pre-installation settings (PHP 5, htaccess) for certain hosting services (1&1, Free, Lycos, OVH, Infomaniak, Amen, GoDaddy, etc). +If you have any PHP error, perhaps you don't have PHP5 or you need to activate it on your web host. See the page linked above. +If you don't find any solution to start the installer, please post on [the PrestaShop forums][3]. -English webhost [specifics settings][2] - - -If you don't find any solution to launch installer, please post on [our forum][3] - - -There are always solutions for your issues ;-) DOCUMENTATION -------- -For any extra documentation (how-to), please read our [Online documentation][4] +The official PrestaShop documentation is available online [on its own website][4]. FORUMS -------- -You can also discuss, help and contribute with PrestaShop community on [our forums][5] +You can discuss, help and contribute with PrestaShop community on [the PrestaShop forums][5]. - -Thanks for downloading and using PrestaShop e-commerce Open-source solution! +Thank you for downloading and using PrestaShop e-commerce Open-source solution! [1]: http://www.prestabox.com [2]: http://www.prestashop.com/forums/topic/2946-pre-installation-settings-php-5-htaccess-for-certain-hosting-services/ [3]: http://www.prestashop.com/forums/forum/7-installing-prestashop/ [4]: http://doc.prestashop.com -[5]: http://www.prestashop.com/forums/ \ No newline at end of file +[5]: http://www.prestashop.com/forums/ From 31c94caebc209cbeef7a772fa27551cc3db8b5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 11 Sep 2013 16:22:13 +0200 Subject: [PATCH 25/72] [-] BO: Fix out of stock creation with multishop and stock sharing --- classes/stock/StockAvailable.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php index 12e23cd39..2e47abb49 100644 --- a/classes/stock/StockAvailable.php +++ b/classes/stock/StockAvailable.php @@ -305,11 +305,7 @@ class StockAvailableCore extends ObjectModel if (!Validate::isUnsignedId($id_product)) return false; - if ($id_shop === null) - $id_shop = Context::getContext()->shop->id; - $existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, (int)$id_product_attribute, (int)$id_shop); - if ($existing_id > 0) { Db::getInstance()->update( From dfdbe39ee3b9840c2b2b041d320864f1896e20d5 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 11 Sep 2013 16:28:11 +0200 Subject: [PATCH 26/72] [-] BO : Small changes when creating vouchers in back office orders --- .../default/template/controllers/orders/form.tpl | 16 +++++++--------- classes/CartRule.php | 2 +- controllers/admin/AdminOrdersController.php | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/orders/form.tpl b/admin-dev/themes/default/template/controllers/orders/form.tpl index 92d2c5ff0..e8de6bf14 100755 --- a/admin-dev/themes/default/template/controllers/orders/form.tpl +++ b/admin-dev/themes/default/template/controllers/orders/form.tpl @@ -117,7 +117,7 @@ $('#vouchers_err').hide(); var mytab = new Array(); for (var i = 0; i < data.vouchers.length; i++) - mytab[mytab.length] = { data: data.vouchers[i], value: data.vouchers[i].name+' - '+data.vouchers[i].description }; + mytab[mytab.length] = { data: data.vouchers[i], value: data.vouchers[i].name + (data.vouchers[i].code.length > 0 ? ' - ' + data.vouchers[i].code : '')}; return mytab; }, extraParams: { @@ -694,17 +694,15 @@ function updateCartVouchers(vouchers) { var vouchers_html = ''; - if (vouchers.length > 0) - { - $.each(vouchers, function() { + if (typeof(vouchers) == 'object') + $.each(vouchers, function(){ vouchers_html += '
'; }); - $('#voucher_list').show(); - } - else + $('#voucher_list tbody').html($.trim(vouchers_html)); + if ($('#voucher_list tbody').html().length == 0) $('#voucher_list').hide(); - - $('#voucher_list tbody').html(vouchers_html); + else + $('#voucher_list').show(); } function updateCartPaymentList(payment_list) diff --git a/classes/CartRule.php b/classes/CartRule.php index 10ab17616..ea87a4174 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -1190,7 +1190,7 @@ class CartRuleCore extends ObjectModel SELECT cr.*, crl.* FROM '._DB_PREFIX_.'cart_rule cr LEFT JOIN '._DB_PREFIX_.'cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang = '.(int)$id_lang.') - WHERE code LIKE \'%'.pSQL($name).'%\' + WHERE code LIKE \'%'.pSQL($name).'%\' OR name LIKE \'%'.pSQL($name).'%\' '); } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 0b9557f64..3ca37b935 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -506,7 +506,7 @@ class AdminOrdersControllerCore extends AdminController if (Tools::isSubmit('generateDiscountRefund') && !count($this->errors)) { $cart_rule = new CartRule(); - $cart_rule->description = sprintf($this->l('Credit card slip for order #%d'), $order->id); + $cart_rule->description = sprintf($this->l('Credit slip for order #%d'), $order->id); $languages = Language::getLanguages(false); foreach ($languages as $language) // Define a temporary name From a4d131eac9ee02b7dd30116c6069b63e70e9d0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 11 Sep 2013 16:32:11 +0200 Subject: [PATCH 27/72] [-] WS: Fix entities retrieve for some cases --- classes/webservice/WebserviceRequest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/classes/webservice/WebserviceRequest.php b/classes/webservice/WebserviceRequest.php index 546370998..2dca1bdb3 100644 --- a/classes/webservice/WebserviceRequest.php +++ b/classes/webservice/WebserviceRequest.php @@ -1289,9 +1289,8 @@ class WebserviceRequestCore $check = ' WHERE ('.implode('OR', $OR).') AND `'.bqSQL($this->resourceConfiguration['fields']['id']['sqlId']).'` = '.(int)$this->urlSegment[1]; if (!Db::getInstance()->getValue($sql.$check)) $this->setError(404, 'This '.$this->resourceConfiguration['retrieveData']['className'].' ('.(int)$this->urlSegment[1].') does not exists on this shop', 131); - else - return $objects; } + return $objects; } if (!count($this->errors)) { From f4f3084c35c313d61f0077700d022cfe9adbf3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 11 Sep 2013 16:40:33 +0200 Subject: [PATCH 28/72] [-] Core: Set a remote addr with php-cli #PSCFV-10372 --- classes/shop/Shop.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 4ca5cf8f4..2b1320c27 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -363,10 +363,12 @@ class ShopCore extends ObjectModel // Define some $_SERVER variables like HTTP_HOST if PHP is launched with php-cli if (Tools::isPHPCLI()) { - if(!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) + if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = $shop->domain; - if(!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME'])) + if (!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME'])) $_SERVER['SERVER_NAME'] = $shop->domain; + if (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR'])) + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; } } else From a37033e47867c512ab063cce97d7bee332fe9ad3 Mon Sep 17 00:00:00 2001 From: Prestaspirit Date: Thu, 12 Sep 2013 07:01:55 +0200 Subject: [PATCH 29/72] [-] MO : Fixed a bug when displaying textures Corrections links texture image in the blocklayered --- modules/blocklayered/blocklayered.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/blocklayered/blocklayered.tpl b/modules/blocklayered/blocklayered.tpl index f2102440a..f514f7231 100644 --- a/modules/blocklayered/blocklayered.tpl +++ b/modules/blocklayered/blocklayered.tpl @@ -94,7 +94,7 @@ param_product_url = ''; {if $value.nbr || !$hide_0_values}
  • {if isset($filter.is_color_group) && $filter.is_color_group} - + {if isset($value.checked) && $value.checked}{/if} {else} @@ -115,7 +115,7 @@ param_product_url = ''; {if $value.nbr || !$hide_0_values}
  • {if isset($filter.is_color_group) && $filter.is_color_group} - + {if isset($value.checked) && $value.checked}{/if} {else} From 90091d4f2c7d2ae53e2c934489843d1d17c35adb Mon Sep 17 00:00:00 2001 From: gRoussac Date: Thu, 12 Sep 2013 10:50:04 +0200 Subject: [PATCH 30/72] [-] BO : Do not copy link_rewrite from title if cms already has one --- controllers/admin/AdminCmsController.php | 4 ++-- js/admin.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/controllers/admin/AdminCmsController.php b/controllers/admin/AdminCmsController.php index c46c61b88..8d77909e4 100644 --- a/controllers/admin/AdminCmsController.php +++ b/controllers/admin/AdminCmsController.php @@ -110,10 +110,10 @@ class AdminCmsControllerCore extends AdminController 'type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', - 'id' => 'name', // for copy2friendlyUrl compatibility + 'id' => 'name', // for copyMeta2friendlyURL compatibility 'lang' => true, 'required' => true, - 'class' => 'copy2friendlyUrl', + 'class' => 'copyMeta2friendlyURL', 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'size' => 50 ), diff --git a/js/admin.js b/js/admin.js index 7904d724b..e4bee41e9 100644 --- a/js/admin.js +++ b/js/admin.js @@ -119,7 +119,8 @@ function copy2friendlyURL() function copyMeta2friendlyURL() { - $('#input_link_rewrite_' + id_language).val(str2url($('#name_' + id_language).val().replace(/^[0-9]+\./, ''), 'UTF-8')); + if (!$('input[name="id_cms"]').length) + $('#link_rewrite_' + id_language).val(str2url($('#name_' + id_language).val().replace(/^[0-9]+\./, ''), 'UTF-8')); } function updateCurrentText() From e5276ff5318475e4aeb0e872f6de266d0dd045b3 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Thu, 12 Sep 2013 11:16:12 +0200 Subject: [PATCH 31/72] [-] FO : 301 Redirect /iso_lang to /iso_lang/ url --- classes/Dispatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php index de874eb67..7bfaa54ca 100644 --- a/classes/Dispatcher.php +++ b/classes/Dispatcher.php @@ -369,7 +369,7 @@ class DispatcherCore // If there are several languages, get language from uri if ($this->use_routes && Language::isMultiLanguageActivated()) - if (preg_match('#^/([a-z]{2})/#', $this->request_uri, $m)) + if (preg_match('#^/([a-z]{2})/?#', $this->request_uri, $m)) { $_GET['isolang'] = $m[1]; $this->request_uri = substr($this->request_uri, 3); From 876be3b452880b2b9eeb5fac8c220a57df58b4de Mon Sep 17 00:00:00 2001 From: romainberger Date: Thu, 12 Sep 2013 14:07:45 +0200 Subject: [PATCH 32/72] [*] FO : removed extra slash and point --- themes/default/authentication.tpl | 14 +++++++------- themes/default/order-follow.tpl | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/default/authentication.tpl b/themes/default/authentication.tpl index 72551663b..a4371c698 100644 --- a/themes/default/authentication.tpl +++ b/themes/default/authentication.tpl @@ -36,7 +36,7 @@ var idSelectedCountry = {if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}false{/if}; var countries = new Array(); var countriesNeedIDNumber = new Array(); -var countriesNeedZipCode = new Array(); +var countriesNeedZipCode = new Array(); {if isset($countries)} {foreach from=$countries item='country'} {if isset($country.states) && $country.contains_states} @@ -75,7 +75,7 @@ $(document).ready(function() {

    {if !isset($email_create)}{l s='Authentication'}{else}{l s='Create an account'}{/if}

    -{if !isset($back) || $back != 'my-account'}{assign var='current_step' value='login'}{include file="$tpl_dir./order-steps.tpl"}{/if} +{if !isset($back) || $back != 'my-account'}{assign var='current_step' value='login'}{include file="$tpl_dir./order-steps.tpl"}{/if} {include file="$tpl_dir./errors.tpl"} {assign var='stateExist' value=false} {assign var="postCodeExist" value=false} @@ -126,7 +126,7 @@ $(document).ready(function() { $('#center_column').html('
    '+$('#center_column').html()+'
    '); $('#noSlide').fadeOut('slow', function(){ $('#noSlide').html(jsonData.page); - // update the state (when this file is called from AJAX you still need to update the state) + // update the state (when this file is called from AJAX you still need to update the state) bindStateInputAndUpdate(); $(this).fadeIn('slow', function(){ document.location = '#account-creation'; @@ -160,7 +160,7 @@ $(document).ready(function() {

    {l s='Create an account'}

    -

    {l s='Please enter your email address to create an account.'}.

    +

    {l s='Please enter your email address to create an account.'}

    @@ -339,7 +339,7 @@ $(document).ready(function() {

    - {/if} + {/if} @@ -551,7 +551,7 @@ $(document).ready(function() {

    - {/if} + {/if} {if $stateExist eq false} -{/if} \ No newline at end of file +{/if} diff --git a/themes/default/order-follow.tpl b/themes/default/order-follow.tpl index bf4d6a7d8..41abbb6f2 100644 --- a/themes/default/order-follow.tpl +++ b/themes/default/order-follow.tpl @@ -34,7 +34,7 @@

    {l s='Please provide an explanation for your RMA:'}

    -
    +

    From 53c1e56c5163622e3ad6acd6aa2e0344674abbdd Mon Sep 17 00:00:00 2001 From: Francois Gaillard Date: Thu, 12 Sep 2013 14:32:02 +0200 Subject: [PATCH 33/72] [-] BO : Bug fix - Encoding & tips of the day --- controllers/admin/AdminHomeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminHomeController.php b/controllers/admin/AdminHomeController.php index 96d37e035..45797273e 100644 --- a/controllers/admin/AdminHomeController.php +++ b/controllers/admin/AdminHomeController.php @@ -503,7 +503,7 @@ class AdminHomeControllerCore extends AdminController // 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); - $content = explode('|', utf8_encode($content)); + $content = explode('|', $content); if ($content[0] == 'OK' && Validate::isCleanHtml($content[1])) $result['discover_prestashop'] .= '
    '.$content[1].'
    '; From f9b1f0ab5e8791f70c683bf140e80e787c1572b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Thu, 12 Sep 2013 15:03:23 +0200 Subject: [PATCH 34/72] [*] Core: don't re-generate the class_index.php file if a class is not known to avoid misuse of class_exists() --- .../template/controllers/performance/helpers/form/form.tpl | 2 +- classes/Autoload.php | 3 +-- controllers/admin/AdminPerformanceController.php | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/performance/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/performance/helpers/form/form.tpl index 5e9db0548..efb117fa9 100644 --- a/admin-dev/themes/default/template/controllers/performance/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/performance/helpers/form/form.tpl @@ -41,7 +41,7 @@ {/if} {$smarty.block.parent} {if $input.type == 'radio' && $input.name == 'smarty_cache'} - {l s='Clear Smarty cache'} + {l s='Clear Smarty cache & Autoload cache'} {/if} {/block} diff --git a/classes/Autoload.php b/classes/Autoload.php index 91864a22d..a07c7f068 100644 --- a/classes/Autoload.php +++ b/classes/Autoload.php @@ -81,8 +81,7 @@ class Autoload return; // regenerate the class index if the requested class is not found in the index or if the requested file doesn't exists - if (!isset($this->index[$classname]) - || ($this->index[$classname] && !is_file($this->root_dir.$this->index[$classname])) + if ((isset($this->index[$classname]) && $this->index[$classname] && !is_file($this->root_dir.$this->index[$classname])) || (isset($this->index[$classname.'Core']) && $this->index[$classname.'Core'] && !is_file($this->root_dir.$this->index[$classname.'Core']))) $this->generateIndex(); diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 798e1912d..acfbe4d20 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -796,6 +796,7 @@ class AdminPerformanceControllerCore extends AdminController { $redirectAdmin = true; Tools::clearSmartyCache(); + Autoload::getInstance()->generateIndex(); } if ($redirectAdmin && (!isset($this->errors) || !count($this->errors))) From 30591b7c28e2850b7634df3a832ffd3fc249b0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Thu, 12 Sep 2013 15:04:47 +0200 Subject: [PATCH 35/72] // Typo --- classes/Autoload.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Autoload.php b/classes/Autoload.php index a07c7f068..7f20b0cf9 100644 --- a/classes/Autoload.php +++ b/classes/Autoload.php @@ -80,7 +80,7 @@ class Autoload if (strpos(strtolower($classname), 'smarty_') === 0) return; - // regenerate the class index if the requested class is not found in the index or if the requested file doesn't exists + // regenerate the class index if the requested file doesn't exists if ((isset($this->index[$classname]) && $this->index[$classname] && !is_file($this->root_dir.$this->index[$classname])) || (isset($this->index[$classname.'Core']) && $this->index[$classname.'Core'] && !is_file($this->root_dir.$this->index[$classname.'Core']))) $this->generateIndex(); @@ -186,4 +186,4 @@ class Autoload { return isset($this->index[$classname]) ? $this->index[$classname] : null; } -} \ No newline at end of file +} From 5095b45e47dd0785a00d216624879b02f42a5fe4 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Thu, 12 Sep 2013 15:09:21 +0200 Subject: [PATCH 36/72] [-] BO : Fix bug, orders states not ordered by order state name --- classes/controller/AdminController.php | 7 +++++-- controllers/admin/AdminOrdersController.php | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 82465abf0..94bc96d7d 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2159,8 +2159,11 @@ class AdminControllerCore extends Controller || !Validate::isUnsignedId($id_lang)) throw new PrestaShopException('get list params is not valid'); - if (isset($this->fields_list[$order_by]) && isset($this->fields_list[$order_by]['filter_key'])) - $order_by = $this->fields_list[$order_by]['filter_key']; + if (!isset($this->fields_list[$order_by]['order_key']) && isset($this->fields_list[$order_by]['filter_key'])) + $this->fields_list[$order_by]['order_key'] = $this->fields_list[$order_by]['filter_key']; + + if (isset($this->fields_list[$order_by]) && isset($this->fields_list[$order_by]['order_key'])) + $order_by = $this->fields_list[$order_by]['order_key']; /* Determine offset from current page */ if ((isset($_POST['submitFilter'.$this->list_id]) || diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 3ca37b935..23bd95520 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -110,7 +110,8 @@ class AdminOrdersControllerCore extends AdminController 'type' => 'select', 'list' => $statuses_array, 'filter_key' => 'os!id_order_state', - 'filter_type' => 'int' + 'filter_type' => 'int', + 'order_key' => 'osname' ), 'date_add' => array( 'title' => $this->l('Date'), From db4b69d10c20e6fe6bbdfe5f08556cb57eeb2415 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Thu, 12 Sep 2013 18:03:30 +0200 Subject: [PATCH 37/72] [-] BO : Customer message twice encoded --- controllers/admin/AdminCustomerThreadsController.php | 2 +- controllers/front/ContactController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index 3714a0a17..4e7c97c25 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -380,7 +380,7 @@ class AdminCustomerThreadsControllerCore extends AdminController $cm->id_employee = (int)$this->context->employee->id; $cm->id_customer_thread = $ct->id; - $cm->message = Tools::htmlentitiesutf8(Tools::getValue('reply_message')); + $cm->message = Tools::getValue('reply_message'); $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); if (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0) $this->errors[] = Tools::displayError('An error occurred during the file upload process.'); diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index 01941bf4d..8d3e5689e 100644 --- a/controllers/front/ContactController.php +++ b/controllers/front/ContactController.php @@ -144,7 +144,7 @@ class ContactControllerCore extends FrontController { $cm = new CustomerMessage(); $cm->id_customer_thread = $ct->id; - $cm->message = Tools::htmlentitiesUTF8($message); + $cm->message = $message; if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename']))) $cm->file_name = $fileAttachment['rename']; $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); From 452f41df8da32c87e0170ae033168a694b5032f0 Mon Sep 17 00:00:00 2001 From: zimmi1 Date: Fri, 13 Sep 2013 10:05:30 +0200 Subject: [PATCH 38/72] Speeding up sql queries Searching for "DATE_ADD(date_add, INTERVAL 30 MINUTE) > now" needs for every line to add 30 minutes to the date. but it is the same operation as comparing "date_add > (now - 30 minutes). It is faster because there is no DATE_ADD calculation. The problem: By profiling speed of my shop, this query appeared after about 3 months always as the absolute slowest query of the shop, needing about 15 to 30 ms to perform, because I have now nearly 700 connections to my shop (and it then browses the 700 lines) A solution: Removing DATE_ADD MySql function and using date() and time() functions of php for calculating only once the 30 min. difference. Using this solution takes it down again to 0.8 to 1.3 ms. I guess it is the same in case of bots (could be even worse as they can make thousands of connections). --- classes/Connection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Connection.php b/classes/Connection.php index 23514695b..206bd307b 100644 --- a/classes/Connection.php +++ b/classes/Connection.php @@ -114,7 +114,7 @@ class ConnectionCore extends ObjectModel // This is a bot and we have to retrieve its connection ID $sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections` WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).' - AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\' + AND `date_add` > \''.pSQL(date('Y-m-d H:i:00'), time() - 1800).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' ORDER BY `date_add` DESC'; if ($id_connections = Db::getInstance()->getValue($sql)) @@ -128,7 +128,7 @@ class ConnectionCore extends ObjectModel $sql = 'SELECT `id_guest` FROM `'._DB_PREFIX_.'connections` WHERE `id_guest` = '.(int)$cookie->id_guest.' - AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\' + AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' ORDER BY `date_add` DESC'; $result = Db::getInstance()->getRow($sql); From 3eb4d65fc923daccf7173c088a6a9d6c024877e3 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Fri, 13 Sep 2013 10:26:08 +0200 Subject: [PATCH 39/72] [-] BO : Fix Bug #PSCFV-10331 check all from list --- controllers/admin/AdminTaxRulesGroupController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin/AdminTaxRulesGroupController.php b/controllers/admin/AdminTaxRulesGroupController.php index c36597348..21045acfb 100644 --- a/controllers/admin/AdminTaxRulesGroupController.php +++ b/controllers/admin/AdminTaxRulesGroupController.php @@ -78,6 +78,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController public function initRulesList($id_group) { $this->table = 'tax_rule'; + $this->list_id = 'tax_rule'; $this->identifier = 'id_tax_rule'; $this->className = 'TaxRule'; $this->lang = false; From d9bc07d03053916f1ff4a74815bc0f58480ef0fc Mon Sep 17 00:00:00 2001 From: gRoussac Date: Fri, 13 Sep 2013 10:45:07 +0200 Subject: [PATCH 40/72] [-] BO : quote badly decoded in customerThreads --- controllers/admin/AdminCustomerThreadsController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index 4e7c97c25..c53945a5b 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -597,11 +597,12 @@ class AdminCustomerThreadsControllerCore extends AdminController } $message['date_add'] = Tools::displayDate($message['date_add'], null, true); $message['user_agent'] = strip_tags($message['user_agent']); + $message['message'] = preg_replace( '/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', '\1\2', html_entity_decode($message['message'], - ENT_NOQUOTES, 'UTF-8') + ENT_QUOTES, 'UTF-8') ); $tpl->assign(array( From 4f06b74a29e6bc49a700d59803399f4f18dccab0 Mon Sep 17 00:00:00 2001 From: zimmi1 Date: Fri, 13 Sep 2013 11:56:50 +0200 Subject: [PATCH 41/72] Update Connection.php correction from 717 I'm very very sorry, I produced an error with the last commit on this file: there was an error in parenthesis position on line 117. Line 117 should be as line 131. (But how did I manage to make this wrong ???) --- classes/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Connection.php b/classes/Connection.php index 206bd307b..7375841c9 100644 --- a/classes/Connection.php +++ b/classes/Connection.php @@ -114,7 +114,7 @@ class ConnectionCore extends ObjectModel // This is a bot and we have to retrieve its connection ID $sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections` WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).' - AND `date_add` > \''.pSQL(date('Y-m-d H:i:00'), time() - 1800).'\' + AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' ORDER BY `date_add` DESC'; if ($id_connections = Db::getInstance()->getValue($sql)) From 5363e75238f955005a76c68ae98045e6cf3a5548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Fri, 13 Sep 2013 12:13:12 +0200 Subject: [PATCH 42/72] // small fix --- classes/Autoload.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/Autoload.php b/classes/Autoload.php index 7f20b0cf9..bd1a6715c 100644 --- a/classes/Autoload.php +++ b/classes/Autoload.php @@ -54,6 +54,8 @@ class Autoload $this->root_dir = dirname(dirname(__FILE__)).'/'; if (file_exists($this->root_dir.Autoload::INDEX_FILE)) $this->index = include($this->root_dir.Autoload::INDEX_FILE); + else + $this->generateIndex(); } /** From 97ec6341e858d7b3b5d3938aa59ac9dfdd558ab3 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Fri, 13 Sep 2013 15:39:30 +0200 Subject: [PATCH 43/72] [-] BO ; Fix bug #PSCFV-10393 manufacturer filter --- controllers/admin/AdminManufacturersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminManufacturersController.php b/controllers/admin/AdminManufacturersController.php index ebdb2ad1d..4d26c7627 100644 --- a/controllers/admin/AdminManufacturersController.php +++ b/controllers/admin/AdminManufacturersController.php @@ -140,7 +140,7 @@ class AdminManufacturersControllerCore extends AdminController 'lastname' => array( 'title' => $this->l('Last name'), 'width' => 100, - 'filter_key' => 'a!name' + 'filter_key' => 'a!lastname' ), 'postcode' => array( 'title' => $this->l('Zip Code/Postal Code'), From d0ef8cca8f66a8a1e57a5eda89ce146c6b75ce52 Mon Sep 17 00:00:00 2001 From: makk1ntosh Date: Fri, 13 Sep 2013 08:02:47 -0700 Subject: [PATCH 44/72] Added ui.button as dependency of ui.dialog While developing my own module, i've upgraded installation to latest version of PS and impacted a bug: $('#something').dialog({...}); caused an error: t().button is not a function. In my php code i had this: $this->context->controller->addJqueryUI('ui.dialog'); i found that it doesn't load ui.button dependency. Added 'ui.button' to classes/Media.php at the end of ui.dialog dependencies and all worked fine. --- classes/Media.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Media.php b/classes/Media.php index 86b51e5ff..7ce172f56 100755 --- a/classes/Media.php +++ b/classes/Media.php @@ -39,7 +39,7 @@ class MediaCore 'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.autocomplete' => array('fileName' => 'jquery.ui.autocomplete.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true), 'ui.button' => array('fileName' => 'jquery.ui.button.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), - 'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true), + 'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position','ui.button'), 'theme' => true), 'ui.slider' => array('fileName' => 'jquery.ui.slider.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), 'ui.tabs' => array('fileName' => 'jquery.ui.tabs.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.datepicker' => array('fileName' => 'jquery.ui.datepicker.min.js', 'dependencies' => array('ui.core'), 'theme' => true), From 6da1228359a52291bdc31ce428566c7380ff0310 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Fri, 13 Sep 2013 17:56:45 +0200 Subject: [PATCH 45/72] [-] BO : Fix bug #PSCFV-8407 can not customize feature column name if needed --- js/admin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin.js b/js/admin.js index e4bee41e9..f3d81d410 100644 --- a/js/admin.js +++ b/js/admin.js @@ -481,7 +481,7 @@ function askFeatureName(selected, selector) { var elem; - if (selected.value == 'feature') + if (selected.value == 'features') { $('#features_' + selector).show(); $('#feature_name_' + selector).attr('name', selected.name); From 73dd524de8e0f7a78ae2690f2ada894809404c70 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Sat, 14 Sep 2013 00:05:45 +0200 Subject: [PATCH 46/72] [-] BO : Could not order in AdminStatuses by ID or template --- controllers/admin/AdminStatusesController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin/AdminStatusesController.php b/controllers/admin/AdminStatusesController.php index b046fe3ea..fe4e129e0 100644 --- a/controllers/admin/AdminStatusesController.php +++ b/controllers/admin/AdminStatusesController.php @@ -136,6 +136,7 @@ class AdminStatusesControllerCore extends AdminController { $this->table = 'order_return_state'; $this->_defaultOrderBy = $this->identifier = 'id_order_return_state'; + $this->list_id = 'order_return_state'; $this->deleted = false; $this->_orderBy = null; From 08373c05419a1c2cbd35421223266be4fc4a38e8 Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 14 Sep 2013 14:57:00 +0200 Subject: [PATCH 47/72] [+] Modules : add hookHome --- modules/blocknewproducts/blocknewproducts.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/blocknewproducts/blocknewproducts.php b/modules/blocknewproducts/blocknewproducts.php index ae04a77ee..f6b23a22d 100644 --- a/modules/blocknewproducts/blocknewproducts.php +++ b/modules/blocknewproducts/blocknewproducts.php @@ -134,6 +134,11 @@ class BlockNewProducts extends Module { return $this->hookRightColumn($params); } + + public function hookHome($params) + { + return $this->hookRightColumn($params); + } public function hookHeader($params) { From c0afb55d11d2f47d50bb9fc409c354be501923dd Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Mon, 16 Sep 2013 09:25:10 +0200 Subject: [PATCH 48/72] [-] BO : FixBug #PSCFV-9900 Double quote escape problem in delete button link --- classes/helper/HelperList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index 69a6127c2..0e979f28c 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -456,7 +456,7 @@ class HelperListCore extends Helper ); if ($this->specificConfirmDelete !== false) - $data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : addcslashes(Tools::htmlentitiesDecodeUTF8(self::$cache_lang['DeleteItem'].$name), '\''); + $data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : Tools::safeOutput(addcslashes(self::$cache_lang['DeleteItem'].$name, '\'')); $tpl->assign(array_merge($this->tpl_delete_link_vars, $data)); From 0e3d53321aff6cc16ea9c49e541a31c9fde6713f Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 16 Sep 2013 09:37:39 +0200 Subject: [PATCH 49/72] [-] BO : limited the number of customers displayed in the group view to 100 in order to avoid memory usage error --- .../default/template/controllers/groups/helpers/view/view.tpl | 1 + controllers/admin/AdminGroupsController.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl index eceafdb0c..e2503c9a6 100755 --- a/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl @@ -58,6 +58,7 @@

    {l s='Members of this customer group'}

    +

    {l s='Limited to the 100th first customers.'} {l s='Please use filters to narrow your search.'}

    {$customerList} {/block} \ No newline at end of file diff --git a/controllers/admin/AdminGroupsController.php b/controllers/admin/AdminGroupsController.php index 3c8f26a79..007bd38b0 100644 --- a/controllers/admin/AdminGroupsController.php +++ b/controllers/admin/AdminGroupsController.php @@ -193,7 +193,7 @@ class AdminGroupsControllerCore extends AdminController 'active' => array('title' => $this->l('Enabled'),'align' => 'center','width' => 20, 'active' => 'status','type' => 'bool') )); - $customer_list = $group->getCustomers(false, 0, 0, true); + $customer_list = $group->getCustomers(false, 0, 100, true); $helper = new HelperList(); $helper->currentIndex = Context::getContext()->link->getAdminLink('AdminCustomers', false); From 08efa4e3139aa8afa6a854dcfba1d8def2fdc534 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 16 Sep 2013 11:12:55 +0200 Subject: [PATCH 50/72] [-] IN : Fix bug #PSCFV-10382 add_module_to_hook retunrning false when hook not exists --- install-dev/upgrade/php/add_module_to_hook.php | 15 +++++++++------ install-dev/upgrade/sql/1.5.6.0.sql | 14 +++++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/install-dev/upgrade/php/add_module_to_hook.php b/install-dev/upgrade/php/add_module_to_hook.php index c44e4eabd..fabd39cfa 100644 --- a/install-dev/upgrade/php/add_module_to_hook.php +++ b/install-dev/upgrade/php/add_module_to_hook.php @@ -35,9 +35,14 @@ function add_module_to_hook($module_name, $hook_name) if ((int)$id_module > 0) { - $id_hook = Db::getInstance()->getValue(' - SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = "'.$hook_name.'" - '); + $id_hook = Db::getInstance()->getValue('SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = "'.$hook_name.'"'); + if(!$id_hook) + { + $res &= Db::getInstance()->execute(' + INSERT IGNORE INTO `'._DB_PREFIX_.'hook` (`name`, `title`) + VALUES ("'.pSQL($hook_name).'", "'.pSQL($hook_name).'")'); + $id_hook = Db::getInstance()->Insert_ID(); + } if ((int)$id_hook > 0) { @@ -51,7 +56,5 @@ function add_module_to_hook($module_name, $hook_name) )'); } } - return $res; -} - +} \ No newline at end of file diff --git a/install-dev/upgrade/sql/1.5.6.0.sql b/install-dev/upgrade/sql/1.5.6.0.sql index 5f5521cff..08f15d8c4 100644 --- a/install-dev/upgrade/sql/1.5.6.0.sql +++ b/install-dev/upgrade/sql/1.5.6.0.sql @@ -1 +1,13 @@ -ALTER TABLE `PREFIX_manufacturer_lang` CHANGE `short_description` `short_description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; \ No newline at end of file +ALTER TABLE `PREFIX_manufacturer_lang` CHANGE `short_description` `short_description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; + +/* PHP:add_module_to_hook(blockcart, actionCartListOverride); */; +/* PHP:add_module_to_hook(blockmanufacturer, actionObjectManufacturerDeleteAfter); */; +/* PHP:add_module_to_hook(blockmanufacturer, actionObjectManufacturerAddAfter); */; +/* PHP:add_module_to_hook(blockmanufacturer, actionObjectManufacturerUpdateAfter); */; +/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierDeleteAfter); */; +/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierAddAfter); */; +/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierUpdateAfter); */; +/* PHP:add_module_to_hook(blockmyaccount, actionModuleRegisterHookAfter); */; +/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */; +/* PHP:add_module_to_hook(blockmyaccount, actionModuleUnRegisterHookAfter); */; +/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleUnRegisterHookAfter); */; \ No newline at end of file From e68c124218863034db1dbdb93d58ffbf5de46a17 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 16 Sep 2013 11:40:29 +0200 Subject: [PATCH 51/72] [-] FO : replace ucfirst by ucwords for the customer firstname #PSCFV-10396 --- classes/Tools.php | 7 +++++++ controllers/front/AuthController.php | 1 + controllers/front/IdentityController.php | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/Tools.php b/classes/Tools.php index 31adb3bbf..bc0721a84 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1260,6 +1260,13 @@ class ToolsCore return Tools::strtoupper(Tools::substr($str, 0, 1)).Tools::substr($str, 1); } + public static function ucwords($str) + { + if (function_exists('mb_convert_case')) + return mb_convert_case($str, MB_CASE_TITLE); + return ucwords(strtolower($str)); + } + public static function orderbyPrice(&$array, $order_way) { foreach ($array as &$row) diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 79b09cce6..505630aaa 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -425,6 +425,7 @@ class AuthControllerCore extends FrontController if (Tools::isSubmit('newsletter')) $this->processCustomerNewsletter($customer); + $customer->firstname = Tools::ucwords($customer->firstname); $customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']); if (!Validate::isBirthDate($customer->birthday)) $this->errors[] = Tools::displayError('Invalid date of birth.'); diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php index 7f0eb50b4..109cf3bc8 100644 --- a/controllers/front/IdentityController.php +++ b/controllers/front/IdentityController.php @@ -79,7 +79,7 @@ class IdentityControllerCore extends FrontController if (!count($this->errors)) { $this->customer->id_default_group = (int)$prev_id_default_group; - $this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname)); + $this->customer->firstname = Tools::ucwords($this->customer->firstname); if (!isset($_POST['newsletter'])) $this->customer->newsletter = 0; From 8504574ae12b5ac75e79a662173a5297e81faa85 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 16 Sep 2013 15:02:12 +0200 Subject: [PATCH 52/72] [-] IN : Could not remove some tabs --- install-dev/upgrade/php/remove_tab.php | 2 +- install-dev/upgrade/sql/1.5.6.0.sql | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/install-dev/upgrade/php/remove_tab.php b/install-dev/upgrade/php/remove_tab.php index 2a0c53902..9ade12ee5 100644 --- a/install-dev/upgrade/php/remove_tab.php +++ b/install-dev/upgrade/php/remove_tab.php @@ -29,6 +29,6 @@ function remove_tab($tabname) Db::getInstance()->execute(' DELETE t, l FROM `'._DB_PREFIX_.'tab` t LEFT JOIN `'._DB_PREFIX_.'tab_lang` l ON (t.id_tab = l.id_tab) - WHERE t.`class_name` = '.pSQL($tabname)); + WHERE t.`class_name` = "'.pSQL($tabname).'"'); } diff --git a/install-dev/upgrade/sql/1.5.6.0.sql b/install-dev/upgrade/sql/1.5.6.0.sql index 08f15d8c4..3b03e96ed 100644 --- a/install-dev/upgrade/sql/1.5.6.0.sql +++ b/install-dev/upgrade/sql/1.5.6.0.sql @@ -10,4 +10,6 @@ ALTER TABLE `PREFIX_manufacturer_lang` CHANGE `short_description` `short_descrip /* PHP:add_module_to_hook(blockmyaccount, actionModuleRegisterHookAfter); */; /* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */; /* PHP:add_module_to_hook(blockmyaccount, actionModuleUnRegisterHookAfter); */; -/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleUnRegisterHookAfter); */; \ No newline at end of file +/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleUnRegisterHookAfter); */; +/* PHP:remove_tab(AdminRangePrice); */; +/* PHP:remove_tab(AdminRangeWeight); */; \ No newline at end of file From 852faeab7a5b60369dbddf3038d93cb43172dc25 Mon Sep 17 00:00:00 2001 From: CINS Date: Mon, 16 Sep 2013 15:57:44 +0200 Subject: [PATCH 53/72] Update admin.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lorsqu'un produit possède trop d'images, il est impossible de réordonner celle-ci car la valeur JSON fourni en URL (GET) est beaucoup trop longue. Il faut envoyer les données JSON en POST pour solutionner le problème de longueur. --------- When a product has many pictures, we can't reorder them. The JSON value is too long in URL (GET). We need to send data with POST to avoid problem. --- js/admin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/admin.js b/js/admin.js index f3d81d410..f0d210359 100644 --- a/js/admin.js +++ b/js/admin.js @@ -751,6 +751,7 @@ function doAdminAjax(data, success_func, error_func) { url : 'index.php', data : data, + type : 'POST', success : function(data){ if (success_func) return success_func(data); From 15dd1cf96f0874a28347175e3d3a23fc0f284435 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 16 Sep 2013 17:16:11 +0200 Subject: [PATCH 54/72] [-] BO : Fix bugPSCFV-10249 images copy when unix path --- classes/Tools.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/classes/Tools.php b/classes/Tools.php index bc0721a84..6e2a4030a 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1412,7 +1412,12 @@ class ToolsCore $stream_context = @stream_context_create(array('http' => array('timeout' => 10))); if (in_array(@ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $source)) - return @copy($source, $destination, $stream_context); + { + if (!is_null($stream_context)) + return @copy($source, $destination, $stream_context); + else + return @copy($source, $destination); + } elseif (function_exists('curl_init')) { $curl = curl_init(); From 2d5bd901f4ef47b34795dce6fafb08a7c821bd27 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 16 Sep 2013 18:51:06 +0200 Subject: [PATCH 55/72] [*] CORE : Refactoring Tools::copy() as copy with context > PHP 5.3 --- classes/Tools.php | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 6e2a4030a..38aee11b6 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1408,31 +1408,9 @@ class ToolsCore public static function copy($source, $destination, $stream_context = null) { - if ($stream_context == null && preg_match('/^https?:\/\//', $source)) - $stream_context = @stream_context_create(array('http' => array('timeout' => 10))); - - if (in_array(@ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $source)) - { - if (!is_null($stream_context)) - return @copy($source, $destination, $stream_context); - else - return @copy($source, $destination); - } - elseif (function_exists('curl_init')) - { - $curl = curl_init(); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_URL, $source); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); - curl_setopt($curl, CURLOPT_TIMEOUT, 10); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - $opts = stream_context_get_options($stream_context); - $content = curl_exec($curl); - curl_close($curl); - return file_put_contents($destination, $content); - } - else - return false; + if (is_null($stream_context) && !preg_match('/^https?:\/\//', $source)) + return @copy($source, $destination); + return @file_put_contents($destination, Tools::file_get_contents($source, false, $stream_context)); } /** From 6ee6317feef9cf8f2c7689149b8d9666e823b126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 17 Sep 2013 11:07:29 +0200 Subject: [PATCH 56/72] // orderby position --- classes/helper/HelperList.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index 0e979f28c..eeb161535 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -136,6 +136,9 @@ class HelperListCore extends Helper $this->_list = $list; $this->fields_list = $fields_display; + $this->orderBy = preg_replace('/^([a-z _]*!)/Ui', '', $this->orderBy); + $this->orderWay = preg_replace('/^([a-z _]*!)/Ui', '', $this->orderWay); + // Display list header (filtering, pagination and column names) $tpl_vars['header'] = $this->displayListHeader(); @@ -522,9 +525,6 @@ class HelperListCore extends Helper isset($this->context->cookie->{$this->list_id.'_pagination'}) ? $this->context->cookie->{$this->list_id.'_pagination'} : null ); - // Cleaning links - if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway')) - $this->currentIndex = preg_replace('/&'.$this->table.'Orderby=([a-z _]*)&'.$this->table.'Orderway=([a-z]*)/i', '', $this->currentIndex); if ($this->position_identifier && (int)Tools::getValue($this->position_identifier, 1)) $table_id = substr($this->identifier, 3, strlen($this->identifier)); From e6e8efc19ab354147c7bf33db25a23a53e4ddacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 17 Sep 2013 11:58:12 +0200 Subject: [PATCH 57/72] [-] FO: Fix Product::getAttributesGroups() minimal_quantity/weight/available_date should be multishop --- classes/Product.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/classes/Product.php b/classes/Product.php index 188ce4a05..19e5917af 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3055,18 +3055,18 @@ class ProductCore extends ObjectModel if (!Combination::isFeatureActive()) return array(); $sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, - a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pa.`id_product_attribute`, - IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, pa.`weight`, + a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, product_attribute_shop.`id_product_attribute`, + IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, product_attribute_shop.`weight`, product_attribute_shop.`default_on`, pa.`reference`, product_attribute_shop.`unit_price_impact`, - pa.`minimal_quantity`, pa.`available_date`, ag.`group_type` + product_attribute_shop.`minimal_quantity`, product_attribute_shop.`available_date`, ag.`group_type` FROM `'._DB_PREFIX_.'product_attribute` pa '.Shop::addSqlAssociation('product_attribute', 'pa').' '.Product::sqlStock('pa', 'pa').' - LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` - LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` - LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` - LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute` - LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group` + LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`) + LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) + LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`) + LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute`) + LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group`) '.Shop::addSqlAssociation('attribute', 'a').' WHERE pa.`id_product` = '.(int)$this->id.' AND al.`id_lang` = '.(int)$id_lang.' From 3151064daf2980bb70cf6d3c934ff2f3bc73b18f Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Tue, 17 Sep 2013 12:18:37 +0200 Subject: [PATCH 58/72] //small fix on helper form && option --- admin-dev/themes/default/template/helpers/form/form.tpl | 2 +- admin-dev/themes/default/template/helpers/options/options.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin-dev/themes/default/template/helpers/form/form.tpl b/admin-dev/themes/default/template/helpers/form/form.tpl index ee9ee638a..ed77b5c40 100644 --- a/admin-dev/themes/default/template/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/helpers/form/form.tpl @@ -30,7 +30,7 @@ {if isset($fields.title)}

    {$fields.title}

    {/if} {block name="defaultForm"} - + {if $form_id} {/if} diff --git a/admin-dev/themes/default/template/helpers/options/options.tpl b/admin-dev/themes/default/template/helpers/options/options.tpl index ea9bb26c2..3c1309690 100644 --- a/admin-dev/themes/default/template/helpers/options/options.tpl +++ b/admin-dev/themes/default/template/helpers/options/options.tpl @@ -34,7 +34,7 @@ {block name="defaultOptions"} Date: Tue, 17 Sep 2013 14:54:38 +0200 Subject: [PATCH 59/72] //small fix with mode catalog and cart button --- themes/default/product.tpl | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/themes/default/product.tpl b/themes/default/product.tpl index 97f5bbb08..dfd32a4ae 100644 --- a/themes/default/product.tpl +++ b/themes/default/product.tpl @@ -433,17 +433,10 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving {/if} {*close if for show price*} {/if} - {if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE} - - - {l s='Add to cart'} - - {else} -

    - - -

    - {/if} +

    quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE}style="display:none"{/if} class="buttons_bottom_block"> + + +

    {if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if}
    From 47c5f400eecb12c9828a4ae619ec246c5e9dcedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 17 Sep 2013 16:30:47 +0200 Subject: [PATCH 60/72] // Add gender on order view --- .../default/template/controllers/orders/helpers/view/view.tpl | 2 +- controllers/admin/AdminOrdersController.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl index ef8cc81c5..af01d0657 100755 --- a/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -153,7 +153,7 @@
    {l s='Customer information'} - {$customer->firstname} {$customer->lastname} ({l s='#'}{$customer->id})
    + {$gender->name|escape:'htmlall':'UTF-8'} {$customer->firstname} {$customer->lastname} ({l s='#'}{$customer->id})
    ({$customer->email})

    {if ($customer->isGuest())} {l s='This order has been placed by a guest.'} diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 23bd95520..66f3ad249 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1342,11 +1342,14 @@ class AdminOrdersControllerCore extends AdminController $product['warehouse_name'] = '--'; } + $gender = new Gender((int)$customer->id_gender, $this->context->language->id); + // Smarty assign $this->tpl_view_vars = array( 'order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, + 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array( 'delivery' => $addressDelivery, From 965b8a1bf3eaff0146e00c013542aa1edbaeb9aa Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Wed, 18 Sep 2013 11:18:26 +0200 Subject: [PATCH 61/72] [-] BO - fixed bug #PSCFV-10286 - End range in summary of shipping wizard not correct when range number is a float --- js/admin_carrier_wizard.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/admin_carrier_wizard.js b/js/admin_carrier_wizard.js index 1bb403720..d62dc9e82 100644 --- a/js/admin_carrier_wizard.js +++ b/js/admin_carrier_wizard.js @@ -153,12 +153,13 @@ function displaySummary() $('tr.range_inf td input').each( function() { - if (!isNaN(parseFloat($(this).val())) && (range_inf == summary_translation_undefined || range_inf > $(this).val())) + if (!isNaN(parseFloat($(this).val())) && (range_inf == summary_translation_undefined || parseFloat(range_inf) > parseFloat($(this).val()))) range_inf = $(this).val(); }); $('tr.range_sup td input').each( function(){ - if (!isNaN(parseFloat($(this).val())) && (range_sup == summary_translation_undefined || range_sup < $(this).val())) + + if (!isNaN(parseFloat($(this).val())) && (range_sup == summary_translation_undefined || parseFloat(range_sup) < parseFloat($(this).val()))) range_sup = $(this).val(); }); From 672da852c55c5f4bf4982b8cef03bc3ef67e4239 Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Wed, 18 Sep 2013 11:40:58 +0200 Subject: [PATCH 62/72] [-] BO - fixed bug #PSCFV-10178 --- js/admin_carrier_wizard.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/admin_carrier_wizard.js b/js/admin_carrier_wizard.js index d62dc9e82..d2bb9f401 100644 --- a/js/admin_carrier_wizard.js +++ b/js/admin_carrier_wizard.js @@ -273,7 +273,6 @@ function bind_inputs() }); $('tr.fees td input:checkbox').off('change').on('change', function () { - if($(this).is(':checked')) { $(this).closest('tr').children('td').each( function () { @@ -390,7 +389,7 @@ function hideFees() function showFees() { $('tr.range_inf td, tr.range_sup td, tr.fees_all td, tr.fees td').each( function () { - if ($(this).index() >= 2) + if ($(this).index() > 2) { //enable only if zone is active tr = $(this).parent('tr'); From 66f46eee032247274297ee5c57df1e55ffd450e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 18 Sep 2013 14:29:01 +0200 Subject: [PATCH 63/72] // Avoid exception if amount is null on addind an orderpayment --- 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 66f3ad249..d15fd1323 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -805,7 +805,7 @@ class AdminOrdersControllerCore extends AdminController if (!Validate::isLoadedObject($order)) $this->errors[] = Tools::displayError('The order cannot be found'); - elseif (!Validate::isNegativePrice($amount)) + elseif (!Validate::isNegativePrice($amount) || !(float)$amount) $this->errors[] = Tools::displayError('The amount is invalid.'); elseif (!Validate::isString(Tools::getValue('payment_method'))) $this->errors[] = Tools::displayError('The selected payment method is invalid.'); From f293562ea4c878edec40d66786e79fc9e8b36aeb Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 18 Sep 2013 15:03:16 +0200 Subject: [PATCH 64/72] [-] BO : Fix bug #PSCFV-8214 import entity pre selected --- .../controllers/import/helpers/form/form.tpl | 3 +-- admin-dev/themes/default/template/toolbar.tpl | 2 +- controllers/admin/AdminAddressesController.php | 2 +- .../admin/AdminCategoriesController.php | 2 +- controllers/admin/AdminCustomersController.php | 2 +- controllers/admin/AdminImportController.php | 7 +++++-- .../admin/AdminManufacturersController.php | 2 +- controllers/admin/AdminProductsController.php | 2 +- controllers/admin/AdminSuppliersController.php | 18 ++++++++++++++++++ 9 files changed, 30 insertions(+), 10 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl index 059ccfdd2..c1949da21 100644 --- a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl @@ -112,7 +112,6 @@
    {l s='Import '} -
    {if count($files_to_import)} @@ -146,7 +145,7 @@
  • {if $has_bulk_actions} - + {/if}
    '+this.name+''+this.description+''+this.value_real+'