imapsync: added option to delete from source after transfer

master
andryyy 2017-04-10 13:07:39 +02:00
parent 7339bd446e
commit 7f8d6556b8
7 changed files with 41 additions and 5 deletions

View File

@ -11,8 +11,7 @@ login_log_format_elements = "user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k"
mail_home = /var/vmail/%d/%n mail_home = /var/vmail/%d/%n
mail_location = maildir:~/ mail_location = maildir:~/
mail_plugins = quota acl zlib mail_crypt mail_plugins = quota acl zlib mail_crypt
auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@ ssl_protocols = !SSLv3
#ssl_protocols = !SSLv3 !SSLv2
ssl_prefer_server_ciphers = yes ssl_prefer_server_ciphers = yes
ssl_cipher_list = EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA ssl_cipher_list = EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA
ssl_options = no_compression ssl_options = no_compression

View File

@ -350,6 +350,13 @@ elseif (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] ==
</div> </div>
</div> </div>
</div> </div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox" name="delete1" checked> <?=$lang['add']['delete1'];?></label>
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<div class="checkbox"> <div class="checkbox">

View File

@ -620,6 +620,20 @@ elseif (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] ==
<input type="text" class="form-control" name="exclude" id="exclude" value="<?=htmlspecialchars($result['exclude'], ENT_QUOTES, 'UTF-8');?>"> <input type="text" class="form-control" name="exclude" id="exclude" value="<?=htmlspecialchars($result['exclude'], ENT_QUOTES, 'UTF-8');?>">
</div> </div>
</div> </div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox" name="delete2duplicates" <?=($result['delete2duplicates']=="1") ? "checked" : "";?>> <?=$lang['edit']['delete2duplicates'];?></label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox" name="delete1" <?=($result['delete1']=="1") ? "checked" : "";?>> <?=$lang['edit']['delete1'];?></label>
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<div class="checkbox"> <div class="checkbox">

View File

@ -109,6 +109,11 @@ function init_db_schema() {
if ($num_results == 0) { if ($num_results == 0) {
$pdo->query("ALTER TABLE `mailbox` ADD `multiple_bookings` tinyint(1) NOT NULL DEFAULT '0'"); $pdo->query("ALTER TABLE `mailbox` ADD `multiple_bookings` tinyint(1) NOT NULL DEFAULT '0'");
} }
$stmt = $pdo->query("SHOW COLUMNS FROM `imapsync` LIKE 'delete1'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results == 0) {
$pdo->query("ALTER TABLE `imapsync` ADD `delete1` tinyint(1) NOT NULL DEFAULT '0'");
}
$stmt = $pdo->query("SHOW COLUMNS FROM `mailbox` LIKE 'wants_tagged_subject'"); $stmt = $pdo->query("SHOW COLUMNS FROM `mailbox` LIKE 'wants_tagged_subject'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results == 0) { if ($num_results == 0) {
@ -1075,6 +1080,7 @@ function add_syncjob($postarray) {
} }
isset($postarray['active']) ? $active = '1' : $active = '0'; isset($postarray['active']) ? $active = '1' : $active = '0';
isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0'; isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0';
isset($postarray['delete1']) ? $delete1 = '1' : $delete1 = '0';
$port1 = $postarray['port1']; $port1 = $postarray['port1'];
$host1 = $postarray['host1']; $host1 = $postarray['host1'];
$password1 = $postarray['password1']; $password1 = $postarray['password1'];
@ -1147,12 +1153,13 @@ function add_syncjob($postarray) {
return false; return false;
} }
try { try {
$stmt = $pdo->prepare("INSERT INTO `imapsync` (`user2`, `exclude`, `maxage`, `subfolder2`, `host1`, `authmech1`, `user1`, `password1`, `mins_interval`, `port1`, `enc1`, `delete2duplicates`, `active`) $stmt = $pdo->prepare("INSERT INTO `imapsync` (`user2`, `exclude`, `delete1`, `maxage`, `subfolder2`, `host1`, `authmech1`, `user1`, `password1`, `mins_interval`, `port1`, `enc1`, `delete2duplicates`, `active`)
VALUES (:user2, :exclude, :maxage, :subfolder2, :host1, :authmech1, :user1, :password1, :mins_interval, :port1, :enc1, :delete2duplicates, :active)"); VALUES (:user2, :exclude, :maxage, :delete1, :subfolder2, :host1, :authmech1, :user1, :password1, :mins_interval, :port1, :enc1, :delete2duplicates, :active)");
$stmt->execute(array( $stmt->execute(array(
':user2' => $username, ':user2' => $username,
':exclude' => $exclude, ':exclude' => $exclude,
':maxage' => $maxage, ':maxage' => $maxage,
':delete1' => $delete1,
':subfolder2' => $subfolder2, ':subfolder2' => $subfolder2,
':host1' => $host1, ':host1' => $host1,
':authmech1' => 'PLAIN', ':authmech1' => 'PLAIN',
@ -1200,6 +1207,7 @@ function edit_syncjob($postarray) {
} }
isset($postarray['active']) ? $active = '1' : $active = '0'; isset($postarray['active']) ? $active = '1' : $active = '0';
isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0'; isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0';
isset($postarray['delete1']) ? $delete1 = '1' : $delete1 = '0';
$id = $postarray['id']; $id = $postarray['id'];
$port1 = $postarray['port1']; $port1 = $postarray['port1'];
$host1 = $postarray['host1']; $host1 = $postarray['host1'];
@ -1273,10 +1281,11 @@ function edit_syncjob($postarray) {
return false; return false;
} }
try { try {
$stmt = $pdo->prepare("UPDATE `imapsync` set `maxage` = :maxage, `subfolder2` = :subfolder2, `exclude` = :exclude, `host1` = :host1, `user1` = :user1, `password1` = :password1, `mins_interval` = :mins_interval, `port1` = :port1, `enc1` = :enc1, `delete2duplicates` = :delete2duplicates, `active` = :active $stmt = $pdo->prepare("UPDATE `imapsync` set `delete1` = :delete1, `maxage` = :maxage, `subfolder2` = :subfolder2, `exclude` = :exclude, `host1` = :host1, `user1` = :user1, `password1` = :password1, `mins_interval` = :mins_interval, `port1` = :port1, `enc1` = :enc1, `delete2duplicates` = :delete2duplicates, `active` = :active
WHERE `user2` = :user2 AND `id` = :id"); WHERE `user2` = :user2 AND `id` = :id");
$stmt->execute(array( $stmt->execute(array(
':user2' => $username, ':user2' => $username,
':delete1' => $delete1,
':id' => $id, ':id' => $id,
':exclude' => $exclude, ':exclude' => $exclude,
':maxage' => $maxage, ':maxage' => $maxage,

View File

@ -329,6 +329,9 @@ $lang['add']['subfolder2'] = 'Sync into subfolder on destination';
$lang['add']['mins_interval'] = 'Abrufintervall (Minuten)'; $lang['add']['mins_interval'] = 'Abrufintervall (Minuten)';
$lang['add']['exclude'] = 'Elemente ausschließen (Regex)'; $lang['add']['exclude'] = 'Elemente ausschließen (Regex)';
$lang['add']['delete2duplicates'] = 'Lösche Duplikate im Ziel'; $lang['add']['delete2duplicates'] = 'Lösche Duplikate im Ziel';
$lang['add']['delete1'] = 'Lösche Nachricht nach Übertragung vom Quell-Server';
$lang['edit']['delete2duplicates'] = 'Lösche Duplikate im Ziel';
$lang['edit']['delete1'] = 'Lösche Nachricht nach Übertragung vom Quell-Server';
$lang['add']['title'] = 'Objekt anlegen'; $lang['add']['title'] = 'Objekt anlegen';
$lang['add']['domain'] = 'Domain'; $lang['add']['domain'] = 'Domain';

View File

@ -333,6 +333,9 @@ $lang['add']['maxage'] = 'Maximum age of messages that will be polled from remot
$lang['add']['subfolder2'] = 'Sync into subfolder on destination'; $lang['add']['subfolder2'] = 'Sync into subfolder on destination';
$lang['add']['exclude'] = 'Exclude objects (regex)'; $lang['add']['exclude'] = 'Exclude objects (regex)';
$lang['add']['delete2duplicates'] = 'Delete duplicates on destination'; $lang['add']['delete2duplicates'] = 'Delete duplicates on destination';
$lang['add']['delete1'] = 'Delete from source when completed';
$lang['edit']['delete2duplicates'] = 'Delete duplicates on destination';
$lang['edit']['delete1'] = 'Delete from source when completed';
$lang['add']['title'] = 'Add object'; $lang['add']['title'] = 'Add object';
$lang['add']['domain'] = 'Domain'; $lang['add']['domain'] = 'Domain';

View File

@ -321,6 +321,7 @@ $lang['add']['maxage'] = 'Maximum age of messages that will be polled from remot
$lang['add']['subfolder2'] = "Синхронизировать в подпапку по назначению"; $lang['add']['subfolder2'] = "Синхронизировать в подпапку по назначению";
$lang['add']['exclude'] = "Исключить объекты (regex)"; $lang['add']['exclude'] = "Исключить объекты (regex)";
$lang['add']['delete2duplicates'] = "Удалить дубликаты в получателях"; $lang['add']['delete2duplicates'] = "Удалить дубликаты в получателях";
$lang['edit']['delete2duplicates'] = "Удалить дубликаты в получателях";
$lang['add']['title'] = "Добавить объект"; $lang['add']['title'] = "Добавить объект";
$lang['add']['domain'] = "Домен"; $lang['add']['domain'] = "Домен";
$lang['add']['active'] = "Активный"; $lang['add']['active'] = "Активный";