added domainname based retention support

This commit is contained in:
SJ 2013-07-31 10:57:45 +02:00
parent d1cae282dc
commit 8b18ce4896
6 changed files with 39 additions and 4 deletions

View File

@ -105,7 +105,7 @@ create table if not exists `tag` (
create table if not exists `archiving_rule` (
`id` bigint unsigned not null auto_increment,
`domain` varchar(255) default null,
`domain` varchar(128) default null,
`from` char(128) default null,
`to` char(255) default null,
`subject` char(255) default null,
@ -123,7 +123,7 @@ create table if not exists `archiving_rule` (
create table if not exists `retention_rule` (
`id` bigint unsigned not null auto_increment,
`domain` varchar(255) default null,
`domain` varchar(128) default null,
`from` char(128) default null,
`to` char(255) default null,
`subject` char(255) default null,
@ -135,7 +135,7 @@ create table if not exists `retention_rule` (
`spam` tinyint(1) default -1,
`days` int default 0,
primary key (`id`),
unique(`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`)
unique (`domain`,`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`)
) ENGINE=InnoDB;

View File

@ -7,6 +7,8 @@ create index `audit_idx5` on `audit`(`domain`);
alter table archiving_rule add column domain varchar(255) default null;
alter table retention_rule add column domain varchar(255) default null;
alter table retention_rule drop index `from`;
create unique index `entry` on retention_rule (`domain`,`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`);
create table if not exists `ldap` (
`id` int not null auto_increment primary key,

View File

@ -52,6 +52,7 @@ class ControllerPolicyRetention extends Controller {
$this->request->post['attachment_type'] == '' && $this->request->post['attachment_size'] == '' &&
$this->request->post['spam'] == -1
) {
if(ENABLE_SAAS == 1 && strlen($this->request->post['domain']) > 3) { return true; }
return false;
}

View File

@ -22,8 +22,12 @@ class ModelPolicyRetention extends Model {
public function add_new_rule($data = array()) {
$domain = '';
if(isset($data['domain'])) { $domain = $data['domain']; }
$query = $this->db->query("INSERT INTO " . TABLE_RETENTION_RULE . " (`domain`,`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`,`days`) VALUES(?,?,?,?,?,?,?,?,?,?,?)", array($domain, $data['from'], $data['to'], $data['subject'], $data['_size'], $data['size'], $data['attachment_type'], $data['_attachment_size'], $data['attachment_size'], $data['spam'], $data['days']) );
$query = $this->db->query("INSERT INTO " . TABLE_RETENTION_RULE . " (`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`,`days`) VALUES(?,?,?,?,?,?,?,?,?,?)", array($data['from'], $data['to'], $data['subject'], $data['_size'], $data['size'], $data['attachment_type'], $data['_attachment_size'], $data['attachment_size'], $data['spam'], $data['days']) );
return $this->db->countAffected();
}

View File

@ -2,6 +2,16 @@
<h4><?php print $text_add_new_rule; ?></h4>
<form method="post" id="add1" name="add1" action="index.php?route=policy/retention" class="form-horizontal">
<?php if(ENABLE_SAAS == 1) { ?>
<div class="control-group">
<label class="control-label" for="domain"><?php print $text_domain; ?>:</label>
<div class="controls">
<input type="text" class="text" name="domain" />
</div>
</div>
<?php } ?>
<div class="control-group">
<label class="control-label" for="from"><?php print $text_from; ?>:</label>
<div class="controls">
@ -76,6 +86,9 @@
<table id="ss1" class="table table-striped table-condensed">
<tr class="domainrow">
<?php if(ENABLE_SAAS == 1) { ?>
<th><?php print $text_domain; ?></th>
<?php } ?>
<th><?php print $text_from; ?></th>
<th><?php print $text_to; ?></th>
<th><?php print $text_subject; ?></th>
@ -89,6 +102,9 @@
<?php foreach($rules as $rule) { ?>
<tr class="domainrow">
<?php if(ENABLE_SAAS == 1) { ?>
<td><?php print $rule['domain']; ?></td>
<?php } ?>
<td><?php print $rule['from']; ?></td>
<td><?php print $rule['to']; ?></td>
<td><?php print $rule['subject']; ?></td>

View File

@ -5,6 +5,12 @@
<div id="ss1">
<?php if(ENABLE_SAAS == 1) { ?>
<div class="row">
<div class="domaincell"><?php print $text_domain; ?>:</div>
<div class="domaincell"><input type="text" name="domain" class="input-medium span5" /></div>
</div>
<?php } ?>
<div class="row">
<div class="domaincell"><?php print $text_from; ?>:</div>
<div class="domaincell"><input type="text" name="from" class="input-medium span5" /></div>
@ -78,6 +84,9 @@
<div id="ss1">
<div class="domainrow">
<?php if(ENABLE_SAAS == 1) { ?>
<div class="domaincell"><?php print $text_domain; ?></div>
<?php } ?>
<div class="domaincell"><?php print $text_from; ?></div>
<div class="domaincell"><?php print $text_to; ?></div>
<div class="domaincell"><?php print $text_subject; ?></div>
@ -91,6 +100,9 @@
<?php foreach($rules as $rule) { ?>
<div class="domainrow">
<?php if(ENABLE_SAAS == 1) { ?>
<div class="domaincell"><?php print $rule['domain']; ?></div>
<?php } ?>
<div class="domaincell"><?php print $rule['from']; ?></div>
<div class="domaincell"><?php print $rule['to']; ?></div>
<div class="domaincell"><?php print $rule['subject']; ?></div>