mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-01-12 14:40:12 +01:00
prevent adding empty retention rule
This commit is contained in:
parent
32287100e1
commit
7a096bceb7
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user