From 87567ed1a05ad5a348b432d9a01ad04f627074ad Mon Sep 17 00:00:00 2001 From: djfm Date: Wed, 4 Sep 2013 07:44:52 +0000 Subject: [PATCH 01/10] // fixed translation of modules descriptions containing quotes --- classes/module/Module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/module/Module.php b/classes/module/Module.php index f6b2fd8fd..2e911e26d 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -935,7 +935,7 @@ abstract class ModuleCore public static function configXmlStringFormat($string) { - return str_replace('\'', '\\\'', Tools::htmlentitiesDecodeUTF8($string)); + return Tools::htmlentitiesDecodeUTF8($string); } From 641cf225f2cfbf2eecea6d74db1327017b322efd Mon Sep 17 00:00:00 2001 From: djfm Date: Mon, 9 Sep 2013 09:47:44 +0000 Subject: [PATCH 02/10] // fix small translation bug PSCFV-10329 --- .../template/controllers/referrers/helpers/form/form.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin-dev/themes/default/template/controllers/referrers/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/referrers/helpers/form/form.tpl index fa1244e65..01c588730 100644 --- a/admin-dev/themes/default/template/controllers/referrers/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/referrers/helpers/form/form.tpl @@ -45,7 +45,7 @@ {l s='The field `request_uri` is the URL from which the customers come to your website.'}
{l s='For example, if the visitor accesses a product page, the URL will be'} "{$uri}music-ipods/1-ipod-nano.html".
{l s='This is helpful because you can add tags or tokens in the links pointing to your website.'} - {l s='For example, you can post a link "%dindex.php?prestashop" in the forum and get statistics by entering "%prestashop" in the field `request_uri`. '} + {l s='For example, you can post a link "%1$sindex.php?prestashop" in the forum and get statistics by entering "%%prestashop" in the field `request_uri`. ' sprintf=[$uri]} {l s='This method is more reliable than the `http_referer`, but there is one disadvantage. If a search engine references a page with your link, then it will be displayed in the search results and you will not only have visitors from the forum, but also those from the search engine.'}
From 65559c5cf401fab42d742e9c5e7f2b025e03e5dd Mon Sep 17 00:00:00 2001 From: djfm Date: Wed, 18 Sep 2013 16:08:23 +0000 Subject: [PATCH 03/10] // small improvement to Brazilian translations --- install-dev/langs/br/data/quick_access.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install-dev/langs/br/data/quick_access.xml b/install-dev/langs/br/data/quick_access.xml index 72e5a5b9b..6791c4339 100644 --- a/install-dev/langs/br/data/quick_access.xml +++ b/install-dev/langs/br/data/quick_access.xml @@ -1,8 +1,8 @@ - - - - + + + + From c6222c51c851204d4112e70ae3e994a4b8074ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 23 Sep 2013 11:36:15 +0200 Subject: [PATCH 04/10] // commit 6b47f5713e5a8b38fdd36db37849a777455b976e is missing --- js/admin-products.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin-products.js b/js/admin-products.js index 9f67664cd..b187ac55e 100644 --- a/js/admin-products.js +++ b/js/admin-products.js @@ -1576,7 +1576,7 @@ var ProductMultishop = new function() ProductMultishop.checkField($('input[name=\'multishop_check[id_tax_rules_group]\']').prop('checked'), 'id_tax_rules_group'); ProductMultishop.checkField($('input[name=\'multishop_check[unit_price]\']').prop('checked'), 'unit_price', 'unit_price'); ProductMultishop.checkField($('input[name=\'multishop_check[on_sale]\']').prop('checked'), 'on_sale'); - ProductMultishop.checkField($('input[name=\'multishop_check[on_sale]\']').prop('checked'), 'ecotax'); + ProductMultishop.checkField($('input[name=\'multishop_check[ecotax]\']').prop('checked'), 'ecotax'); }; this.checkAllSeo = function() From 6850db06120e9a1879a73b6a77c7d6fe625ea5b7 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 23 Sep 2013 20:23:45 +0200 Subject: [PATCH 05/10] [-] BO : fix contructor override on AdminImportController When we overload the constucteur of AdminImport to add an import type and PS_ADVANCED_STOCK_MANAGEMENT is off, switch index is undefined for "Supply Orders" and "Supply Order Details". --- controllers/admin/AdminImportController.php | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 0a69a5bb4..0e2c6ff19 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -363,10 +363,13 @@ class AdminImportControllerCore extends AdminController 'shop' => Shop::getGroupFromShop(Configuration::get('PS_SHOP_DEFAULT')), ); break; - // @since 1.5.0 - case $this->entities[$this->l('Supply Orders')]: - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) - { + } + + // @since 1.5.0 + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) + switch ((int)Tools::getValue('entity')) + { + case $this->entities[$this->l('Supply Orders')]: // required fields $this->required_fields = array( 'id_supplier', @@ -394,12 +397,8 @@ class AdminImportControllerCore extends AdminController 'discount_rate' => '0', 'is_template' => '0', ); - } - break; - // @since 1.5.0 - case $this->entities[$this->l('Supply Order Details')]: - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) - { + break; + case $this->entities[$this->l('Supply Order Details')]: // required fields $this->required_fields = array( 'supply_order_reference', @@ -423,8 +422,9 @@ class AdminImportControllerCore extends AdminController 'discount_rate' => '0', 'tax_rate' => '0', ); - } - } + break; + + } $this->separator = strval(trim(Tools::getValue('separator', ';'))); @@ -2843,4 +2843,4 @@ class AdminImportControllerCore extends AdminController die; } } -} \ No newline at end of file +} From 6acebca8fa380e1b779d0e7aa9095aa0e2660312 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 23 Sep 2013 21:04:55 +0200 Subject: [PATCH 06/10] [-] BO : fix postProcess override on AdminImportController When we override the constucteur of AdminImport to add an import type and PS_ADVANCED_STOCK_MANAGEMENT is off, switch index is undefined for "Supply Orders" and "Supply Order Details". Default case of switch is never used. --- controllers/admin/AdminImportController.php | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 0a69a5bb4..8689f5f37 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -2764,19 +2764,22 @@ class AdminImportControllerCore extends AdminController $this->supplierImport(); $this->clearSmartyCache(); break; - // @since 1.5.0 - case $this->entities[$import_type = $this->l('Supply Orders')]: - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) - $this->supplyOrdersImport(); - break; - // @since 1.5.0 - case $this->entities[$import_type = $this->l('Supply Order Details')]: - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) - $this->supplyOrdersDetailsImport(); - break; - default: - $this->errors[] = $this->l('Please select what you would like to import'); } + + // @since 1.5.0 + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) + switch ((int)Tools::getValue('entity')) + { + case $this->entities[$import_type = $this->l('Supply Orders')]: + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) + $this->supplyOrdersImport(); + break; + case $this->entities[$import_type = $this->l('Supply Order Details')]: + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) + $this->supplyOrdersDetailsImport(); + break; + } + if ($import_type !== false) { $log_message = sprintf($this->l('%s import'), $import_type); @@ -2843,4 +2846,4 @@ class AdminImportControllerCore extends AdminController die; } } -} \ No newline at end of file +} From 3d477c62ebebb296aa0cf4da4a9e1d6e36a9180e Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 24 Sep 2013 16:03:39 +0200 Subject: [PATCH 07/10] // remove notice --- .../themes/default/template/controllers/products/suppliers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin-dev/themes/default/template/controllers/products/suppliers.tpl b/admin-dev/themes/default/template/controllers/products/suppliers.tpl index 70fa99107..e638aa977 100644 --- a/admin-dev/themes/default/template/controllers/products/suppliers.tpl +++ b/admin-dev/themes/default/template/controllers/products/suppliers.tpl @@ -75,7 +75,7 @@

{l s='Click "Save and Stay" after changing selected suppliers to display the associated product references.'}

{foreach from=$associated_suppliers item=supplier} -

{$supplier->name}

+

{if isset($supplier->name)}{$supplier->name}{/if}

From beb0a74135326cef2bdc08921931748c0d10bdb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 24 Sep 2013 17:12:28 +0200 Subject: [PATCH 08/10] // use ObjectModel::validateField on validaterules --- classes/ObjectModel.php | 39 +++++++-- classes/controller/AdminController.php | 117 ++++++------------------- 2 files changed, 58 insertions(+), 98 deletions(-) diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 20be99921..3dd0072b6 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -893,7 +893,7 @@ abstract class ObjectModelCore * @param int $id_lang * @return bool|string */ - public function validateField($field, $value, $id_lang = null) + public function validateField($field, $value, $id_lang = null, $skip = array(), $human_errors = false) { $this->cacheFieldsRequiredDatabase(); $data = $this->def['fields'][$field]; @@ -901,9 +901,12 @@ abstract class ObjectModelCore // Check if field is required $required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array(); if (!$id_lang || $id_lang == Configuration::get('PS_LANG_DEFAULT')) - if (!empty($data['required']) || in_array($field, $required_fields)) + if (!in_array('required', $skip) && (!empty($data['required']) || in_array($field, $required_fields))) if (Tools::isEmpty($value)) - return 'Property '.get_class($this).'->'.$field.' is empty'; + if ($human_errors) + return sprintf(Tools::displayError('The %s field is required.'), $this->displayFieldName($field, get_class($this))); + else + return 'Property '.get_class($this).'->'.$field.' is empty'; // Default value if (!$value && !empty($data['default'])) @@ -913,11 +916,11 @@ abstract class ObjectModelCore } // Check field values - if (!empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values'])) - return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')'; + if (!in_array('values', $skip) && !empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values'])) + return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')'; // Check field size - if (!empty($data['size'])) + if (!in_array('size', $skip) && !empty($data['size'])) { $size = $data['size']; if (!is_array($data['size'])) @@ -925,11 +928,24 @@ abstract class ObjectModelCore $length = Tools::strlen($value); if ($length < $size['min'] || $length > $size['max']) - return 'Property '.get_class($this).'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max']; + { + if ($human_errors) + { + if (isset($data['lang']) && $data['lang']) + { + $language = new Language((int)$id_lang); + return sprintf(Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'), $this->displayFieldName($field, get_class($this)), $language->name, $size['max']); + } + else + return sprintf(Tools::displayError('The %1$s field is too long (%2$d chars max).'), $this->displayFieldName($field, get_class($this)), $size['max']); + } + else + return 'Property '.get_class($this).'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max']; + } } // Check field validator - if (!empty($data['validate'])) + if (!in_array('validate', $skip) && !empty($data['validate'])) { if (!method_exists('Validate', $data['validate'])) throw new PrestaShopException('Validation function not found. '.$data['validate']); @@ -948,7 +964,12 @@ abstract class ObjectModelCore $res = false; } if (!$res) - return 'Property '.get_class($this).'->'.$field.' is not valid'; + { + if ($human_errors) + return sprintf(Tools::displayError('The %s field is invalid.'), $this->displayFieldName($field, get_class($this))); + else + return 'Property '.get_class($this).'->'.$field.' is not valid'; + } } } diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 84feddee9..56338546b 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2426,102 +2426,41 @@ class AdminControllerCore extends Controller if (!$class_name) $class_name = $this->className; - /* Class specific validation rules */ - if (!empty($class_name)) - $rules = call_user_func(array($class_name, 'getValidationRules'), $class_name); + $object = new $class_name(); + $definition = ObjectModel::getDefinition($class_name); + $default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - if (isset($rules) && count($rules) && (count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang']))) + foreach ($definition['fields'] as $field => $def) { - /* Language() instance determined by default language */ - $default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $skip = array(); + if (in_array($field, array('passwd', 'no-picture'))) + $skip = array('required'); - /* All availables languages */ - $languages = Language::getLanguages(false); + if (isset($def['lang']) && $def['lang'] && isset($def['required']) && $def['required']) + { + $value = Tools::getValue($field.'_'.$default_language->id); + if (Tools::isEmpty($value)) + $this->errors[$field.'_'.$default_language->id] = sprintf( + Tools::displayError('The field %1$s is required at least in %2$s.'), + $object->displayFieldName($field, $class_name), + $default_language->name + ); + + foreach (Language::getLanguages(false) as $language) + { + $value = Tools::getValue($field.'_'.$language['id_lang']); + if (!empty($value)) + if (($error = $object->validateField($field, $value, $language['id_lang'], $skip, true)) !== true) + $this->errors[$field.'_'.$language['id_lang']] = $error; + } + } + else + if (($error = $object->validateField($field, Tools::getValue($field), null, $skip, true)) !== true) + $this->errors[$field] = $error; } - /* Checking for required fields */ - if (isset($rules['required']) && is_array($rules['required'])) - foreach ($rules['required'] as $field) - if (($value = Tools::getValue($field)) == false && (string)$value != '0') - if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture')) - $this->errors[$field] = sprintf( - Tools::displayError('The %s field is required.'), - call_user_func(array($class_name, 'displayFieldName'), $field, $class_name) - ); - - /* Checking for multilingual required fields */ - if (isset($rules['requiredLang']) && is_array($rules['requiredLang'])) - foreach ($rules['requiredLang'] as $field_lang) - if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty)) - $this->errors[$field_lang.'_'.$default_language->id] = sprintf( - Tools::displayError('The field %1$s is required at least in %2$s.'), - call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name), - $default_language->name - ); - - /* Checking for maximum fields sizes */ - if (isset($rules['size']) && is_array($rules['size'])) - foreach ($rules['size'] as $field => $max_length) - if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length) - $this->errors[$field] = sprintf( - Tools::displayError('The %1$s field is too long (%2$d chars max).'), - call_user_func(array($class_name, 'displayFieldName'), $field, $class_name), - $max_length - ); - - /* Checking for maximum multilingual fields size */ - if (isset($rules['sizeLang']) && is_array($rules['sizeLang'])) - foreach ($rules['sizeLang'] as $field_lang => $max_length) - foreach ($languages as $language) - { - $field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']); - if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length) - $this->errors[$field_lang.'_'.$language['id_lang']] = sprintf( - Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'), - call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name), - $language['name'], - $max_length - ); - } /* Overload this method for custom checking */ $this->_childValidation(); - - /* Checking for fields validity */ - if (isset($rules['validate']) && is_array($rules['validate'])) - foreach ($rules['validate'] as $field => $function) - if (($value = Tools::getValue($field)) !== false && ($field != 'passwd')) - if (!Validate::$function($value) && !empty($value)) - $this->errors[$field] = sprintf( - Tools::displayError('The %s field is invalid.'), - call_user_func(array($class_name, 'displayFieldName'), $field, $class_name) - ); - - /* Checking for passwd_old validity */ - if (($value = Tools::getValue('passwd')) != false) - { - if ($class_name == 'Employee' && !Validate::isPasswdAdmin($value)) - $this->errors['passwd'] = sprintf( - Tools::displayError('The %s field is invalid.'), - call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name) - ); - elseif ($class_name == 'Customer' && !Validate::isPasswd($value)) - $this->errors['passwd'] = sprintf( - Tools::displayError('The %s field is invalid.'), - call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name) - ); - } - - /* Checking for multilingual fields validity */ - if (isset($rules['validateLang']) && is_array($rules['validateLang'])) - foreach ($rules['validateLang'] as $field_lang => $function) - foreach ($languages as $language) - if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value)) - if (!Validate::$function($value)) - $this->errors[$field_lang.'_'.$language['id_lang']] = sprintf( - Tools::displayError('The %1$s field (%2$s) is invalid.'), - call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name), - $language['name'] - ); } /** From 5e7dbea9706c1e16ec12d5319bb1187ccd340385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 24 Sep 2013 17:22:50 +0200 Subject: [PATCH 09/10] // --- classes/Product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Product.php b/classes/Product.php index 5a8600fed..a5eb361ec 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -730,10 +730,10 @@ class ProductCore extends ObjectModel /** * @see ObjectModel::validateField() */ - public function validateField($field, $value, $id_lang = null) + public function validateField($field, $value, $id_lang = null, $skip = array(), $human_errors = false) { $value = ($field == 'description_short' ? strip_tags($value) : $value); - return parent::validateField($field, $value, $id_lang); + return parent::validateField($field, $value, $id_lang, $skip, $human_errors); } public function toggleStatus() From 81ca3ac1f91b5943f1e8fadd2aea536caab9d8a2 Mon Sep 17 00:00:00 2001 From: Dinis Lage Date: Tue, 24 Sep 2013 17:42:43 +0100 Subject: [PATCH 10/10] BO: Modules - show update button even if module is not installed but don't warn for modules with updates available but not installed. --- .../themes/default/template/controllers/modules/list.tpl | 2 +- controllers/admin/AdminModulesController.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/modules/list.tpl b/admin-dev/themes/default/template/controllers/modules/list.tpl index 7dd84356f..cef266630 100644 --- a/admin-dev/themes/default/template/controllers/modules/list.tpl +++ b/admin-dev/themes/default/template/controllers/modules/list.tpl @@ -101,7 +101,7 @@   {if isset($module->id_currency) && isset($module->price)}{displayPrice price=$module->price currency=$module->id_currency}{/if} {else} - {if $module->id && isset($module->version_addons) && $module->version_addons} + {if isset($module->version_addons) && $module->version_addons}
  • {l s='Update it!'}
  • {/if}
  • diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index a9f19e379..e8336f8ed 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -1108,8 +1108,8 @@ class AdminModulesControllerCore extends AdminController $modules[$km]->preferences = $modules_preferences[$modules[$km]->name]; } unset($object); - if (isset($module->version_addons)) - $upgrade_available[] = array('anchor' => ucfirst($module->name), 'name' => $module->displayName);; + if ($module->installed && isset($module->version_addons) && $module->version_addons) + $upgrade_available[] = array('anchor' => ucfirst($module->name), 'name' => $module->displayName); } // Don't display categories without modules