OpenCart 🇺🇦

Схема

protected mixed validateForm ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

if (!$this->user->hasPermission('modify', 'sale/affiliate')) {
	$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');
}

$affiliate_info = $this->model_sale_affiliate->getAffiliateByEmail($this->request->post['email']);

if (!isset($this->request->get['affiliate_id'])) {
	if ($affiliate_info) {
		$this->error['warning'] = $this->language->get('error_exists');
	}
} else {
	if ($affiliate_info && ($this->request->get['affiliate_id'] != $affiliate_info['affiliate_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['affiliate_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 ((utf8_strlen($this->request->post['address_1']) < 3) || (utf8_strlen($this->request->post['address_1']) > 128)) {
	$this->error['address_1'] = $this->language->get('error_address_1');
}

if ((utf8_strlen($this->request->post['city']) < 2) || (utf8_strlen($this->request->post['city']) > 128)) {
	$this->error['city'] = $this->language->get('error_city');
}

$this->load->model('localisation/country');

$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);

if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['postcode']) < 2) || (utf8_strlen($this->request->post['postcode']) > 10)) {
	$this->error['postcode'] = $this->language->get('error_postcode');
}

if ($this->request->post['country_id'] == '') {
	$this->error['country'] = $this->language->get('error_country');
}

if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
	$this->error['zone'] = $this->language->get('error_zone');
}

if (!$this->request->post['code']) {
	$this->error['code'] = $this->language->get('error_code');
}

if (!$this->error) {
	return true;
} else {
	return false;
}