// Fix PSCFV-3976

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17269 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard
2012-09-10 14:06:51 +00:00
parent 96104ecbf5
commit 265afeefca
+36 -35
View File
@@ -126,50 +126,51 @@ class AddressControllerCore extends FrontController
// Check phone
if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
$this->errors[] = Tools::displayError('You must register at least one phone number');
// Check country
if (!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country))
throw new PrestaShopException('Country cannot be loaded with address->id_country');
if ((int)$country->contains_states && !(int)$address->id_state)
$this->errors[] = Tools::displayError('This country requires a state selection.');
// US customer: normalize the address
if ($address->id_country == Country::getByIso('US'))
if ($address->id_country)
{
include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
$normalize = new AddressStandardizationSolution;
$address->address1 = $normalize->AddressLineStandardization($address->address1);
$address->address2 = $normalize->AddressLineStandardization($address->address2);
}
// Check country
if (!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country))
throw new PrestaShopException('Country cannot be loaded with address->id_country');
// Check country zip code
$zip_code_format = $country->zip_code_format;
if ($country->need_zip_code)
{
if (($postcode = Tools::getValue('postcode')) && $zip_code_format)
if ((int)$country->contains_states && !(int)$address->id_state)
$this->errors[] = Tools::displayError('This country requires a state selection.');
// US customer: normalize the address
if ($address->id_country == Country::getByIso('US'))
{
if (!$country->checkZipCode($postcode))
include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
$normalize = new AddressStandardizationSolution;
$address->address1 = $normalize->AddressLineStandardization($address->address1);
$address->address2 = $normalize->AddressLineStandardization($address->address2);
}
// Check country zip code
$zip_code_format = $country->zip_code_format;
if ($country->need_zip_code)
{
if (($postcode = Tools::getValue('postcode')) && $zip_code_format)
{
if (!$country->checkZipCode($postcode))
$this->errors[] = sprintf(
Tools::displayError('Zip/Postal code is invalid. Must be typed as follows: %s'),
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
);
}
else if ($zip_code_format)
$this->errors[] = Tools::displayError('Zip/Postal code is required.');
else if ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->errors[] = sprintf(
Tools::displayError('Zip/Postal code is invalid. Must be typed as follows: %s'),
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
);
}
else if ($zip_code_format)
$this->errors[] = Tools::displayError('Zip/Postal code is required.');
else if ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->errors[] = sprintf(
Tools::displayError('Zip/Postal code is invalid. Must be typed as follows: %s'),
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
);
// Check country DNI
if ($country->isNeedDni() && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
else if (!$country->isNeedDni())
$address->dni = null;
}
// Check country DNI
if ($country->isNeedDni() && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
else if (!$country->isNeedDni())
$address->dni = null;
// Check if the alias exists
if (!empty($_POST['alias'])
&& (int)$this->context->customer->id > 0