if (!$this->user->hasPermission('modify', 'sale/voucher')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if ((utf8_strlen($this->request->post['code']) < 3) || (utf8_strlen($this->request->post['code']) > 10)) {
$this->error['code'] = $this->language->get('error_code');
}
$voucher_info = $this->model_sale_voucher->getVoucherByCode($this->request->post['code']);
if ($voucher_info) {
if (!isset($this->request->get['voucher_id'])) {
$this->error['warning'] = $this->language->get('error_exists');
} elseif ($voucher_info['voucher_id'] != $this->request->get['voucher_id']) {
$this->error['warning'] = $this->language->get('error_exists');
}
}
if ((utf8_strlen($this->request->post['to_name']) < 1) || (utf8_strlen($this->request->post['to_name']) > 64)) {
$this->error['to_name'] = $this->language->get('error_to_name');
}
if ((utf8_strlen($this->request->post['to_email']) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['to_email'])) {
$this->error['to_email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['from_name']) < 1) || (utf8_strlen($this->request->post['from_name']) > 64)) {
$this->error['from_name'] = $this->language->get('error_from_name');
}
if ((utf8_strlen($this->request->post['from_email']) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['from_email'])) {
$this->error['from_email'] = $this->language->get('error_email');
}
if ($this->request->post['amount'] < 1) {
$this->error['amount'] = $this->language->get('error_amount');
}
if (!$this->error) {
return true;
} else {
return false;
}