private function _generateMD5SecurityKey()
 {
     $concatenationValue = '';
     foreach ($this->_fields['list'] as $paramName => &$valueDetailed) {
         if ($paramName != 'Texte' && $paramName != 'Security') {
             // Mac server make an empty string instead of a cleaned string
             // TODO : test on windows and linux server
             $cleanedString = MRTools::replaceAccentedCharacters($valueDetailed['value']);
             $valueDetailed['value'] = !empty($cleanedString) ? strtoupper($cleanedString) : strtoupper($valueDetailed['value']);
             $valueDetailed['value'] = strtoupper($valueDetailed['value']);
             // Call a pointer function if exist to do different test
             if (isset($valueDetailed['methodValidation']) && method_exists('MRTools', $valueDetailed['methodValidation']) && isset($valueDetailed['params']) && MRTools::$valueDetailed['methodValidation']($valueDetailed['value'], $valueDetailed['params'])) {
                 $concatenationValue .= $valueDetailed['value'];
             } else {
                 if (isset($valueDetailed['regexValidation']) && preg_match($valueDetailed['regexValidation'], $valueDetailed['value'], $matches)) {
                     $concatenationValue .= $valueDetailed['value'];
                 } else {
                     if (!strlen($valueDetailed['value']) && $valueDetailed['required'] || strlen($valueDetailed['value'])) {
                         $error = $this->_mondialRelay->l('This key') . ' [' . $paramName . '] ' . $this->_mondialRelay->l('hasn\'t a valide value format') . ' : ' . $valueDetailed['value'];
                         $this->_resultList['error'][] = $error;
                     }
                 }
             }
         }
     }
     $concatenationValue .= $this->_webServiceKey;
     $this->_fields['list']['Security']['value'] = strtoupper(md5($concatenationValue));
 }
 private function _generateMD5SecurityKey()
 {
     // RootCase is the array case where the main information are stored
     // it's an array containing id_mr_selected and an array with the necessary fields
     foreach ($this->_fieldsList as &$rootCase) {
         $concatenationValue = '';
         foreach ($rootCase['list'] as $paramName => &$valueDetailed) {
             if ($paramName != 'Texte' && $paramName != 'Security') {
                 // Mac server make an empty string instead of a cleaned string
                 // TODO : test on windows and linux server
                 $cleanedString = MRTools::replaceAccentedCharacters($valueDetailed['value']);
                 $valueDetailed['value'] = !empty($cleanedString) ? strtoupper($cleanedString) : strtoupper($valueDetailed['value']);
                 // Call a pointer function if exist to do different test
                 if (isset($valueDetailed['methodValidation']) && method_exists('MRTools', $valueDetailed['methodValidation']) && isset($valueDetailed['params']) && MRTools::$valueDetailed['methodValidation']($valueDetailed['value'], $valueDetailed['params'])) {
                     $concatenationValue .= $valueDetailed['value'];
                 } else {
                     if (isset($valueDetailed['regexValidation']) && preg_match($valueDetailed['regexValidation'], $valueDetailed['value'], $matches)) {
                         $concatenationValue .= $valueDetailed['value'];
                     } else {
                         if (!strlen($valueDetailed['value']) && $valueDetailed['required'] || strlen($valueDetailed['value'])) {
                             if (empty($valueDetailed['value'])) {
                                 $error = $this->_mondialRelay->l('This key') . ' [' . $paramName . '] ' . $this->_mondialRelay->l('is empty and need to be filled');
                             } else {
                                 $error = 'This key [' . $paramName . '] hasn\'t a valid value format : ' . $valueDetailed['value'];
                             }
                             $this->_resultList['error'][$rootCase['list']['NDossier']['value']][] = $error;
                         }
                     }
                 }
             }
         }
         $concatenationValue .= $this->_webServiceKey;
         $rootCase['list']['Security']['value'] = strtoupper(md5($concatenationValue));
     }
 }
Ejemplo n.º 3
0
 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;
 }