[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
This commit is contained in:
andryyy
2019-09-22 15:10:56 +02:00
parent baba546c7a
commit c3be04560b
12 changed files with 78 additions and 30 deletions

View File

@@ -146,6 +146,18 @@ $(document).ready(function() {
}
});
// Reload after session timeout
var session_lifetime = <?=(intval($SESSION_LIFETIME) * 1000) + 15000;?>;
<?php
if (isset($_SESSION['mailcow_cc_username'])):
?>
setTimeout(function() {
location.reload();
}, session_lifetime);
<?php
endif;
?>
// CSRF
$('<input type="hidden" value="<?= $_SESSION['CSRF']['TOKEN']; ?>">').attr('name', 'csrf_token').appendTo('form');
if (sessionStorage.scrollTop != "undefined") {

View File

@@ -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'])) {

View File

@@ -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(

View File

@@ -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";