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/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}
-
+
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.'}
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/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()
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']
- );
}
/**
diff --git a/classes/module/Module.php b/classes/module/Module.php
index f3c8e73d1..d28465d92 100644
--- a/classes/module/Module.php
+++ b/classes/module/Module.php
@@ -938,7 +938,7 @@ abstract class ModuleCore
public static function configXmlStringFormat($string)
{
- return str_replace('\'', '\\\'', Tools::htmlentitiesDecodeUTF8($string));
+ return Tools::htmlentitiesDecodeUTF8($string);
}
diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php
index 0a69a5bb4..06dc11148 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', ';')));
@@ -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
+}
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
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 @@
-
-
-
-
+
+
+
+
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()