Схема
protected mixed
validateForm (
)
Аргументы
| Аргумент |
Возможный тип |
Описание |
|
У метода нет аргументов
|
Описание
Метод пока еще не документирован.
Исходный код
if (!$this->user->hasPermission('modify', 'sale/customer')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if ((utf8_strlen($this->request->post['firstname']) < 1) || (utf8_strlen($this->request->post['firstname']) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen($this->request->post['lastname']) < 1) || (utf8_strlen($this->request->post['lastname']) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['email']) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
$customer_info = $this->model_sale_customer->getCustomerByEmail($this->request->post['email']);
if (!isset($this->request->get['customer_id'])) {
if ($customer_info) {
$this->error['warning'] = $this->language->get('error_exists');
}
} else {
if ($customer_info && ($this->request->get['customer_id'] != $customer_info['customer_id'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
if ($this->request->post['password'] || (!isset($this->request->get['customer_id']))) {
if ((utf8_strlen($this->request->post['password']) < 4) || (utf8_strlen($this->request->post['password']) > 20)) {
$this->error['password'] = $this->language->get('error_password');
}
if ($this->request->post['password'] != $this->request->post['confirm']) {
$this->error['confirm'] = $this->language->get('error_confirm');
}
}
if (isset($this->request->post['address'])) {
foreach ($this->request->post['address'] as $key => $value) {
if ((utf8_strlen($value['firstname']) < 1) || (utf8_strlen($value['firstname']) > 32)) {
$this->error['address_firstname'][$key] = $this->language->get('error_firstname');
}
if ((utf8_strlen($value['lastname']) < 1) || (utf8_strlen($value['lastname']) > 32)) {
$this->error['address_lastname'][$key] = $this->language->get('error_lastname');
}
if ((utf8_strlen($value['address_1']) < 3) || (utf8_strlen($value['address_1']) > 128)) {
$this->error['address_address_1'][$key] = $this->language->get('error_address_1');
}
if ((utf8_strlen($value['city']) < 2) || (utf8_strlen($value['city']) > 128)) {
$this->error['address_city'][$key] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($value['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && (utf8_strlen($value['postcode']) < 2) || (utf8_strlen($value['postcode']) > 10)) {
$this->error['address_postcode'][$key] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && $value['tax_id'] && (vat_validation($country_info['iso_code_2'], $value['tax_id']) == 'invalid')) {
$this->error['address_tax_id'][$key] = $this->language->get('error_vat');
}
}
if ($value['country_id'] == '') {
$this->error['address_country'][$key] = $this->language->get('error_country');
}
if (!isset($value['zone_id']) || $value['zone_id'] == '') {
$this->error['address_zone'][$key] = $this->language->get('error_zone');
}
}
}
if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
if (!$this->error) {
return true;
} else {
return false;
}