From 071778796b664dc91f1bf323405fcd6bfdbfc386 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Tue, 6 Mar 2012 10:32:25 +0000 Subject: [PATCH] [-] BO : fixed #PSTEST-939 - now you can't add tow country with the same isocode --- controllers/admin/AdminCountriesController.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminCountriesController.php b/controllers/admin/AdminCountriesController.php index 6e8982059..87dadab12 100644 --- a/controllers/admin/AdminCountriesController.php +++ b/controllers/admin/AdminCountriesController.php @@ -353,7 +353,22 @@ class AdminCountriesControllerCore extends AdminController public function postProcess() { - $res = parent::postProcess(); + if (!Tools::getValue('id_'.$this->table)) + { + if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) + $this->errors[] = Tools::displayError('This iso code already exist, you can\'t create two country with the same iso code'); + } + else if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) + { + $id_country = Country::getByIso(Tools::getValue('iso_code')); + if (!is_null($id_country) && $id_country != Tools::getValue('id_'.$this->table)) + $this->errors[] = Tools::displayError('This iso code already exist, you can\'t create two country with the same iso code'); + } + + if (!count($this->errors)) + $res = parent::postProcess(); + else + return false; if (Tools::getValue('submitAdd'.$this->table) && $res) {