当前位置: 首页>>代码示例>>PHP>>正文


PHP Validate::isPostCode方法代码示例

本文整理汇总了PHP中Validate::isPostCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isPostCode方法的具体用法?PHP Validate::isPostCode怎么用?PHP Validate::isPostCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validate的用法示例。


在下文中一共展示了Validate::isPostCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hookFooter

 /**
  * Returns module content for header
  *
  * @param array $params Parameters
  * @return string Content
  */
 function hookFooter($params)
 {
     global $smarty, $cookie, $cart;
     if (isset($smarty->_tpl_vars['HOOK_EXTRACARRIER']) and $smarty->_tpl_vars['page_name'] == 'order') {
         $smarty->assign('TNTCarrierId', $this->_id_carrier);
         //			if ($smarty->_tpl_vars['page_name'] == 'order')
         //				$smarty->assign('TNT_js', 'relaisColis');
         if ($smarty->_tpl_vars['page_name'] == 'history') {
             $smarty->assign('TNT_js', 'suiviColis');
         }
         return $this->display(__FILE__, 'relaistnt_footer.tpl');
     } elseif ($smarty->_tpl_vars['page_name'] == 'order' and (Tools::isSubmit('processCarrier') or Tools::getValue('step') === '3') and Validate::isLoadedObject($cart)) {
         if ($cart->id_carrier != intval($this->_id_carrier)) {
             return;
         }
         if (Configuration::get('PS_TOKEN_ENABLE') == 1 && strcmp(Tools::getToken(false), Tools::getValue('token')) && $cookie->isLogged() === true) {
             $error = $this->l('invalid token');
         }
         $tntRCSelectedCode = pSQL(Tools::getValue('tntRCSelectedCode'));
         if (empty($tntRCSelectedCode) or is_null($tntRCSelectedCode)) {
             $error = $this->l('Avec la livraison TNT, vous devez choisir le relais dans lequel votre colis sera livré.');
         }
         if (!isset($error)) {
             $address_TNT = new Address();
             $address_TNT->id_country = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
             $address_TNT->id_customer = intval($cart->id_customer);
             $address_TNT->alias = $this->l('TNT-') . $cart->id . '-' . $tntRCSelectedCode;
             $address_TNT->lastname = $this->l('TNT');
             $address_TNT->firstname = $this->l('Relais Colis');
             if (Validate::isName(Tools::getValue('tntRCSelectedNom'))) {
                 $address_TNT->company = pSQL(Tools::getValue('tntRCSelectedNom'));
                 $address_TNT->firstname .= ' - ' . pSQL(Tools::getValue('tntRCSelectedNom'));
             }
             if (Validate::isAddress(Tools::getValue('tntRCSelectedAdresse'))) {
                 $address_TNT->address1 = pSQL(Tools::getValue('tntRCSelectedAdresse'));
             }
             if (Validate::isPostCode(Tools::getValue('tntRCSelectedCodePostal'))) {
             }
             $address_TNT->postcode = pSQL(Tools::getValue('tntRCSelectedCodePostal'));
             if (Validate::isCityName(preg_replace('[\\d]', '', pSQL(Tools::getValue('tntRCSelectedCommune'))))) {
                 $address_TNT->city = preg_replace('[\\d]', '', pSQL(Tools::getValue('tntRCSelectedCommune')));
             }
             $address_TNT->deleted = 1;
             $errors = $address_TNT->validateControler();
             if (is_array($errors) and isset($errors[0])) {
                 Tools::redirect('order.php?step=2&error;=' . urlencode($errors[0]));
             }
             if ($address_TNT->save()) {
                 $cart->id_address_delivery = intval($address_TNT->id);
                 $cart->save();
             } else {
                 Tools::redirect('order.php?step=2&error;=' . urlencode($this->l('could not save TNT address')));
             }
         } else {
             Tools::redirect('order.php?step=2&error;=' . urlencode($error));
         }
     }
 }
开发者ID:bastnic,项目名称:presta-relaistnt,代码行数:64,代码来源:relaistnt.php

示例2: _postValidationParameters

 private function _postValidationParameters()
 {
     // Check configuration values
     if (Tools::getValue('ebay_identifier') == NULL) {
         $this->_postErrors[] = $this->l('Your eBay identifier account is not specified or is invalid');
     }
     if (Tools::getValue('ebay_shop') == NULL) {
         $this->_postErrors[] = $this->l('Your ebay shop must be specified');
     }
     if (Tools::getValue('ebay_paypal_email') == NULL or !Validate::isEmail(Tools::getValue('ebay_paypal_email'))) {
         $this->_postErrors[] = $this->l('Your Paypal E-mail account is not specified or is invalid');
     }
     if (Tools::getValue('ebay_shipping_cost') == '' or !is_numeric(Tools::getValue('ebay_shipping_cost'))) {
         $this->_postErrors[] = $this->l('Your shipping cost is not specified or is invalid');
     }
     if (Tools::getValue('ebay_shop_postalcode') == '' or !Validate::isPostCode(Tools::getValue('ebay_shop_postalcode'))) {
         $this->_postErrors[] = $this->l('Your shop\'s postal code is not specified or is invalid');
     }
 }
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:19,代码来源:ebay.php

示例3: postProcess

 public function postProcess()
 {
     // On construit un login pour le compte
     // ------------------------------------
     // Si PS_SHOP_EMAIL = info@axalone.com
     // Alors login      = ps-info-axalone
     //   1/ On ajoute 'ps-' devant l'email
     //   2/ On retire l'extention .com à la fin
     //   3/ On remplace toutes les lettres accentuées par leurs équivalents sans accent
     //   4/ On remplace tous les sigles par des tirets
     //   5/ Enfin on remplace les doubles/triples tirets par des simples
     // --------------------------------------------------------------------------------
     $company_login = 'ps-' . Configuration::get('PS_SHOP_EMAIL');
     $company_login = Tools::substr($company_login, 0, strrpos($company_login, '.'));
     $company_login = EMTools::removeAccents($company_login);
     $company_login = Tools::strtolower($company_login);
     $company_login = preg_replace('/[^a-z0-9-]/', '-', $company_login);
     $company_login = preg_replace('/-{2,}/', '-', $company_login);
     $cart_product = (string) Tools::getValue('product', '');
     // Initialisation de l'API
     // -----------------------
     if (Tools::isSubmit('submitInscription')) {
         // On prépare l'ouverture du compte
         // --------------------------------
         $company_name = (string) Tools::getValue('company_name');
         $company_email = (string) Tools::getValue('company_email');
         $company_phone = (string) Tools::getValue('company_phone');
         $company_address1 = (string) Tools::getValue('company_address1');
         $company_address2 = (string) Tools::getValue('company_address2');
         $company_zipcode = (string) Tools::getValue('company_zipcode');
         $company_city = (string) Tools::getValue('company_city');
         $country_id = (int) Tools::getValue('country_id');
         $country = new Country($country_id);
         if (!is_object($country) || empty($country->id)) {
             $this->errors[] = Tools::displayError('Country is invalid');
         } else {
             $company_country = Country::getNameById($this->context->language->id, $country_id);
         }
         if (!Validate::isGenericName($company_name)) {
             $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop name', 'AdminStores') . ' »');
         }
         if (!Validate::isEmail($company_email)) {
             $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop email', 'AdminStores') . ' »');
         }
         if (!Validate::isPhoneNumber($company_phone)) {
             $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Phone', 'AdminStores') . ' »');
         }
         if (!Validate::isAddress($company_address1)) {
             $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop address line 1', 'AdminStores') . ' »');
         }
         if ($country->zip_code_format && !$country->checkZipCode($company_zipcode)) {
             $this->errors[] = Tools::displayError('Your Zip/postal code is incorrect.') . '<br />' . Tools::displayError('It must be entered as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)));
         } elseif (empty($company_zipcode) && $country->need_zip_code) {
             $this->errors[] = Tools::displayError('A Zip/postal code is required.');
         } elseif ($company_zipcode && !Validate::isPostCode($company_zipcode)) {
             $this->errors[] = Tools::displayError('The Zip/postal code is invalid.');
         }
         if (!Validate::isGenericName($company_city)) {
             $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('City', 'AdminStores') . ' »');
         }
         // We save these informations in the database
         // ------------------------------------------
         Db::getInstance()->insert('expressmailing_order_address', array('id_address' => 1, 'company_name' => pSQL($company_name), 'company_email' => pSQL($company_email), 'company_address1' => pSQL($company_address1), 'company_address2' => pSQL($company_address2), 'company_zipcode' => pSQL($company_zipcode), 'company_city' => pSQL($company_city), 'country_id' => $country_id, 'company_country' => pSQL($company_country), 'company_phone' => pSQL($company_phone), 'product' => pSQL($cart_product)), false, false, Db::REPLACE);
         // If form contains 1 or more errors, we stop the process
         // ------------------------------------------------------
         if (is_array($this->errors) && count($this->errors)) {
             return false;
         }
         // Open a session on Express-Mailing API
         // -------------------------------------
         if ($this->session_api->openSession()) {
             // We create the account
             // ---------------------
             $response_array = array();
             $base_url = Configuration::get('PS_SSL_ENABLED') == 0 ? Tools::getShopDomain(true, true) : Tools::getShopDomainSsl(true, true);
             $module_dir = Tools::str_replace_once(_PS_ROOT_DIR_, '', _PS_MODULE_DIR_);
             $parameters = array('login' => $company_login, 'info_company' => $company_name, 'info_email' => $company_email, 'info_phone' => $company_phone, 'info_address' => $company_address1 . "\r\n" . $company_address2, 'info_country' => $company_country, 'info_zipcode' => $company_zipcode, 'info_city' => $company_city, 'info_phone' => $company_phone, 'info_contact_firstname' => $this->context->employee->firstname, 'info_contact_lastname' => $this->context->employee->lastname, 'email_report' => $this->context->employee->email, 'gift_code' => 'prestashop_' . Translate::getModuleTranslation('expressmailing', '3320', 'session_api'), 'INFO_WWW' => $base_url . $module_dir . $this->module->name . '/campaigns/index.php');
             if ($this->session_api->createAccount($parameters, $response_array)) {
                 // If the form include the buying process (field 'product')
                 // We initiate a new cart with the product selected
                 // --------------------------------------------------------
                 if ($cart_product) {
                     Tools::redirectAdmin('index.php?controller=AdminMarketingBuy&submitCheckout&campaign_id=' . $this->campaign_id . '&media=' . $this->next_controller . '&product=' . $cart_product . '&token=' . Tools::getAdminTokenLite('AdminMarketingBuy'));
                     exit;
                 }
                 // Else we back to the mailing process
                 // -----------------------------------
                 Tools::redirectAdmin($this->next_action);
                 exit;
             }
             if ($this->session_api->error == 11) {
                 // Account already existe, we print the rescue form (with password input)
                 // ----------------------------------------------------------------------
                 $response_array = array();
                 $parameters = array('login' => $company_login);
                 $this->session_api->resendPassword($parameters, $response_array);
                 $this->generateRescueForm();
                 return;
             } else {
                 // Other error
//.........这里部分代码省略.........
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:101,代码来源:adminmarketinginscription.php

示例4: isValid

 /**
  * test if found postcode relevance is enough for considering the postcode useful in the rest of checkout process
  *
  * @param          $post_code
  * @param stdClass $relevance
  *
  * @return bool
  */
 private function isValid($post_code, stdClass $relevance = null)
 {
     if (!Validate::isPostCode($post_code) || empty($relevance)) {
         return false;
     }
     if (!empty($relevance->percent) && $relevance->percent > DpdGroupSearch::SEARCH_RESULT_RELEVANCE_THRESHOLD_FOR_VALIDATION) {
         return true;
     }
     return false;
 }
开发者ID:remixaz,项目名称:dpdgroup,代码行数:18,代码来源:PostcodeSearch.php

示例5: preProcess

 public function preProcess()
 {
     parent::preProcess();
     if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) {
         Tools::redirect('my-account.php');
     }
     if (Tools::getValue('create_account')) {
         $create_account = 1;
         self::$smarty->assign('email_create', 1);
     }
     if (Tools::isSubmit('SubmitCreate')) {
         if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (Customer::customerExists($email, false, false)) {
             $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             $_POST['email'] = $_POST['email_create'];
             unset($_POST['email_create']);
         } else {
             $create_account = 1;
             self::$smarty->assign('email_create', Tools::safeOutput($email));
             $_POST['email'] = $email;
         }
     }
     if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) {
         $create_account = 1;
         if (Tools::isSubmit('submitAccount')) {
             self::$smarty->assign('email_create', 1);
         }
         /* New Guest customer */
         if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
             $this->errors[] = Tools::displayError('You cannot create a guest account.');
         }
         if (!Tools::getValue('is_new_customer', 1)) {
             $_POST['passwd'] = md5(time() . _COOKIE_KEY_);
         }
         if (isset($_POST['guest_email']) and $_POST['guest_email']) {
             $_POST['email'] = $_POST['guest_email'];
         }
         /* Preparing customer */
         $customer = new Customer();
         $lastnameAddress = $_POST['lastname'];
         $firstnameAddress = $_POST['firstname'];
         $_POST['lastname'] = $_POST['customer_lastname'];
         $_POST['firstname'] = $_POST['customer_firstname'];
         if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) {
             $this->errors[] = Tools::displayError('You must register at least one phone number');
         }
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         }
         $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
         $this->errors = array_unique(array_merge($this->errors, $customer->validateControler()));
         /* Preparing address */
         $address = new Address();
         $_POST['lastname'] = $lastnameAddress;
         $_POST['firstname'] = $firstnameAddress;
         $address->id_customer = 1;
         $this->errors = array_unique(array_merge($this->errors, $address->validateControler()));
         /* US customer: normalize the address */
         if ($address->id_country == Country::getByIso('US') && Configuration::get('PS_TAASC')) {
             include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php';
             $normalize = new AddressStandardizationSolution();
             $address->address1 = $normalize->AddressLineStandardization($address->address1);
             $address->address2 = $normalize->AddressLineStandardization($address->address2);
         }
         if (!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country)) {
             $this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country');
         }
         $postcode = Tools::getValue('postcode');
         /* Check zip code format */
         if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
             $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)));
         } elseif (empty($postcode) && $country->need_zip_code) {
             $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.');
         } elseif ($postcode && !Validate::isPostCode($postcode)) {
             $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.');
         }
         if (Country::isNeedDniByCountryId($address->id_country) and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) {
             $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
         } elseif (!Country::isNeedDniByCountryId($address->id_country)) {
             $address->dni = NULL;
         }
         if (!count($this->errors)) {
             if (Customer::customerExists(Tools::getValue('email'), false, Configuration::get('PS_GUEST_CHECKOUT_ENABLED') && Tools::getValue('is_new_customer') == 0)) {
                 $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             }
             if (Tools::isSubmit('newsletter')) {
                 $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
                 $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
             }
             if (!count($this->errors)) {
                 $country = new Country((int) $address->id_country, _PS_LANG_DEFAULT_);
                 if (!$country || !Validate::isLoadedObject($country)) {
                     die(Tools::displayError());
                 }
                 if ((int) $country->contains_states && !(int) $address->id_state) {
                     $this->errors[] = Tools::displayError('This country requires a state selection.');
                 } else {
                     $customer->active = 1;
                     /* New Guest customer */
//.........这里部分代码省略.........
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:101,代码来源:AuthController.php

示例6: postProcess

 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table])) {
         // Transform e-mail in id_customer for parent processing
         if ($this->addressType == 'customer') {
             if (Validate::isEmail(Tools::getValue('email'))) {
                 $customer = new Customer();
                 $customer->getByEmail(Tools::getValue('email'), null, true);
                 if (Validate::isLoadedObject($customer)) {
                     $_POST['id_customer'] = $customer->id;
                 } else {
                     $this->_errors[] = Tools::displayError('This e-mail address is not registered.');
                 }
             } elseif ($id_customer = Tools::getValue('id_customer')) {
                 $customer = new Customer((int) $id_customer);
                 if (Validate::isLoadedObject($customer)) {
                     $_POST['id_customer'] = $customer->id;
                 } else {
                     $this->_errors[] = Tools::displayError('Unknown customer');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('Unknown customer');
             }
             if (Country::isNeedDniByCountryId(Tools::getValue('id_country')) and !Tools::getValue('dni')) {
                 $this->_errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
             }
         }
         // Check manufacturer selected
         if ($this->addressType == 'manufacturer') {
             $manufacturer = new Manufacturer((int) Tools::getValue('id_manufacturer'));
             if (!Validate::isLoadedObject($manufacturer)) {
                 $this->_errors[] = Tools::displayError('Manufacturer selected is not valid.');
             }
         }
         /* If the selected country does not contain states */
         $id_state = (int) Tools::getValue('id_state');
         if ($id_country = Tools::getValue('id_country') and $country = new Country((int) $id_country) and !(int) $country->contains_states and $id_state) {
             $this->_errors[] = Tools::displayError('You have selected a state for a country that does not contain states.');
         }
         /* If the selected country contains states, then a state have to be selected */
         if ((int) $country->contains_states && !$id_state) {
             $this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
         }
         $postcode = Tools::getValue('postcode');
         /* Check zip code format */
         if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
             $this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)));
         } elseif (empty($postcode) && $country->need_zip_code) {
             $this->_errors[] = Tools::displayError('Postcode required.');
         } elseif ($postcode && !Validate::isPostCode($postcode)) {
             $this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.');
         }
         /* If this address come from order's edition and is the same as the other one (invoice or delivery one)
          ** we delete its id_address to force the creation of a new one */
         if ((int) Tools::getValue('id_order')) {
             $this->_redirect = false;
             if (isset($_POST['address_type'])) {
                 $_POST['id_address'] = '';
             }
         }
     }
     if (Tools::getIsset('delete' . $this->table) && $this->tabAccess['delete'] === '1') {
         call_user_func_array(array($this->className, '_cleanCart'), array(null, (int) Tools::getValue('id_address')));
     }
     if (!sizeof($this->_errors)) {
         parent::postProcess();
     }
     /* Reassignation of the order's new (invoice or delivery) address */
     $address_type = (int) Tools::getValue('address_type') == 2 ? 'invoice' : ((int) Tools::getValue('address_type') == 1 ? 'delivery' : '');
     if (isset($_POST['submitAdd' . $this->table]) and $id_order = (int) Tools::getValue('id_order') and !sizeof($this->_errors) and !empty($address_type)) {
         if (!Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'orders SET `id_address_' . $address_type . '` = ' . Db::getInstance()->Insert_ID() . ' WHERE `id_order` = ' . $id_order)) {
             $this->_errors[] = Tools::displayError('An error occurred while linking this address to its order.');
         } else {
             Tools::redirectAdmin(Tools::getValue('back') . '&conf=4');
         }
     }
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:77,代码来源:AdminAddresses.php

示例7: postProcess

 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table])) {
         /* Cleaning fields */
         foreach ($_POST as $kp => $vp) {
             if (!in_array($kp, array('checkBoxShopGroupAsso_store', 'checkBoxShopAsso_store'))) {
                 $_POST[$kp] = trim($vp);
             }
         }
         /* Rewrite latitude and longitude to 8 digits */
         $_POST['latitude'] = number_format((double) $_POST['latitude'], 8);
         $_POST['longitude'] = number_format((double) $_POST['longitude'], 8);
         /* If the selected country does not contain states */
         $id_state = (int) Tools::getValue('id_state');
         $id_country = (int) Tools::getValue('id_country');
         $country = new Country((int) $id_country);
         if ($id_country && $country && !(int) $country->contains_states && $id_state) {
             $this->errors[] = Tools::displayError('You\'ve selected a state for a country that does not contain states.');
         }
         /* If the selected country contains states, then a state have to be selected */
         if ((int) $country->contains_states && !$id_state) {
             $this->errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
         }
         $latitude = (double) Tools::getValue('latitude');
         $longitude = (double) Tools::getValue('longitude');
         if (empty($latitude) || empty($longitude)) {
             $this->errors[] = Tools::displayError('Latitude and longitude are required.');
         }
         $postcode = Tools::getValue('postcode');
         /* Check zip code format */
         if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
             $this->errors[] = Tools::displayError('Your Zip/postal code is incorrect.') . '<br />' . Tools::displayError('It must be entered as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)));
         } elseif (empty($postcode) && $country->need_zip_code) {
             $this->errors[] = Tools::displayError('A Zip/postal code is required.');
         } elseif ($postcode && !Validate::isPostCode($postcode)) {
             $this->errors[] = Tools::displayError('The Zip/postal code is invalid.');
         }
         /* Store hours */
         $_POST['hours'] = array();
         for ($i = 1; $i < 8; $i++) {
             $_POST['hours'][] .= Tools::getValue('hours_' . (int) $i);
         }
         $_POST['hours'] = serialize($_POST['hours']);
     }
     if (!count($this->errors)) {
         parent::postProcess();
     } else {
         $this->display = 'add';
     }
 }
开发者ID:ortegon000,项目名称:tienda,代码行数:50,代码来源:AdminStoresController.php

示例8: processSubmitAccount


//.........这里部分代码省略.........
         }
     } else {
         // if registration type is in one step, we save the address
         $_POST['lastname'] = $lastnameAddress;
         $_POST['firstname'] = $firstnameAddress;
         $post_back = $_POST;
         // Preparing addresses
         foreach ($addresses_types as $addresses_type) {
             ${$addresses_type} = new Address();
             ${$addresses_type}->id_customer = 1;
             if ($addresses_type == 'address_invoice') {
                 foreach ($_POST as $key => &$post) {
                     if ($tmp = Tools::getValue($key . '_invoice')) {
                         $post = $tmp;
                     }
                 }
             }
             $this->errors = array_unique(array_merge($this->errors, ${$addresses_type}->validateController()));
             if ($addresses_type == 'address_invoice') {
                 $_POST = $post_back;
             }
             if (!($country = new Country(${$addresses_type}->id_country)) || !Validate::isLoadedObject($country)) {
                 $this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country');
             }
             if (!$country->active) {
                 $this->errors[] = Tools::displayError('This country is not active.');
             }
             $postcode = ${$addresses_type}->postcode;
             /* Check zip code format */
             if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
                 $this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
             } elseif (empty($postcode) && $country->need_zip_code) {
                 $this->errors[] = Tools::displayError('A Zip / Postal code is required.');
             } elseif ($postcode && !Validate::isPostCode($postcode)) {
                 $this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
             }
             if ($country->need_identification_number && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni')))) {
                 $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');
             } elseif (!$country->need_identification_number) {
                 ${$addresses_type}->dni = null;
             }
             if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) {
                 if (!($country = new Country(${$addresses_type}->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country)) {
                     $this->errors[] = Tools::displayError('Country is invalid');
                 }
             }
             $contains_state = isset($country) && is_object($country) ? (int) $country->contains_states : 0;
             $id_state = isset(${$addresses_type}) && is_object(${$addresses_type}) ? (int) ${$addresses_type}->id_state : 0;
             if ((Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state) {
                 $this->errors[] = Tools::displayError('This country requires you to choose a State.');
             }
         }
     }
     if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
         $this->errors[] = Tools::displayError('Invalid date of birth');
     }
     if (!count($this->errors)) {
         if (Customer::customerExists(Tools::getValue('email'))) {
             $this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false);
         }
         $this->processCustomerNewsletter($customer);
         $customer->birthday = empty($_POST['years']) ? '' : (int) Tools::getValue('years') . '-' . (int) Tools::getValue('months') . '-' . (int) Tools::getValue('days');
         if (!Validate::isBirthDate($customer->birthday)) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         }
         if (!count($this->errors)) {
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:67,代码来源:AuthController.php

示例9: _update_configuration

 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_STORE_DISPLAY_FOOTER':
         case 'PS_STORE_DISPLAY_SITEMAP':
         case 'PS_STORE_SIMPLIFIED':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_STORES_CENTER_LAT':
         case 'PS_STORES_CENTER_LONG':
             $validValue = Validate::isCoordinate($value);
             break;
         case 'PS_SHOP_NAME':
             $validValue = Validate::isName($value);
             break;
         case 'PS_SHOP_EMAIL':
             $validValue = Validate::isEmail($value);
             break;
         case 'PS_SHOP_DETAILS':
             $validValue = Validate::isString($value);
             break;
         case 'PS_SHOP_ADDR1':
         case 'PS_SHOP_ADDR2':
             $validValue = Validate::isAddress($value);
             break;
         case 'PS_SHOP_CODE':
             $validValue = Validate::isPostCode($value);
             break;
         case 'PS_SHOP_CITY':
             $validValue = Validate::isCityName($value);
             break;
         case 'PS_SHOP_COUNTRY_ID':
             if (Validate::isUnsignedId($value)) {
                 $obj = new Country((int) $value);
                 $validValue = Validate::isLoadedObject($obj);
             }
             break;
         case 'PS_SHOP_STATE_ID':
             $validValue = Validate::isUnsignedId($value);
             break;
         case 'PS_SHOP_PHONE':
         case 'PS_SHOP_FAX':
             $validValue = Validate::isPhoneNumber($value);
             break;
         default:
             $interface->error("Configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("value '{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated '{$key}' configuration");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:59,代码来源:stores.php

示例10: validatePostcodeCSVColumn

 private function validatePostcodeCSVColumn($postcodes_data, $postcodes_data_count, $column)
 {
     $wrong_lines = array();
     for ($i = 0; $i < $postcodes_data_count; $i++) {
         switch ($column) {
             case DpdGroupPostcode::COLUMN_ID_POSTCODE:
                 if (!Validate::isUnsignedId($postcodes_data[$i][DpdGroupPostcode::COLUMN_ID_POSTCODE])) {
                     $wrong_lines[] = $i + self::DEFAULT_FIRST_LINE_INDEX;
                 }
                 break;
             case DpdGroupPostcode::COLUMN_REGION:
                 if (!Validate::isCityName($postcodes_data[$i][DpdGroupPostcode::COLUMN_REGION])) {
                     $wrong_lines[] = $i + self::DEFAULT_FIRST_LINE_INDEX;
                 }
                 break;
             case DpdGroupPostcode::COLUMN_POSTCODE:
                 if (!Validate::isPostCode($postcodes_data[$i][DpdGroupPostcode::COLUMN_POSTCODE])) {
                     $wrong_lines[] = $i + self::DEFAULT_FIRST_LINE_INDEX;
                 }
                 break;
             case DpdGroupPostcode::COLUMN_CITY:
                 if (!Validate::isCityName($postcodes_data[$i][DpdGroupPostcode::COLUMN_CITY])) {
                     $wrong_lines[] = $i + self::DEFAULT_FIRST_LINE_INDEX;
                 }
                 break;
             case DpdGroupPostcode::COLUMN_ADDRESS:
                 if (!Validate::isCityName($postcodes_data[$i][DpdGroupPostcode::COLUMN_ADDRESS])) {
                     $wrong_lines[] = $i + self::DEFAULT_FIRST_LINE_INDEX;
                 }
                 break;
         }
     }
     return empty($wrong_lines) ? true : implode(', ', $wrong_lines);
 }
开发者ID:remixaz,项目名称:dpdgroup,代码行数:34,代码来源:Postcode.controller.php

示例11: preProcess

 public function preProcess()
 {
     parent::preProcess();
     if ($back = Tools::getValue('back')) {
         self::$smarty->assign('back', Tools::safeOutput($back));
     }
     if ($mod = Tools::getValue('mod')) {
         self::$smarty->assign('mod', Tools::safeOutput($mod));
     }
     if (Tools::isSubmit('ajax') && Tools::isSubmit('type')) {
         if (Tools::getValue('type') == 'delivery') {
             $id_address = isset(self::$cart->id_address_delivery) ? (int) self::$cart->id_address_delivery : 0;
         } elseif (Tools::getValue('type') == 'invoice') {
             $id_address = (isset(self::$cart->id_address_invoice) and self::$cart->id_address_invoice != self::$cart->id_address_delivery) ? (int) self::$cart->id_address_invoice : 0;
         } else {
             exit;
         }
     } else {
         $id_address = (int) Tools::getValue('id_address', 0);
     }
     if ($id_address) {
         $this->_address = new Address((int) $id_address);
         if (Validate::isLoadedObject($this->_address) && Customer::customerHasAddress((int) self::$cookie->id_customer, (int) $id_address)) {
             if (Tools::isSubmit('delete')) {
                 if (self::$cart->id_address_invoice == $this->_address->id) {
                     unset(self::$cart->id_address_invoice);
                 }
                 if (self::$cart->id_address_delivery == $this->_address->id) {
                     unset(self::$cart->id_address_delivery);
                 }
                 if ($this->_address->delete()) {
                     Tools::redirect('addresses.php');
                 }
                 $this->errors[] = Tools::displayError('This address cannot be deleted.');
             }
             self::$smarty->assign(array('address' => $this->_address, 'id_address' => (int) $id_address));
         } elseif (Tools::isSubmit('ajax')) {
             exit;
         } else {
             Tools::redirect('addresses.php');
         }
     }
     if (Tools::isSubmit('submitAddress')) {
         $address = new Address();
         $this->errors = $address->validateControler();
         $address->id_customer = (int) self::$cookie->id_customer;
         if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')) {
             $this->errors[] = Tools::displayError('You must register at least one phone number');
         }
         if (!($country = new Country((int) $address->id_country)) or !Validate::isLoadedObject($country)) {
             die(Tools::displayError());
         }
         /* US customer: normalize the address */
         if ($address->id_country == Country::getByIso('US') && Configuration::get('PS_TAASC')) {
             include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php';
             $normalize = new AddressStandardizationSolution();
             $address->address1 = $normalize->AddressLineStandardization($address->address1);
             $address->address2 = $normalize->AddressLineStandardization($address->address2);
         }
         $postcode = Tools::getValue('postcode');
         /* Check zip code format */
         if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
             $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)));
         } elseif (empty($postcode) && $country->need_zip_code) {
             $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.');
         } elseif ($postcode && !Validate::isPostCode($postcode)) {
             $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.');
         }
         if ($country->isNeedDni() and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) {
             $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
         } elseif (!$country->isNeedDni()) {
             $address->dni = NULL;
         }
         if (Configuration::get('PS_TOKEN_ENABLE') == 1 and strcmp(Tools::getToken(false), Tools::getValue('token')) and self::$cookie->isLogged(true) === true) {
             $this->errors[] = Tools::displayError('Invalid token');
         }
         if ((int) $country->contains_states and !(int) $address->id_state) {
             $this->errors[] = Tools::displayError('This country requires a state selection.');
         }
         if (!sizeof($this->errors)) {
             if (isset($id_address)) {
                 $country = new Country((int) $address->id_country);
                 if (Validate::isLoadedObject($country) and !$country->contains_states) {
                     $address->id_state = 0;
                 }
                 $address_old = new Address((int) $id_address);
                 if (Validate::isLoadedObject($address_old) and Customer::customerHasAddress((int) self::$cookie->id_customer, (int) $address_old->id)) {
                     if ($address_old->isUsed()) {
                         $address_old->delete();
                         if (!Tools::isSubmit('ajax')) {
                             $to_update = false;
                             if (self::$cart->id_address_invoice == $address_old->id) {
                                 $to_update = true;
                                 self::$cart->id_address_invoice = 0;
                             }
                             if (self::$cart->id_address_delivery == $address_old->id) {
                                 $to_update = true;
                                 self::$cart->id_address_delivery = 0;
                             }
                             if ($to_update) {
//.........这里部分代码省略.........
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:101,代码来源:AddressController.php

示例12: disableUsesAddress

 public static function disableUsesAddress($order)
 {
     if (Validate::isLoadedObject($order)) {
         $address = new Address((int) $order->id_address_delivery);
         if (Validate::isLoadedObject($address)) {
             $default_address = Configuration::getMultiple(array('SHIPTOMYID_DEFAULT_ADDR_ADDRESS', 'SHIPTOMYID_DEFAULT_ADDR_ADDRESS2', 'SHIPTOMYID_DEFAULT_ADDR_CITY', 'SHIPTOMYID_DEFAULT_ADDR_POSTCODE', 'SHIPTOMYID_DEFAULT_ADDR_COUNTRY', 'SHIPTOMYID_DEFAULT_ADDR_STATE', 'SHIPTOMYID_DEFAULT_ADDR_PHONE', 'SHIPTOMYID_DEFAULT_ADDR_ALIAS'));
             if (Validate::isAddress($default_address['SHIPTOMYID_DEFAULT_ADDR_ADDRESS'])) {
                 $address->address1 = Tools::substr($default_address['SHIPTOMYID_DEFAULT_ADDR_ADDRESS'], 0, 128);
             }
             if (Validate::isAddress($default_address['SHIPTOMYID_DEFAULT_ADDR_ADDRESS2'])) {
                 $address->address2 = Tools::substr($default_address['SHIPTOMYID_DEFAULT_ADDR_ADDRESS2'], 0, 128);
             }
             if (Validate::isCityName($default_address['SHIPTOMYID_DEFAULT_ADDR_CITY'])) {
                 $address->city = Tools::substr($default_address['SHIPTOMYID_DEFAULT_ADDR_CITY'], 0, 64);
             }
             if (Validate::isPostCode($default_address['SHIPTOMYID_DEFAULT_ADDR_POSTCODE'])) {
                 $address->postcode = Tools::substr($default_address['SHIPTOMYID_DEFAULT_ADDR_POSTCODE'], 0, 12);
             }
             if (Validate::isPhoneNumber($default_address['SHIPTOMYID_DEFAULT_ADDR_PHONE'])) {
                 $address->phone = Tools::substr($default_address['SHIPTOMYID_DEFAULT_ADDR_PHONE'], 0, 32);
             }
             $address->id_country = (int) $default_address['SHIPTOMYID_DEFAULT_ADDR_COUNTRY'];
             $address->id_state = (int) $default_address['SHIPTOMYID_DEFAULT_ADDR_STATE'];
             $address->update();
         }
     }
     Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'address SET deleted = 1 WHERE id_address = ' . (int) $order->id_address_delivery);
 }
开发者ID:ac3gam3r,项目名称:Maxokraft,代码行数:28,代码来源:ShiptomyidOrder.php

示例13: processSave

 public function processSave()
 {
     $hotel_id = Tools::getValue('hotel_id');
     $hotel_name = Tools::getValue('hotel_name');
     $phone = Tools::getValue('phone');
     $email = Tools::getValue('email');
     $check_in = Tools::getValue('check_in');
     $check_out = Tools::getValue('check_out');
     $short_description = Tools::getValue('short_description');
     $description = Tools::getValue('description');
     $rating = Tools::getValue('hotel_rating');
     $city = Tools::getValue('hotel_city');
     $state = Tools::getValue('hotel_state');
     $country = Tools::getValue('hotel_country');
     $policies = Tools::getValue('hotel_policies');
     $zipcode = Tools::getValue('hotel_postal_code');
     $address = Tools::getValue('address');
     $active = Tools::getValue('ENABLE_HOTEL');
     if ($hotel_name == '') {
         $this->errors[] = Tools::displayError('Hotel name is required field.');
     } else {
         if (!Validate::isGenericName($hotel_name)) {
             $this->errors[] = Tools::displayError($this->l('Hotel name must not have Invalid characters <>;=#{}'));
         }
     }
     if (!$phone) {
         $this->errors[] = Tools::displayError('Phone number is required field.');
     } else {
         if (!Validate::isPhoneNumber($phone)) {
             $this->errors[] = Tools::displayError('Please enter a valid phone number.');
         }
     }
     if ($email == '') {
         $this->errors[] = Tools::displayError('Email is required field.');
     } else {
         if (!Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Please enter a valid email.');
         }
     }
     if ($check_in == '') {
         $this->errors[] = Tools::displayError('Check In time is required field.');
     }
     if ($check_out == '') {
         $this->errors[] = Tools::displayError('Check Out Time is required field.');
     }
     if ($zipcode == '') {
         $this->errors[] = Tools::displayError('Postal Code is required field.');
     } else {
         if (!Validate::isPostCode($zipcode)) {
             $this->errors[] = Tools::displayError('Enter a Valid Postal Code.');
         }
     }
     if (!$rating) {
         $this->errors[] = Tools::displayError('Rating is required field.');
     }
     if ($address == '') {
         $this->errors[] = Tools::displayError('Address is required field.');
     }
     if (!$country) {
         $this->errors[] = Tools::displayError('Country is required field.');
     }
     if (!$state) {
         $this->errors[] = Tools::displayError('State is required field.');
     }
     if ($city == '') {
         $this->errors[] = Tools::displayError('City is required field.');
     } else {
         if (!Validate::isCityName($city)) {
             $this->errors[] = Tools::displayError('Enter a Valid City Name.');
         }
     }
     //validate hotel main image
     if (isset($_FILES['hotel_image']) && $_FILES['hotel_image']['name']) {
         $obj_htl_img = new HotelImage();
         $error = $obj_htl_img->validAddHotelMainImage($_FILES['hotel_image']);
         if ($error) {
             $this->errors[] = Tools::displayError('<strong>' . $_FILES['hotel_image']['name'] . '</strong> : Image format not recognized, allowed formats are: .gif, .jpg, .png', false);
         }
     }
     //validate Hotel's other images
     if (isset($_FILES['images']) && $_FILES['images']) {
         $obj_htl_img = new HotelImage();
         $error = $obj_htl_img->validAddHotelOtherImage($_FILES['images']);
         if ($error) {
             $this->errors[] = Tools::displayError('<strong>' . $_FILES['hotel_image']['name'] . '</strong> : Image format not recognized, allowed formats are: .gif, .jpg, .png', false);
         }
     }
     if (!count($this->errors)) {
         if ($hotel_id) {
             $obj_hotel_info = new HotelBranchInformation($hotel_id);
         } else {
             $obj_hotel_info = new HotelBranchInformation();
         }
         if ($obj_hotel_info) {
             if (!$active) {
                 $obj_htl_rm_info = new HotelRoomType();
                 $ids_product = $obj_htl_rm_info->getIdProductByHotelId($obj_hotel_info->id);
                 if (isset($ids_product) && $ids_product) {
                     foreach ($ids_product as $key_prod => $value_prod) {
                         $obj_product = new Product($value_prod['id_product']);
//.........这里部分代码省略.........
开发者ID:Rohit-jn,项目名称:hotelcommerce,代码行数:101,代码来源:AdminAddHotelController.php

示例14: postProcess

 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table])) {
         /* Cleaning fields */
         foreach ($_POST as $kp => $vp) {
             $_POST[$kp] = trim($vp);
         }
         /* If the selected country does not contain states */
         $id_state = (int) Tools::getValue('id_state');
         if ($id_country = Tools::getValue('id_country') and $country = new Country((int) $id_country) and !(int) $country->contains_states and $id_state) {
             $this->_errors[] = Tools::displayError('You have selected a state for a country that does not contain states.');
         }
         /* If the selected country contains states, then a state have to be selected */
         if ((int) $country->contains_states and !$id_state) {
             $this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
         }
         $latitude = (double) Tools::getValue('latitude');
         $longitude = (double) Tools::getValue('longitude');
         if (empty($latitude) or empty($longitude)) {
             $this->_errors[] = Tools::displayError('Latitude and longitude are required.');
         }
         $postcode = Tools::getValue('postcode');
         /* Check zip code format */
         if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
             $this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)));
         } elseif (empty($postcode) && $country->need_zip_code) {
             $this->_errors[] = Tools::displayError('Postcode required.');
         } elseif ($postcode && !Validate::isPostCode($postcode)) {
             $this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.');
         }
         /* Store hours */
         $_POST['hours'] = array();
         for ($i = 1; $i < 8; $i++) {
             $_POST['hours'][] .= Tools::getValue('hours_' . (int) $i);
         }
         $_POST['hours'] = serialize($_POST['hours']);
     }
     if (!sizeof($this->_errors)) {
         parent::postProcess();
     }
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:41,代码来源:AdminStores.php

示例15: _postProcess

    private function _postProcess()
    {
        $errors = array();
        if (Tools::isSubmit('submitSecuvadEdit')) {
            return false;
        }
        if (Tools::isSubmit('submitSecuvadConfiguration')) {
            if (Tools::getValue('forme') != 'SARL' and Tools::getValue('forme') != 'SA' and Tools::getValue('forme') != 'EURL' and Tools::getValue('forme') != 'SAS' and Tools::getValue('forme') != 'Entreprise individuelle' and Tools::getValue('forme') != 'SNC') {
                $errors[] = $this->l('Company type is invalid');
            }
            if (Tools::getValue('societe') == NULL or !Validate::isName(Tools::getValue('societe'))) {
                $errors[] = $this->l('Company name is invalid');
            }
            if (Tools::getValue('capital') != NULL and !Validate::isGenericName(Tools::getValue('capital'))) {
                $errors[] = $this->l('Capital is invalid');
            }
            if (Tools::getValue('web_site') == NULL or !Validate::isUrl(Tools::getValue('web_site'))) {
                $errors[] = $this->l('WebSite is invalid');
            }
            if (Tools::getValue('address') != NULL and !Validate::isAddress(Tools::getValue('address'))) {
                $errors[] = $this->l('Address is invalid');
            }
            if (Tools::getValue('code_postal') != NULL and !Validate::isPostCode(Tools::getValue('code_postal'))) {
                $errors[] = $this->l('Zip/ Postal Code is invalid');
            }
            if (Tools::getValue('ville') != NULL and !Validate::isCityName(Tools::getValue('ville'))) {
                $errors[] = $this->l('City is invalid');
            }
            if (Tools::getValue('pays') != NULL and !Validate::isCountryName(Tools::getValue('pays'))) {
                $errors[] = $this->l('Country is invalid');
            }
            if (Tools::getValue('rcs') != NULL and !Validate::isGenericName(Tools::getValue('rcs'))) {
                $errors[] = $this->l('RCS is invalid');
            }
            if (Tools::getValue('siren') != NULL and !Validate::isGenericName(Tools::getValue('siren'))) {
                $errors[] = $this->l('Siren is invalid');
            }
            if (!is_array(Tools::getValue('categories')) or !sizeof(Tools::getValue('categories'))) {
                $errors[] = $this->l('You must select at least one category.');
            }
            if (Tools::getValue('civilite') != 'M' and Tools::getValue('civilite') != 'Mme' and Tools::getValue('civilite') != 'Mlle') {
                $errors[] = $this->l('Title is invalid');
            }
            if (Tools::getValue('nom') == NULL or !Validate::isName(Tools::getValue('nom'))) {
                $errors[] = $this->l('Last name is invalid');
            }
            if (Tools::getValue('prenom') == NULL or !Validate::isName(Tools::getValue('prenom'))) {
                $errors[] = $this->l('First name is invalid');
            }
            if (Tools::getValue('fonction') != NULL and !Validate::isGenericName(Tools::getValue('fonction'))) {
                $errors[] = $this->l('Function name is invalid');
            }
            if (Tools::getValue('email') == NULL or !Validate::isEmail(Tools::getValue('email'))) {
                $errors[] = $this->l('E-mail name is invalid');
            }
            if (Tools::getValue('telephone') == NULL or !Validate::isPhoneNumber(Tools::getValue('telephone'))) {
                $errors[] = $this->l('Telephone is invalid');
            }
            if (!sizeof($errors)) {
                return true;
            } else {
                $this->_html .= $this->displayError(implode('<br />', $errors));
                return false;
            }
        }
        if (Tools::isSubmit('submitSecuvadPostConfiguration')) {
            $errors = array();
            if (!Validate::isGenericName(Tools::getValue('secuvad_login'))) {
                $errors[] = $this->l('Invalid login');
            }
            if (!Validate::isGenericName(Tools::getValue('secuvad_password'))) {
                $errors[] = $this->l('Invalid password');
            }
            if (!in_array(Tools::getValue('secuvad_mode'), $this->_allowed_modes)) {
                $errors[] = $this->l('Invalid Mode');
            }
            if (!Validate::isInt(Tools::getValue('secuvad_id'))) {
                $errors[] = $this->l('Invalid ID');
            }
            if (!sizeof($errors)) {
                // update configuration
                Configuration::updateValue('SECUVAD_LOGIN', Tools::getValue('secuvad_login'));
                Configuration::updateValue('SECUVAD_MDP', Tools::getValue('secuvad_password'));
                Configuration::updateValue('SECUVAD_MODE', Tools::getValue('secuvad_mode'));
                Configuration::updateValue('SECUVAD_ID', Tools::getValue('secuvad_id'));
                Configuration::updateValue('SECUVAD_ACTIVATION', 1);
                $this->_html .= $this->displayConfirmation($this->l('Settings are updated') . '<img src="http://www.prestashop.com/modules/secuvad.png?id=' . urlencode(Tools::getValue('secuvad_id')) . '&login=' . urlencode(Tools::getValue('secuvad_login')) . '&mode=' . (Tools::getValue('secuvad_mode') == 'TEST' ? 0 : 1) . '" style="float:right" />');
            } else {
                $this->_html .= $this->displayError(implode('<br />', $errors));
            }
        }
        if (Tools::isSubmit('submitSecuvadCategory')) {
            Db::getInstance()->Execute('
			DELETE FROM `' . _DB_PREFIX_ . 'secuvad_assoc_category`
			');
            $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'secuvad_assoc_category` VALUES';
            foreach ($_POST as $k => $category_id) {
                if (preg_match('/secuvad_cat_([0-9]+)$/Ui', $k, $result)) {
                    $id_category = $result[1];
                    $sql .= '(NULL, ' . (int) $id_category . ', ' . (int) $category_id . '),';
//.........这里部分代码省略.........
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:101,代码来源:secuvad.php


注:本文中的Validate::isPostCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。