diff --git a/webui/controller/policy/retention.php b/webui/controller/policy/retention.php index 00339d40..2fb79330 100644 --- a/webui/controller/policy/retention.php +++ b/webui/controller/policy/retention.php @@ -26,7 +26,12 @@ class ControllerPolicyRetention extends Controller { } if($_SERVER['REQUEST_METHOD'] == 'POST') { - $rc = $this->model_policy_retention->add_new_rule($this->request->post); + if($this->validate() == true) { + $rc = $this->model_policy_retention->add_new_rule($this->request->post); + } else { + $this->data['error'] = $lang->data['text_invalid_data']; + } + } $this->data['rules'] = $this->model_policy_retention->get_rules(); @@ -36,6 +41,21 @@ class ControllerPolicyRetention extends Controller { } + private function validate() { + if($this->request->post['days'] == '' || $this->request->post['days'] < 1) { return false; } + + if($this->request->post['from'] == '' && $this->request->post['to'] == '' && + $this->request->post['subject'] == '' && $this->request->post['size'] == '' && + $this->request->post['attachment_type'] == '' && $this->request->post['attachment_size'] == '' && + $this->request->post['spam'] == -1 + ) { + return false; + } + + return true; + } + + } ?>