public function checkPreValidation() { $errorList = array(); if (!$this->_mondialRelay) { $this->_mondialRelay = new MondialRelay(); } $list = array('Expe_Langage' => array('value' => Configuration::get('MR_LANGUAGE'), 'error' => $this->_mondialRelay->l('Please check your language configuration')), 'Expe_Ad1' => array('value' => Configuration::get('PS_MR_SHOP_NAME'), 'error' => $this->_mondialRelay->l('Please check your shop name configuration')), 'Expe_Ad3' => array('value' => Configuration::get('PS_SHOP_ADDR1'), 'error' => $this->_mondialRelay->l('Please check your address 1 configuration')), 'Expe_Ville' => array('value' => Configuration::get('PS_SHOP_CITY'), 'error' => $this->_mondialRelay->l('Please check your city configuration')), 'Expe_CP' => array('value' => Configuration::get('PS_SHOP_CODE'), 'error' => $this->_mondialRelay->l('Please check your zipcode configuration')), 'Expe_Pays' => array('value' => _PS_VERSION_ >= '1.4' ? Country::getIsoById(Configuration::get('PS_SHOP_COUNTRY_ID')) : substr(Configuration::get('PS_SHOP_COUNTRY'), 0, 2), 'error' => $this->_mondialRelay->l('Please check your country configuration')), 'Expe_Tel1' => array('value' => str_replace(array('.', ' ', '-'), '', Configuration::get('PS_SHOP_PHONE')), 'error' => $this->_mondialRelay->l('Please check your Phone configuration')), 'Expe_Mail' => array('value' => Configuration::get('PS_SHOP_EMAIL'), 'error' => $this->_mondialRelay->l('Please check your mail configuration'))); foreach ($list as $name => $tab) { $tab['value'] = strtoupper($tab['value']); if ($name == 'Expe_CP') { if (!MRTools::checkZipcodeByCountry($tab['value'], array('id_country' => Configuration::get('PS_COUNTRY_DEFAULT')))) { $errorList[$name] = $tab['error']; } } else { if (isset($this->_fields['list'][$name]['regexValidation']) && !preg_match($this->_fields['list'][$name]['regexValidation'], $tab['value'], $matches)) { $errorList[$name] = $tab['error']; } } } return $errorList; }
public function checkPreValidation() { $errorList = array('error' => array(), 'warn' => array()); $list = array('Expe_Langage' => array('value' => $this->_mondialrelay->account_shop['MR_LANGUAGE'], 'error' => $this->_mondialrelay->l('Please check your language configuration', $this->class_name)), 'Expe_Ad1' => array('value' => Configuration::get('PS_SHOP_NAME'), 'error' => $this->_mondialrelay->l('Please check your shop name configuration', $this->class_name)), 'Expe_Ad3' => array('value' => Configuration::get('PS_SHOP_ADDR1'), 'error' => $this->_mondialrelay->l('Please check your address 1 configuration', $this->class_name)), 'Expe_Ville' => array('value' => Configuration::get('PS_SHOP_CITY'), 'error' => $this->_mondialrelay->l('Please check your city configuration', $this->class_name)), 'Expe_CP' => array('value' => Configuration::get('PS_SHOP_CODE'), 'error' => $this->_mondialrelay->l('Please check your zipcode configuration', $this->class_name)), 'Expe_Pays' => array('value' => _PS_VERSION_ >= '1.4' ? Country::getIsoById(Configuration::get('PS_SHOP_COUNTRY_ID')) : substr(Configuration::get('PS_SHOP_COUNTRY'), 0, 2), 'error' => $this->_mondialrelay->l('Please check your country configuration', $this->class_name)), 'Expe_Tel1' => array('value' => MRTools::getFormatedPhone(Configuration::get('PS_SHOP_PHONE')), 'error' => $this->_mondialrelay->l('Please check your Phone configuration', $this->class_name)), 'Expe_Mail' => array('value' => Configuration::get('PS_SHOP_EMAIL'), 'error' => $this->_mondialrelay->l('Please check your mail configuration', $this->class_name))); foreach ($list as $name => $tab) { // Mac server make an empty string instead of a cleaned string // TODO : test on windows and linux server $cleanedString = MRTools::removeAccents($tab['value']); $tab['value'] = !empty($cleanedString) ? strtoupper($cleanedString) : strtoupper($tab['value']); if ($name == 'Expe_CP') { if (version_compare(_PS_VERSION_, '1.4', '>=')) { if (!($zipcodeError = MRTools::checkZipcodeByCountry($tab['value'], array('id_country' => Configuration::get('PS_COUNTRY_DEFAULT'))))) { $errorList['error'][$name] = $tab['error']; } } else { $errorList['warn'][$name] = $this->_mondialrelay->l('Post code cannot be validated with PrestaShop versions older than 1.4', $this->class_name); } } else { if (isset($this->_fields['list'][$name]['regexValidation']) && !preg_match($this->_fields['list'][$name]['regexValidation'], $tab['value'], $matches)) { $errorList['error'][$name] = $tab['error']; } } } return $errorList; }
public function checkPreValidation() { $errorList = array('error' => array(), 'warn' => array()); $list = array('Expe_Langage' => array('value' => $this->_mondialrelay->account_shop['MR_LANGUAGE'], 'error' => $this->_mondialrelay->l('Please check your language configuration')), 'Expe_Ad1' => array('value' => Configuration::get('PS_SHOP_NAME'), 'error' => $this->_mondialrelay->l('Please check your shop name configuration')), 'Expe_Ad3' => array('value' => Configuration::get('PS_SHOP_ADDR1'), 'error' => $this->_mondialrelay->l('Please check your address 1 configuration')), 'Expe_Ville' => array('value' => Configuration::get('PS_SHOP_CITY'), 'error' => $this->_mondialrelay->l('Please check your city configuration')), 'Expe_CP' => array('value' => Configuration::get('PS_SHOP_CODE'), 'error' => $this->_mondialrelay->l('Please check your zipcode configuration'), 'warn' => $this->_mondialrelay->l('It seems the layout of your zipcode country is not configured or you didn\'t set a right zipcode')), 'Expe_Pays' => array('value' => _PS_VERSION_ >= '1.4' ? Country::getIsoById(Configuration::get('PS_SHOP_COUNTRY_ID')) : substr(Configuration::get('PS_SHOP_COUNTRY'), 0, 2), 'error' => $this->_mondialrelay->l('Please check your country configuration')), 'Expe_Tel1' => array('value' => str_pad(substr(preg_replace('/[^0-9+\\(\\)]*/', '', Configuration::get('PS_SHOP_PHONE')), 0, 10), 10, '0'), 'error' => $this->_mondialrelay->l('Please check your Phone configuration')), 'Expe_Mail' => array('value' => Configuration::get('PS_SHOP_EMAIL'), 'error' => $this->_mondialrelay->l('Please check your mail configuration'))); foreach ($list as $name => $tab) { // Mac server make an empty string instead of a cleaned string // TODO : test on windows and linux server $cleanedString = MRTools::replaceAccentedCharacters($tab['value']); $tab['value'] = !empty($cleanedString) ? strtoupper($cleanedString) : strtoupper($tab['value']); if ($name == 'Expe_CP') { if (version_compare(_PS_VERSION_, '1.4', '>=')) { if (!($zipcodeError = MRTools::checkZipcodeByCountry($tab['value'], array('id_country' => Configuration::get('PS_COUNTRY_DEFAULT'))))) { $errorList['error'][$name] = $tab['error']; } else { if ($zipcodeError < 0) { $errorList['warn'][$name] = $tab['warn']; } } } else { $errorList['warn'][$name] = $this->_mondialrelay->l('Using a PrestaShop version less than 1.4, we can\'t validate the zipcode'); } } else { if (isset($this->_fields['list'][$name]['regexValidation']) && !preg_match($this->_fields['list'][$name]['regexValidation'], $tab['value'], $matches)) { $errorList['error'][$name] = $tab['error']; } } } return $errorList; }