mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 08:00:12 +01:00
added an option to change the stored retention values
This commit is contained in:
parent
a10040ea1c
commit
16e54ffbfd
@ -55,21 +55,23 @@ create index metadata_idx4 on metadata(`bodydigest`);
|
||||
create index metadata_idx5 on metadata(`deleted`);
|
||||
create index metadata_idx6 on metadata(`arrived`);
|
||||
create index metadata_idx7 on metadata(`retained`);
|
||||
create index metadata_idx8 on metadata(`fromdomain`);
|
||||
|
||||
|
||||
create table if not exists `rcpt` (
|
||||
`id` bigint unsigned not null,
|
||||
`to` varchar(128) not null,
|
||||
`todomain` varchar(64) not null,
|
||||
`todomain` varchar(128) not null,
|
||||
unique(`id`,`to`)
|
||||
) Engine=InnoDB;
|
||||
|
||||
create index `rcpt_idx` on `rcpt`(`id`);
|
||||
create index `rcpt_idx2` on `rcpt`(`to`);
|
||||
create index `rcpt_idx3` on `rcpt`(`todomain`);
|
||||
|
||||
|
||||
drop view if exists `v_messages`;
|
||||
create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`arrived` AS `arrived`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
|
||||
create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`retained` AS `retained`, `metadata`.`arrived` AS `arrived`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
|
||||
|
||||
|
||||
create table if not exists `attachment` (
|
||||
|
@ -10,6 +10,9 @@ 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`);
|
||||
|
||||
drop view if exists `v_messages`;
|
||||
create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`retained` AS `retained`, `metadata`.`arrived` AS `arrived`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
|
||||
|
||||
create table if not exists `ldap` (
|
||||
`id` int not null auto_increment primary key,
|
||||
`description` varchar(255) not null,
|
||||
|
@ -123,6 +123,8 @@ $config['PAGE_LEN'] = 20;
|
||||
$config['MAX_NUMBER_OF_FROM_ITEMS'] = 5;
|
||||
$config['MAX_SEARCH_HITS'] = 1000;
|
||||
|
||||
$config['DEFAULT_RETENTION'] = 0;
|
||||
|
||||
$config['LOCALHOST'] = '127.0.0.1';
|
||||
$config['PILER_HOST'] = '1.2.3.4';
|
||||
$config['PILER_PORT'] = 25;
|
||||
|
42
webui/controller/policy/updateretention.php
Normal file
42
webui/controller/policy/updateretention.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerPolicyUpdateRetention extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "policy/updateretention.tpl";
|
||||
$this->layout = "common/layout";
|
||||
|
||||
|
||||
$request = Registry::get('request');
|
||||
|
||||
$db = Registry::get('db');
|
||||
|
||||
$this->load->model('policy/retention');
|
||||
|
||||
$this->document->title = $this->data['text_retention_rules'];
|
||||
|
||||
if(Registry::get('admin_user') == 0) {
|
||||
die("go away");
|
||||
}
|
||||
|
||||
$this->data['n'] = 0;
|
||||
$this->data['domain'] = '';
|
||||
$this->data['days'] = 0;
|
||||
|
||||
if(isset($this->request->get['domain']) && isset($this->request->get['days'])) {
|
||||
$this->data['domain'] = $this->request->get['domain'];
|
||||
$this->data['days'] = $this->request->get['days'];
|
||||
|
||||
$this->data['n'] = $this->model_policy_retention->update_retention_time($this->data);
|
||||
}
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -271,6 +271,7 @@ $_['text_restore_message'] = "Nachricht wiederherstellen";
|
||||
$_['text_restore_to_mailbox'] = "Nachricht im Postfach wiederherstellen";
|
||||
$_['text_restored'] = "Wiederhergestellt";
|
||||
$_['text_result'] = "Ergebnis";
|
||||
$_['text_retention_days'] = "Aufbewahrungstagen";
|
||||
$_['text_retention_rules'] = "Aufbewahrungsregeln";
|
||||
$_['text_role'] = "Berechtigung";
|
||||
$_['text_running'] = "läuft";
|
||||
@ -340,7 +341,9 @@ $_['text_unauthorized_download_attachment'] = "Anhang unerlaubt heruntergeladen"
|
||||
$_['text_unauthorized_remove_message'] = "unerlaubte Nachrichtenlöschung";
|
||||
$_['text_unauthorized_view_message'] = "unerlaubte Nachrichtenansicht";
|
||||
$_['text_unknown'] = "unbekannt";
|
||||
$_['text_update_retention_within_this_domain'] = "Update retention values within this domain";
|
||||
$_['text_update_selected_uids'] = "Ausgewählte Benutzerkennungen aktualisieren";
|
||||
$_['text_updated_records'] = "Updated records";
|
||||
$_['text_uptime'] = "Betriebszeit";
|
||||
$_['text_user'] = "Benutzer";
|
||||
$_['text_users'] = "Benutzer";
|
||||
|
@ -271,6 +271,7 @@ $_['text_restore_message'] = "restore message";
|
||||
$_['text_restore_to_mailbox'] = "Restore message to mailbox";
|
||||
$_['text_restored'] = "Restored";
|
||||
$_['text_result'] = "Result";
|
||||
$_['text_retention_days'] = "Retention days";
|
||||
$_['text_retention_rules'] = "Retention rules";
|
||||
$_['text_role'] = "Role";
|
||||
$_['text_running'] = "running";
|
||||
@ -340,7 +341,9 @@ $_['text_unauthorized_download_attachment'] = "unauthorized attachment download"
|
||||
$_['text_unauthorized_remove_message'] = "unauthorized message removal";
|
||||
$_['text_unauthorized_view_message'] = "unathorized message view";
|
||||
$_['text_unknown'] = "unknown";
|
||||
$_['text_update_retention_within_this_domain'] = "Update retention values within this domain";
|
||||
$_['text_update_selected_uids'] = "Update selected uids";
|
||||
$_['text_updated_records'] = "Updated records";
|
||||
$_['text_uptime'] = "Uptime";
|
||||
$_['text_user'] = "User";
|
||||
$_['text_users'] = "Users";
|
||||
|
@ -271,6 +271,7 @@ $_['text_restore_message'] = "lev
|
||||
$_['text_restore_to_mailbox'] = "Levél visszaállítása postafiókba";
|
||||
$_['text_restored'] = "Visszaállítva";
|
||||
$_['text_result'] = "Eredmény";
|
||||
$_['text_retention_days'] = "Megtartási idõ [nap]";
|
||||
$_['text_retention_rules'] = "Megtartási szabályok";
|
||||
$_['text_role'] = "Felhasználótípus";
|
||||
$_['text_running'] = "fut";
|
||||
@ -340,7 +341,9 @@ $_['text_unauthorized_domain'] = "Nem megengedett domain";
|
||||
$_['text_unauthorized_download_attachment'] = "jogosulatlan melléklet letöltés";
|
||||
$_['text_unauthorized_remove_message'] = "jogosulatlan üzenet törlés";
|
||||
$_['text_unauthorized_view_message'] = "jogosulatlan üzenet megtekintés";
|
||||
$_['text_update_retention_within_this_domain'] = "Megtartási idõ frissítése ebben a domainben";
|
||||
$_['text_update_selected_uids'] = "Kijelölt azonosítók módosítása";
|
||||
$_['text_updated_records'] = "Frissített rekordok";
|
||||
$_['text_uptime'] = "Uptime";
|
||||
$_['text_user'] = "Felhasználó";
|
||||
$_['text_users'] = "Felhasználók";
|
||||
|
@ -271,6 +271,7 @@ $_['text_restore_message'] = "levél visszaállítása";
|
||||
$_['text_restore_to_mailbox'] = "Levél visszaállítása postafiókba";
|
||||
$_['text_restored'] = "Visszaállítva";
|
||||
$_['text_result'] = "Eredmény";
|
||||
$_['text_retention_days'] = "Megtartási idő [nap]";
|
||||
$_['text_retention_rules'] = "Megtartási szabályok";
|
||||
$_['text_role'] = "Felhasználótípus";
|
||||
$_['text_running'] = "fut";
|
||||
@ -340,7 +341,9 @@ $_['text_unauthorized_domain'] = "Nem megengedett domain";
|
||||
$_['text_unauthorized_download_attachment'] = "jogosulatlan melléklet letöltés";
|
||||
$_['text_unauthorized_remove_message'] = "jogosulatlan üzenet törlés";
|
||||
$_['text_unauthorized_view_message'] = "jogosulatlan üzenet megtekintés";
|
||||
$_['text_update_retention_within_this_domain'] = "Megtartási idő frissítése ebben a domainben";
|
||||
$_['text_update_selected_uids'] = "Kijelölt azonosítók módosítása";
|
||||
$_['text_updated_records'] = "Frissített rekordok";
|
||||
$_['text_uptime'] = "Uptime";
|
||||
$_['text_user'] = "Felhasználó";
|
||||
$_['text_users'] = "Felhasználók";
|
||||
|
@ -260,12 +260,12 @@ $_['text_remove_this_policy'] = "Remover esta política";
|
||||
$_['text_remove_this_group'] = "Remover este grupo";
|
||||
$_['text_remove_this_user'] = "Remover este usuário";
|
||||
$_['text_reset_counters'] = "Zerar contadores";
|
||||
|
||||
$_['text_restore'] = "reenviar";
|
||||
$_['text_restore_message'] = "reenviar mensagem";
|
||||
$_['text_restore_to_mailbox'] = "Reenviar mensagem";
|
||||
$_['text_restored'] = "Reenviado.";
|
||||
$_['text_result'] = "Resultado";
|
||||
$_['text_retention_days'] = "Retention days";
|
||||
$_['text_retention_rules'] = "Regras de retenção";
|
||||
$_['text_role'] = "Função";
|
||||
$_['text_running'] = "processando";
|
||||
@ -334,7 +334,9 @@ $_['text_unauthorized_download_attachment'] = "unauthorized attachment download"
|
||||
$_['text_unauthorized_remove_message'] = "remoção de mensagem não autorizada";
|
||||
$_['text_unauthorized_view_message'] = "visualização de mensagem não autorizada";
|
||||
$_['text_unknown'] = "desconhecido";
|
||||
$_['text_update_retention_within_this_domain'] = "Update retention values within this domain";
|
||||
$_['text_update_selected_uids'] = "Atualizar UIDs selecionados";
|
||||
$_['text_updated_records'] = "Updated records";
|
||||
$_['text_uptime'] = "Uptime";
|
||||
$_['text_user'] = "Usuário";
|
||||
$_['text_users'] = "Usuários";
|
||||
|
@ -34,6 +34,25 @@ class ModelPolicyRetention extends Model {
|
||||
|
||||
public function remove_rule($id = 0) {
|
||||
$query = $this->db->query("DELETE FROM " . TABLE_RETENTION_RULE . " WHERE id=?", array($id));
|
||||
|
||||
return $this->db->countAffected();
|
||||
}
|
||||
|
||||
|
||||
public function update_retention_time($data = array()) {
|
||||
if(DEFAULT_RETENTION <= 0) { return 0; }
|
||||
|
||||
if(!isset($data['domain']) || !isset($data['days']) || $data['domain'] == '' || $data['days'] < 1) { return 0; }
|
||||
|
||||
$default_retention = DEFAULT_RETENTION * 86400;
|
||||
|
||||
$delta = NOW + 86400 * $data['days'] - $default_retention;
|
||||
$start_ts = NOW - $default_retention;
|
||||
|
||||
$query = $this->db->query("UPDATE " . VIEW_MESSAGES . " SET retained=? WHERE arrived > ? AND (todomain=? OR fromdomain=?)", array($delta, $start_ts, $data['domain'], $data['domain']));
|
||||
|
||||
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("update retention date: domain='%s', days=%d, hits=%d, exec time=%.2f sec", $data['domain'], $data['days'], $this->db->countAffected(), $query->exec_time)); }
|
||||
|
||||
return $this->db->countAffected();
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
<tr>
|
||||
<th><?php print $text_disk_usage; ?></th>
|
||||
<td><?php foreach($shortdiskinfo as $partition) { ?><span class="<?php if($partition['utilization'] < HEALTH_RATIO) { ?>text-success<?php } else { ?>text-error<?php } ?>"><?php print $partition['partition']; ?> => <?php print nice_size(1000*$partition['used']); ?> / <?php print nice_size($partition['total']); ?> (<?php print $partition['utilization']; ?>%)</span><br /> <?php } ?></td>
|
||||
<td><?php foreach($shortdiskinfo as $partition) { ?><span class="<?php if($partition['utilization'] < HEALTH_RATIO) { ?>text-success<?php } else { ?>text-error<?php } ?>"><?php print $partition['partition']; ?> => <?php print nice_size(1000*$partition['used']); ?> / <?php print nice_size(1000*$partition['total']); ?> (<?php print $partition['utilization']; ?>%)</span><br /> <?php } ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
@ -98,6 +98,9 @@
|
||||
<th><?php print $text_attachment_size; ?></th>
|
||||
<th><?php print $text_days; ?></th>
|
||||
<th> </th>
|
||||
<?php if(ENABLE_SAAS == 1) { ?>
|
||||
<th> </th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach($rules as $rule) { ?>
|
||||
@ -114,6 +117,9 @@
|
||||
<td><?php if($rule['attachment_size'] > 0) { print $rule['_attachment_size']; ?> <?php print $rule['attachment_size']; } ?></td>
|
||||
<td><?php print $rule['days']; ?></td>
|
||||
<td><a href="index.php?route=policy/removeretention&id=<?php print $rule['id']; ?>"><?php print $text_remove; ?></a></td>
|
||||
<?php if(ENABLE_SAAS == 1) { ?>
|
||||
<td><?php if($rule['domain']) { ?><a href="index.php?route=policy/updateretention&domain=<?php print $rule['domain']; ?>&days=<?php print $rule['days']; ?>"><?php print $text_update_retention_within_this_domain; ?></a><?php } else { ?> <?php } ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
|
||||
<div class="alert alert-<?php if($n > 0) { ?>success<?php } else { ?>error<?php } ?>">
|
||||
|
||||
<?php print $text_domain; ?>: <?php print $domain; ?><br />
|
||||
<?php print $text_retention_days; ?>: <?php print $days; ?><br />
|
||||
<?php print $text_updated_records; ?>: <?php print $n; ?>
|
||||
|
||||
</div>
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="cellhealthleft"><?php print $text_disk_usage; ?></div>
|
||||
<div class="cellhealthright"><?php foreach($shortdiskinfo as $partition) { ?><span class="bold <?php if($partition['utilization'] < HEALTH_RATIO) { ?>text-success<?php } else { ?>text-error<?php } ?>"><?php print $partition['partition']; ?> => <?php print nice_size(1000*$partition['used']); ?> / <?php print nice_size($partition['total']); ?> (<?php print $partition['utilization']; ?>%)</span><br /><?php } ?></div>
|
||||
<div class="cellhealthright"><?php foreach($shortdiskinfo as $partition) { ?><span class="bold <?php if($partition['utilization'] < HEALTH_RATIO) { ?>text-success<?php } else { ?>text-error<?php } ?>"><?php print $partition['partition']; ?> => <?php print nice_size(1000*$partition['used']); ?> / <?php print nice_size(1000*$partition['total']); ?> (<?php print $partition['utilization']; ?>%)</span><br /><?php } ?></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -96,6 +96,9 @@
|
||||
<div class="domaincell"><?php print $text_attachment_size; ?></div>
|
||||
<div class="domaincell"><?php print $text_days; ?></div>
|
||||
<div class="domaincell"> </div>
|
||||
<?php if(ENABLE_SAAS == 1) { ?>
|
||||
<div class="domaincell"> </div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php foreach($rules as $rule) { ?>
|
||||
@ -112,6 +115,9 @@
|
||||
<div class="domaincell"><?php if($rule['attachment_size'] > 0) { print $rule['_attachment_size']; ?> <?php print $rule['attachment_size']; } ?></div>
|
||||
<div class="domaincell"><?php print $rule['days']; ?></div>
|
||||
<div class="domaincell"><a href="index.php?route=policy/removeretention&confirmed=1&id=<?php print $rule['id']; ?>" onclick="if(confirm('<?php print $text_remove_rule; ?>: ' + '#<?php print $rule['id']; ?>')) return true; return false;"><?php print $text_remove; ?></a></div>
|
||||
<?php if(ENABLE_SAAS == 1) { ?>
|
||||
<div class="domaincell"><?php if($rule['domain']) { ?><a href="index.php?route=policy/updateretention&domain=<?php print $rule['domain']; ?>&days=<?php print $rule['days']; ?>"><?php print $text_update_retention_within_this_domain; ?></a><?php } else { ?> <?php } ?></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
|
||||
<div class="alert alert-<?php if($n > 0) { ?>success<?php } else { ?>error<?php } ?>">
|
||||
|
||||
<?php print $text_domain; ?>: <?php print $domain; ?><br />
|
||||
<?php print $text_retention_days; ?>: <?php print $days; ?><br />
|
||||
<?php print $text_updated_records; ?>: <?php print $n; ?>
|
||||
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user