本文整理汇总了PHP中Validate::isName方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isName方法的具体用法?PHP Validate::isName怎么用?PHP Validate::isName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processProductTabContent
public function processProductTabContent()
{
if (Tools::isSubmit('mymod_pc_submit_comment')) {
$id_product = Tools::getValue('id_product');
$firstname = Tools::getValue('firstname');
$lastname = Tools::getValue('lastname');
$email = Tools::getValue('email');
$grade = Tools::getValue('grade');
$comment = Tools::getValue('comment');
if (!Validate::isName($firstname) || !Validate::isName($lastname) || !Validate::isEmail($email)) {
$this->context->smarty->assign('new_comment_posted', 'error');
return false;
}
$MyModComment = new MyModComment();
$MyModComment->id_shop = (int) $this->context->shop->id;
$MyModComment->id_product = (int) $id_product;
$MyModComment->firstname = $firstname;
$MyModComment->lastname = $lastname;
$MyModComment->email = $email;
$MyModComment->grade = (int) $grade;
$MyModComment->comment = nl2br($comment);
$MyModComment->add();
$this->context->smarty->assign('new_comment_posted', 'success');
$this->module->smartyClearCache('displayProductTabContent.tpl', $this->cache_id);
}
}
示例2: _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}'");
}
}
示例3: isValidName
public function isValidName($name)
{
$isName = Validate::isName($name);
$isShortName = $this->isShortName($name);
$isNameLikeAnUrl = $this->isNameLikeAnUrl($name);
$isValidName = $isName && $isShortName && !$isNameLikeAnUrl;
return $isValidName;
}
示例4: 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));
}
}
}
示例5: displayFrontForm
public function displayFrontForm()
{
global $smarty;
$error = false;
$confirm = false;
if (isset($_POST['submitAddtoafriend'])) {
global $cookie, $link;
/* Product informations */
$product = new Product((int) Tools::getValue('id_product'), false, (int) $cookie->id_lang);
$productLink = $link->getProductLink($product);
/* Fields verifications */
if (empty($_POST['email']) or empty($_POST['name'])) {
$error = $this->l('You must fill in all fields.');
} elseif (empty($_POST['email']) or !Validate::isEmail($_POST['email'])) {
$error = $this->l('The e-mail given is invalid.');
} elseif (!Validate::isName($_POST['name'])) {
$error = $this->l('The name given is invalid.');
} elseif (!isset($_GET['id_product']) or !is_numeric($_GET['id_product'])) {
$error = $this->l('An error occurred during the process.');
} else {
/* Email generation */
$subject = ($cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend')) . ' ' . $this->l('sent you a link to') . ' ' . $product->name;
$templateVars = array('{product}' => $product->name, '{product_link}' => $productLink, '{customer}' => $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend'), '{name}' => Tools::safeOutput($_POST['name']));
/* Email sending */
if (!Mail::Send((int) $cookie->id_lang, 'send_to_a_friend', Mail::l('A friend sent you a link to') . ' ' . $product->name, $templateVars, $_POST['email'], NULL, $cookie->email ? $cookie->email : NULL, $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : NULL, NULL, NULL, dirname(__FILE__) . '/mails/')) {
$error = $this->l('An error occurred during the process.');
} else {
Tools::redirect(_MODULE_DIR_ . '/' . $this->name . '/sendtoafriend-form.php?id_product=' . $product->id . '&submited');
}
}
} else {
global $cookie, $link;
/* Product informations */
$product = new Product((int) Tools::getValue('id_product'), false, (int) $cookie->id_lang);
$productLink = $link->getProductLink($product);
}
/* Image */
$images = $product->getImages((int) $cookie->id_lang);
foreach ($images as $k => $image) {
if ($image['cover']) {
$cover['id_image'] = (int) $product->id . '-' . (int) $image['id_image'];
$cover['legend'] = $image['legend'];
}
}
if (!isset($cover)) {
$cover = array('id_image' => Language::getIsoById((int) $cookie->id_lang) . '-default', 'legend' => 'No picture');
}
$smarty->assign(array('cover' => $cover, 'errors' => $error, 'confirm' => $confirm, 'product' => $product, 'productLink' => $productLink));
return $this->display(__FILE__, 'sendtoafriend.tpl');
}
示例6: validate
/**
* @see InstallAbstractModel::validate()
*/
public function validate()
{
// List of required fields
$required_fields = array('shop_name', 'shop_country', 'shop_timezone', 'admin_firstname', 'admin_lastname', 'admin_email', 'admin_password');
foreach ($required_fields as $field) {
if (!$this->session->{$field}) {
$this->errors[$field] = $this->l('Field required');
}
}
// Check shop name
if ($this->session->shop_name && !Validate::isGenericName($this->session->shop_name)) {
$this->errors['shop_name'] = $this->l('Invalid shop name');
}
// Check admin name
if ($this->session->admin_firstname && !Validate::isName($this->session->admin_firstname)) {
$this->errors['admin_firstname'] = $this->l('Your firstname contains some invalid characters');
}
if ($this->session->admin_lastname && !Validate::isName($this->session->admin_lastname)) {
$this->errors['admin_lastname'] = $this->l('Your lastname contains some invalid characters');
}
// Check passwords
if ($this->session->admin_password) {
if (!Validate::isPasswdAdmin($this->session->admin_password)) {
$this->errors['admin_password'] = $this->l('The password is incorrect (alphanumeric string with at least 8 characters)');
} else {
if ($this->session->admin_password != $this->session->admin_password_confirm) {
$this->errors['admin_password'] = $this->l('Password and its confirmation are different');
}
}
}
// Check email
if ($this->session->admin_email && !Validate::isEmail($this->session->admin_email)) {
$this->errors['admin_email'] = $this->l('This e-mail address is invalid');
}
return count($this->errors) ? false : true;
}
示例7:
if (isset($_GET['infosEmail']) and !Validate::isEmail($_GET['infosEmail'])) {
$error['infosEmail'] = '3';
} else {
$error['infosEmail'] = '';
}
if (isset($_GET['infosShop']) and !Validate::isGenericName($_GET['infosShop'])) {
$error['validateShop'] = '46';
} else {
$error['validateShop'] = '';
}
if (isset($_GET['infosFirstname']) and !Validate::isName($_GET['infosFirstname'])) {
$error['validateFirstname'] = '47';
} else {
$error['validateFirstname'] = '';
}
if (isset($_GET['infosName']) and !Validate::isName($_GET['infosName'])) {
$error['validateName'] = '48';
} else {
$error['validateName'] = '';
}
if (isset($_GET['catalogMode']) and !Validate::isInt($_GET['catalogMode'])) {
$error['validateCatalogMode'] = '52';
} else {
$error['validateCatalogMode'] = '';
}
if (!isset($_GET['infosEmail']) or empty($_GET['infosEmail'])) {
$error['infosEmail'] = '0';
}
if (!isset($_GET['infosPassword']) or empty($_GET['infosPassword'])) {
$error['infosPassword'] = '0';
} else {
示例8: QuickOrder
public $active = true;
}
$context = Context::getContext();
$quickorder = new QuickOrder();
if (Tools::isSubmit('submitQorder')) {
$errors = array();
if (!Validate::isLoadedObject($context->cart)) {
$errors[] = $quickorder->l('Cart not found', 'ajax');
}
if (Cart::getNbProducts($context->cart->id) <= 0) {
$errors[] = $quickorder->l('You must add minimum 1 quantity', 'ajax');
}
if (!Tools::getValue('phone') || !Validate::isPhoneNumber(Tools::getValue('phone'))) {
$errors[] = $quickorder->l('You must register at least one phone number', 'ajax');
}
if (!Tools::getValue('firstname') || !Validate::isName(Tools::getValue('firstname'))) {
$errors[] = $quickorder->l('Name is empty or contains error', 'ajax');
}
if (!Tools::getValue('time')) {
$errors[] = $quickorder->l('Time is empty or contains error', 'ajax');
}
if (!empty($errors)) {
die(Tools::jsonEncode(array('hasError' => true, 'errors' => $errors)));
} else {
if (Configuration::get('QUI_CREATE_ORDER')) {
if (!$context->customer->isLogged()) {
$customer = new Customer();
$customer->passwd = md5(time() . _COOKIE_KEY_);
$customer->firstname = Tools::getValue('firstname');
$customer->lastname = ' ';
$customer->email = 'default@default.ru';
示例9: array
$activeTab = 'sponsor';
if (!Tools::getValue('conditionsValided')) {
$error = 'conditions not valided';
} else {
$friendsLastName = Tools::getValue('friendsLastName');
$friendsFirstName = Tools::getValue('friendsFirstName');
$mails_exists = array();
foreach ($friendsEmail as $key => $friendEmail) {
$friendEmail = strval($friendEmail);
$friendLastName = strval($friendsLastName[$key]);
$friendFirstName = strval($friendsFirstName[$key]);
if (empty($friendEmail) and empty($friendLastName) and empty($friendFirstName)) {
continue;
} elseif (empty($friendEmail) or !Validate::isEmail($friendEmail)) {
$error = 'email invalid';
} elseif (empty($friendFirstName) or empty($friendLastName) or !Validate::isName($friendLastName) or !Validate::isName($friendFirstName)) {
$error = 'name invalid';
} elseif (ReferralProgramModule::isEmailExists($friendEmail) or Customer::customerExists($friendEmail)) {
$mails_exists[] = $friendEmail;
} else {
$referralprogram = new ReferralProgramModule();
$referralprogram->id_sponsor = (int) $cookie->id_customer;
$referralprogram->firstname = $friendFirstName;
$referralprogram->lastname = $friendLastName;
$referralprogram->email = $friendEmail;
if (!$referralprogram->validateFields(false)) {
$error = 'name invalid';
} else {
if ($referralprogram->save()) {
if (Configuration::get('PS_CIPHER_ALGORITHM')) {
$cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
示例10: signIn
function signIn($POSTdata)
{
//Init variables
$unick = trim($POSTdata['playernick']);
$upass = trim($POSTdata['playerpassword']);
$umail = trim($POSTdata['playermail']);
$data = array();
$output = array();
//Check password copy
if ($upass != $POSTdata['playerpasswordcpy']) {
print 1;
exit;
}
$check = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'users WHERE playermail = "' . mysql_escape_string($umail) . '" LIMIT 1');
if (sizeof($check) >= 1) {
print 2;
die;
}
$error = array();
if (!Validate::isName($unick)) {
$error[] = 'Invalid nickname';
}
if (!Validate::isPasswd($upass)) {
$error[] = 'Invalid password';
}
if (!Validate::isEmail($umail)) {
$error[] = 'Invalid email';
}
//Validate
if (sizeof($error)) {
print 0;
die;
}
/*
==========================
2° step : save data
===========================
*/
Db::q('INSERT INTO ' . _DB_PREFIX_ . 'users (playernick, playermail, playerpassword) VALUES("' . mysql_real_escape_string($unick) . '", "' . mysql_real_escape_string($umail) . '", "' . md5($upass) . '")');
$check = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'users WHERE playermail = "' . mysql_real_escape_string($umail) . '"');
if (!sizeof($check)) {
print 0;
die;
}
Db::q('INSERT INTO ' . _DB_PREFIX_ . 'points
(id_player, points)
VALUES("' . $check[0]['id'] . '", "0")');
//Initialize saves data
Db::q('INSERT INTO ' . _DB_PREFIX_ . 'saves
(id_player, points, level, health, inventary)
VALUES("' . $check[0]['id'] . '", "0", "1", "100", 0)');
print 3;
die;
}
示例11: addDPDClientNumber
public function addDPDClientNumber()
{
$number = Tools::getValue('client_number');
$name = Tools::getValue('name');
$id_shop = (int) Tools::getValue('id_shop', Context::getContext()->shop->id);
$error = '';
$success = '';
if (!$number) {
$error .= $this->l('DPD client number is required') . '<br />';
} elseif (!ctype_alnum($number)) {
$error .= $this->l('DPD client number is not valid') . '<br />';
}
if (!$name) {
$error .= $this->l('Client name is required') . '<br />';
} elseif (!Validate::isName($name)) {
$error .= $this->l('Client name is not valid') . '<br />';
}
if (empty($error)) {
require_once _DPDPOLAND_CLASSES_DIR_ . 'PayerNumber.php';
if (DpdPolandPayerNumber::payerNumberExists($number, $id_shop)) {
$error .= $this->l('DPD client number already exists') . '<br />';
} else {
$payer_number_obj = new DpdPolandPayerNumber();
$payer_number_obj->payer_number = $number;
$payer_number_obj->name = $name;
$payer_number_obj->id_shop = $id_shop;
if (!$payer_number_obj->save()) {
$error .= $this->l('DPD client number / name could not be saved') . '<br />';
}
}
}
$success = $this->l('DPD client number / name saved successfully');
$return = array('error' => $error, 'message' => $success);
return $return;
}
示例12: _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 . '),';
//.........这里部分代码省略.........
示例13: processAccountRequestForm
private function processAccountRequestForm()
{
if (!Tools::isSubmit('submit_account_request')) {
return false;
}
// Check inputs validity
if (Tools::isEmpty(Tools::getValue('lastname')) || !Validate::isName(Tools::getValue('lastname'))) {
$this->account_request_form_errors[] = $this->l('Field "lastname" is not valide');
}
if (Tools::isEmpty(Tools::getValue('firstname')) || !Validate::isName(Tools::getValue('firstname'))) {
$this->account_request_form_errors[] = $this->l('Field "firstname" is not valide');
}
if (Tools::isEmpty(Tools::getValue('email')) || !Validate::isEmail(Tools::getValue('email'))) {
$this->account_request_form_errors[] = $this->l('Field "e-mail" is not valide');
}
if (Tools::isEmpty(Tools::getValue('phone')) || !Validate::isPhoneNumber(Tools::getValue('phone'))) {
$this->account_request_form_errors[] = $this->l('Field "phone number" is not valide');
}
if (Tools::isEmpty(Tools::getValue('shop_name')) || !Validate::isGenericName(Tools::getValue('shop_name'))) {
$this->account_request_form_errors[] = $this->l('Field "shop name" is not valide');
}
if (!is_numeric(Tools::getValue('packages_per_year')) || Tools::getValue('packages_per_year') <= 0) {
$this->account_request_form_errors[] = $this->l('Field "packages per year" is not valide');
}
if (!is_numeric(Tools::getValue('package_weight')) || Tools::getValue('package_weight') <= 0) {
$this->account_request_form_errors[] = $this->l('Field "average weight of a package" is not valide');
}
// Validation error dont send mail
if (count($this->account_request_form_errors)) {
return false;
}
return true;
}
示例14: validate
/**
* @see InstallAbstractModel::validate()
*/
public function validate()
{
// List of required fields
$required_fields = array('shop_name', 'shop_country', 'shop_timezone', 'admin_firstname', 'admin_lastname', 'admin_email', 'admin_password');
foreach ($required_fields as $field) {
if (!$this->session->{$field}) {
$this->errors[$field] = $this->translator->trans('Field required', array(), 'Install');
}
}
// Check shop name
if ($this->session->shop_name && !Validate::isGenericName($this->session->shop_name)) {
$this->errors['shop_name'] = $this->translator->trans('Invalid shop name', array(), 'Install');
} elseif (strlen($this->session->shop_name) > 64) {
$this->errors['shop_name'] = $this->translator->trans('The field %shop_name% is limited to %limit% characters', array('limit' => 64, 'shop_name' => $this->translator->trans('shop name', array(), 'Install')), 'Install');
}
// Check admin name
if ($this->session->admin_firstname && !Validate::isName($this->session->admin_firstname)) {
$this->errors['admin_firstname'] = $this->translator->trans('Your firstname contains some invalid characters', array(), 'Install');
} elseif (strlen($this->session->admin_firstname) > 32) {
$this->errors['admin_firstname'] = $this->translator->trans('The field %field% is limited to %d characters', array('field' => $this->translator->trans('firstname', array(), 'Install'), 'limit' => 32), 'Install');
}
if ($this->session->admin_lastname && !Validate::isName($this->session->admin_lastname)) {
$this->errors['admin_lastname'] = $this->translator->trans('Your lastname contains some invalid characters');
} elseif (strlen($this->session->admin_lastname) > 32) {
$this->errors['admin_lastname'] = $this->translator->trans('The field %s is limited to %d characters', array('%field%' => $this->translator->trans('lastname', array(), 'Install'), '%limit%' => 32), 'Install');
}
// Check passwords
if ($this->session->admin_password) {
if (!Validate::isPasswdAdmin($this->session->admin_password)) {
$this->errors['admin_password'] = $this->translator->trans('The password is incorrect (alphanumeric string with at least 8 characters)', array(), 'Install');
} elseif ($this->session->admin_password != $this->session->admin_password_confirm) {
$this->errors['admin_password'] = $this->translator->trans('Password and its confirmation are different', array(), 'Install');
}
}
// Check email
if ($this->session->admin_email && !Validate::isEmail($this->session->admin_email)) {
$this->errors['admin_email'] = $this->translator->trans('This e-mail address is invalid', array(), 'Install');
}
return count($this->errors) ? false : true;
}
示例15: displayFrontForm
public function displayFrontForm()
{
global $smarty, $cookie, $link;
session_start();
$errors = array();
$product = new Product((int) Tools::getValue('id_product'), false, (int) $cookie->id_lang);
$productlink = $link->getProductLink($product);
include_once dirname(__FILE__) . '/securimage/securimage.php';
$securimage = new Securimage();
$valid = $securimage->check($code = Tools::getValue('captcha_code'));
if (Tools::isSubmit('submitAskMoreInfoFront')) {
$message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
if (!($name = Tools::getValue('name')) && !$cookie->isLogged()) {
$errors[] = $this->l('Enter your name.');
} elseif (!Validate::isName($name) && !$cookie->isLogged()) {
$errors[] = $this->l('Sorry, but the name is invalid.');
} elseif (!($email = Tools::getValue('email')) && !$cookie->isLogged()) {
$errors[] = $this->l('Enter your e-mail address.');
} elseif (!Validate::isEmail($email) && !$cookie->isLogged()) {
$errors[] = $this->l('Sorry, but the e-mail address is invalid.');
} elseif (!($message = nl2br2($message))) {
$errors[] = $this->l('Enter a message.');
} elseif (!Validate::isMessage($message)) {
$errors[] = $this->l('Sorry, but the message is invalid');
} elseif (!$code && (int) Configuration::get('ASK_CAPTCHA')) {
$errors[] = $this->l('Enter the security code.');
} elseif (!$valid && (int) Configuration::get('ASK_CAPTCHA')) {
$errors[] = $this->l('Sorry, but the security code is not right.');
} elseif (!isset($_GET['id_product']) or !is_numeric($_GET['id_product'])) {
$errors[] = $this->l('An error occurred during the process.');
} else {
$subject = ($cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A visitor')) . ' ' . $this->l('requires more information about') . ' ' . $product->name;
$templateVars = array('{product}' => $product->name, '{product_link}' => $productlink, '{customer}' => $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A visitor'), '{name}' => $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : Tools::safeOutput($name), '{email}' => $cookie->email ? $cookie->email : Tools::safeOutput($email), '{message}' => stripslashes($message));
if (Mail::Send((int) $cookie->id_lang, 'askmoreinfo', Mail::l($subject), $templateVars, Configuration::get('PS_SHOP_EMAIL'), NULL, $cookie->email ? $cookie->email : NULL, $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : NULL, NULL, NULL, dirname(__FILE__) . '/mails/')) {
$smarty->assign('confirmation', 1);
} else {
$errors[] = $this->l('Sorry, an error occurred while sending message');
}
}
}
$images = $product->getImages((int) $cookie->id_lang);
foreach ($images as $image) {
if ($image['cover']) {
$cover['id_image'] = (int) $product->id . '-' . (int) $image['id_image'];
$cover['legend'] = $image['legend'];
}
}
if (!isset($cover)) {
$cover = array('id_image' => Language::getIsoById((int) $cookie->id_lang) . '-default', 'legend' => 'No picture');
}
$smarty->assign(array('customer_logged' => $cookie->customer_firstname, 'captcha' => (int) Configuration::get('ASK_CAPTCHA') == 1 ? true : false, 'askmoreinfo_imagesize' => Image::getSize('home'), 'cover' => $cover, 'errors' => $errors, 'product' => $product, 'productlink' => $productlink));
return $this->display(__FILE__, 'maofree_askmoreinfo.tpl');
}