prevent you to shoot yourself in the foot very badly with an archiving rule

This commit is contained in:
SJ 2013-01-23 22:17:37 +01:00
parent f522ed9267
commit c6d4cf051d
3 changed files with 25 additions and 2 deletions

View File

@ -14,6 +14,7 @@ class ControllerPolicyArchiving extends Controller {
$request = Registry::get('request');
$db = Registry::get('db');
$lang = Registry::get('language');
$this->load->model('policy/archiving');
@ -21,12 +22,18 @@ class ControllerPolicyArchiving extends Controller {
$this->data['rules'] = array();
$this->data['error'] = '';
if(Registry::get('admin_user') == 0) {
die("go away");
}
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if($this->validate == true) {
$rc = $this->model_policy_archiving->add_new_rule($this->request->post);
} else {
$this->data['error'] = $lang->data['text_invalid_data'];
}
}
$this->data['rules'] = $this->model_policy_archiving->get_rules();
@ -36,6 +43,18 @@ class ControllerPolicyArchiving extends Controller {
}
private function validate() {
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;
}
}
?>

View File

@ -166,6 +166,7 @@
.fcell { display: table-cell; font: bold 12px Arial, sans-serif; padding: 5px; vertical-align: top; }
.domain { font: normal 12px Arial, sans-serif; font-weight: bold; text-align:left; width: 408px;}
p.error { margin-bottom: 20px; color: red; font-weight: bold; }
#dhtmltooltip { position: absolute; width: 150px; border: 2px solid black; padding: 2px; background-color: yellow; color: #ffffff; visibility: hidden; z-index: 100; }

View File

@ -65,6 +65,10 @@
</form>
<?php if($error) { ?>
<p class="error"><?php print $text_error; ?>: <?php print $error; ?></p>
<?php } ?>
<h4><?php print $text_existing_rules; ?></h4>
@ -101,4 +105,3 @@
<?php print $text_not_found; ?>
<?php } ?>