From c3be04560b9026770a27233a73b95c44b6920a15 Mon Sep 17 00:00:00 2001 From: andryyy Date: Sun, 22 Sep 2019 15:10:56 +0200 Subject: [PATCH] [Web] mailbox.php uses dropups [Web] Allow to set visibility of aliases in SOGo [Web] Refresh window when session timed out [Web] Increase default log lines and pagination trigger [Web] Increase delay when filtering tables --- data/web/edit.php | 8 +++++++- data/web/inc/footer.inc.php | 12 ++++++++++++ data/web/inc/functions.mailbox.inc.php | 14 ++++++++++++-- data/web/inc/init_db.inc.php | 6 +++++- data/web/inc/vars.inc.php | 6 +++--- data/web/js/build/014-mailcow.js | 2 +- data/web/js/site/admin.js | 2 +- data/web/js/site/debug.js | 22 +++++++++++----------- data/web/js/site/mailbox.js | 1 + data/web/lang/lang.de.php | 6 ++++++ data/web/lang/lang.en.php | 6 ++++++ data/web/mailbox.php | 23 +++++++++++++---------- 12 files changed, 78 insertions(+), 30 deletions(-) diff --git a/data/web/edit.php b/data/web/edit.php index 694d8fdc..acbd8841 100644 --- a/data/web/edit.php +++ b/data/web/edit.php @@ -28,6 +28,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
+
@@ -37,7 +38,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
- +
@@ -47,6 +48,11 @@ if (isset($_SESSION['mailcow_cc_role'])) {
+
+
+ +
+


diff --git a/data/web/inc/footer.inc.php b/data/web/inc/footer.inc.php index f1cca54c..23d2a770 100644 --- a/data/web/inc/footer.inc.php +++ b/data/web/inc/footer.inc.php @@ -146,6 +146,18 @@ $(document).ready(function() { } }); + // Reload after session timeout + var session_lifetime = ; + + setTimeout(function() { + location.reload(); + }, session_lifetime); + + // CSRF $('').attr('name', 'csrf_token').appendTo('form'); if (sessionStorage.scrollTop != "undefined") { diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index d48f0c0b..99fda2d8 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -472,6 +472,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $addresses = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['address'])); $gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto'])); $active = intval($_data['active']); + $sogo_visible = intval($_data['sogo_visible']); $goto_null = intval($_data['goto_null']); $goto_spam = intval($_data['goto_spam']); $goto_ham = intval($_data['goto_ham']); @@ -625,8 +626,8 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ); continue; } - $stmt = $pdo->prepare("INSERT INTO `alias` (`address`, `public_comment`, `private_comment`, `goto`, `domain`, `active`) - VALUES (:address, :public_comment, :private_comment, :goto, :domain, :active)"); + $stmt = $pdo->prepare("INSERT INTO `alias` (`address`, `public_comment`, `private_comment`, `goto`, `domain`, `sogo_visible`, `active`) + VALUES (:address, :public_comment, :private_comment, :goto, :domain, :sogo_visible, :active)"); if (!filter_var($address, FILTER_VALIDATE_EMAIL) === true) { $stmt->execute(array( ':address' => '@'.$domain, @@ -635,6 +636,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ':address' => '@'.$domain, ':goto' => $goto, ':domain' => $domain, + ':sogo_visible' => $sogo_visible, ':active' => $active )); } @@ -645,6 +647,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ':private_comment' => $private_comment, ':goto' => $goto, ':domain' => $domain, + ':sogo_visible' => $sogo_visible, ':active' => $active )); } @@ -1697,6 +1700,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $is_now = mailbox('get', 'alias_details', $id); if (!empty($is_now)) { $active = (isset($_data['active'])) ? intval($_data['active']) : $is_now['active_int']; + $sogo_visible = (isset($_data['sogo_visible'])) ? intval($_data['sogo_visible']) : $is_now['sogo_visible_int']; $goto_null = (isset($_data['goto_null'])) ? intval($_data['goto_null']) : 0; $goto_spam = (isset($_data['goto_spam'])) ? intval($_data['goto_spam']) : 0; $goto_ham = (isset($_data['goto_ham'])) ? intval($_data['goto_ham']) : 0; @@ -1831,6 +1835,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { `public_comment` = :public_comment, `private_comment` = :private_comment, `goto` = :goto, + `sogo_visible`= :sogo_visible, `active`= :active WHERE `id` = :id"); $stmt->execute(array( @@ -1838,6 +1843,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ':public_comment' => $public_comment, ':private_comment' => $private_comment, ':goto' => $goto, + ':sogo_visible' => $sogo_visible, ':active' => $active, ':id' => $id )); @@ -2958,7 +2964,9 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { `public_comment`, `private_comment`, `active` as `active_int`, + `sogo_visible` as `sogo_visible_int`, CASE `active` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `active`, + CASE `sogo_visible` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `sogo_visible`, `created`, `modified` FROM `alias` @@ -2987,7 +2995,9 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $aliasdata['address'] = $row['address']; (!filter_var($aliasdata['address'], FILTER_VALIDATE_EMAIL)) ? $aliasdata['is_catch_all'] = 1 : $aliasdata['is_catch_all'] = 0; $aliasdata['active'] = $row['active']; + $aliasdata['sogo_visible'] = $row['sogo_visible']; $aliasdata['active_int'] = $row['active_int']; + $aliasdata['sogo_visible_int'] = $row['sogo_visible_int']; $aliasdata['created'] = $row['created']; $aliasdata['modified'] = $row['modified']; if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $aliasdata['domain'])) { diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php index 019c1afb..91672e3b 100644 --- a/data/web/inc/init_db.inc.php +++ b/data/web/inc/init_db.inc.php @@ -3,7 +3,7 @@ function init_db_schema() { try { global $pdo; - $db_version = "01092019_1240"; + $db_version = "22092019_0940"; $stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -19,14 +19,17 @@ function init_db_schema() { SELECT goto, IFNULL(GROUP_CONCAT(address SEPARATOR ' '), '') AS address FROM alias WHERE address!=goto AND active = '1' + AND sogo_visible = '1' AND address NOT LIKE '@%' GROUP BY goto;", + // START // Unused at the moment - we cannot allow to show a foreign mailbox as sender address in SOGo, as SOGo does not like this // We need to create delegation in SOGo AND set a sender_acl in mailcow to allow to send as user X "grouped_sender_acl" => "CREATE VIEW grouped_sender_acl (username, send_as_acl) AS SELECT logged_in_as, IFNULL(GROUP_CONCAT(send_as SEPARATOR ' '), '') AS send_as_acl FROM sender_acl WHERE send_as NOT LIKE '@%' GROUP BY logged_in_as;", + // END "grouped_sender_acl_external" => "CREATE VIEW grouped_sender_acl_external (username, send_as_acl) AS SELECT logged_in_as, IFNULL(GROUP_CONCAT(send_as SEPARATOR ' '), '') AS send_as_acl FROM sender_acl WHERE send_as NOT LIKE '@%' AND external = '1' @@ -147,6 +150,7 @@ function init_db_schema() { "modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP", "private_comment" => "TEXT", "public_comment" => "TEXT", + "sogo_visible" => "TINYINT(1) NOT NULL DEFAULT '1'", "active" => "TINYINT(1) NOT NULL DEFAULT '1'" ), "keys" => array( diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php index a86377ec..90b7e377 100644 --- a/data/web/inc/vars.inc.php +++ b/data/web/inc/vars.inc.php @@ -109,13 +109,13 @@ $MAILCOW_APPS = array( $PAGINATION_SIZE = 20; // Default number of rows/lines to display (log table) -$LOG_LINES = 100; +$LOG_LINES = 1000; // Rows until pagination begins (log table) -$LOG_PAGINATION_SIZE = 30; +$LOG_PAGINATION_SIZE = 50; // Session lifetime in seconds -$SESSION_LIFETIME = 3600; +$SESSION_LIFETIME = 10800; // Label for OTP devices $OTP_LABEL = "mailcow UI"; diff --git a/data/web/js/build/014-mailcow.js b/data/web/js/build/014-mailcow.js index 66ff61ad..8428c2a6 100644 --- a/data/web/js/build/014-mailcow.js +++ b/data/web/js/build/014-mailcow.js @@ -2,7 +2,7 @@ $(document).ready(function() { // mailcow alert box generator window.mailcow_alert_box = function(message, type) { msg = $('').text(message).text(); - if (type == 'danger') { + if (type == 'danger' || type == 'info') { auto_hide = 0; $('#' + localStorage.getItem("add_modal")).modal('show'); localStorage.removeItem("add_modal"); diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js index 15e512ce..43012897 100644 --- a/data/web/js/site/admin.js +++ b/data/web/js/site/admin.js @@ -73,7 +73,7 @@ jQuery(function($){ "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, "state": {"enabled": true}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "toggleSelector": "table tbody span.footable-toggle" }); diff --git a/data/web/js/site/debug.js b/data/web/js/site/debug.js index 10441874..bf921bff 100644 --- a/data/web/js/site/debug.js +++ b/data/web/js/site/debug.js @@ -53,7 +53,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -85,7 +85,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -118,7 +118,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -152,7 +152,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -194,7 +194,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -231,7 +231,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -262,7 +262,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -294,7 +294,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -326,7 +326,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -358,7 +358,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ @@ -441,7 +441,7 @@ jQuery(function($){ }), "empty": lang.empty, "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "filtering": {"enabled": true,"delay": 1,"position": "left","connectors": false,"placeholder": lang.filter_table}, + "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, "sorting": {"enabled": true}, "on": { "ready.ft.table": function(e, ft){ diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index 5d18fc64..59569d5c 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -781,6 +781,7 @@ jQuery(function($){ {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, {"name":"public_comment","title":lang.public_comment,"breakpoints":"all"}, {"name":"private_comment","title":lang.private_comment,"breakpoints":"all"}, + {"name":"sogo_visible","title":lang.sogo_visible,"breakpoints":"all"}, {"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active}, {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} ], diff --git a/data/web/lang/lang.de.php b/data/web/lang/lang.de.php index 3ae98fe0..544ea3f6 100644 --- a/data/web/lang/lang.de.php +++ b/data/web/lang/lang.de.php @@ -42,6 +42,7 @@ $lang['success']['queue_command_success'] = "Queue-Aufgabe erfolgreich ausgefüh $lang['danger']['unknown'] = "Ein unbekannter Fehler trat auf"; $lang['danger']['malformed_username'] = "Benutzername hat ein falsches Format"; $lang['info']['awaiting_tfa_confirmation'] = "Warte auf TFA Verifizierung"; +$lang['info']['session_expires'] = "Die Sitzung wird in etwa 15 Sekunden beendet"; $lang['success']['logged_in_as'] = "Eingeloggt als %s"; $lang['danger']['login_failed'] = "Anmeldung fehlgeschlagen"; $lang['danger']['set_acl_failed'] = "ACL konnte nicht gesetzt werden"; @@ -331,6 +332,11 @@ Die Ausführung erfolgt in nachstehender Reihenfolge. Ein fehlgeschlagenes Scrip $lang['info']['no_action'] = 'Keine Aktion anwendbar'; +$lang['edit']['sogo_visible'] = 'Alias in SOGo sichtbar'; +$lang['edit']['sogo_visible_info'] = 'Diese Option hat lediglich Einfluss auf Objekte, die in SOGo darstellbar sind (geteilte oder nicht-geteilte Alias-Adressen mit dem Ziel mindestens einer lokalen Mailbox).'; +$lang['mailbox']['sogo_visible'] = 'Alias Sichtbarkeit in SOGo'; +$lang['mailbox']['sogo_visible_y'] = 'Alias in SOGo anzeigen'; +$lang['mailbox']['sogo_visible_n'] = 'Alias in SOGo verbergen'; $lang['edit']['syncjob'] = 'Sync-Job bearbeiten'; $lang['edit']['save'] = 'Änderungen speichern'; $lang['edit']['username'] = 'Benutzername'; diff --git a/data/web/lang/lang.en.php b/data/web/lang/lang.en.php index 9ca74568..99eee6ff 100644 --- a/data/web/lang/lang.en.php +++ b/data/web/lang/lang.en.php @@ -43,6 +43,7 @@ $lang['success']['queue_command_success'] = "Queue command completed successfull $lang['danger']['unknown'] = "An unknown error occurred"; $lang['danger']['malformed_username'] = "Malformed username"; $lang['info']['awaiting_tfa_confirmation'] = "Awaiting TFA confirmation"; +$lang['info']['session_expires'] = "Your session will expire in about 15 seconds"; $lang['success']['logged_in_as'] = "Logged in as %s"; $lang['danger']['login_failed'] = "Login failed"; $lang['danger']['set_acl_failed'] = "Failed to set ACL"; @@ -339,6 +340,11 @@ Each filter will be processed in the described order. Neither a failed script no $lang['info']['no_action'] = 'No action applicable'; +$lang['edit']['sogo_visible'] = 'Alias is visible in SOGo'; +$lang['edit']['sogo_visible_info'] = 'This option only affects objects, that can be displayed in SOGo (shared or non-shared alias addresses pointing to at least one local mailbox).'; +$lang['mailbox']['sogo_visible'] = 'Alias is visible in SOGo'; +$lang['mailbox']['sogo_visible_y'] = 'Show alias in SOGo'; +$lang['mailbox']['sogo_visible_n'] = 'Hide alias in SOGo'; $lang['edit']['syncjob'] = 'Edit sync job'; $lang['edit']['client_id'] = 'Client ID'; $lang['edit']['client_secret'] = 'Client secret'; diff --git a/data/web/mailbox.php b/data/web/mailbox.php index d254dc50..fc2fc9c6 100644 --- a/data/web/mailbox.php +++ b/data/web/mailbox.php @@ -40,7 +40,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
+
-
+
-
+
-
+
-
+
@@ -199,7 +202,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
+
-
+
-
+
-
+
-