From 7a096bceb7bb9125946d79bd84eacf865b6ffd36 Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 9 Mar 2013 20:41:44 +0100 Subject: [PATCH] prevent adding empty retention rule --- webui/controller/policy/retention.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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; + } + + } ?>