From 14e57cf80f37d434e219f685f8c095104385c28b Mon Sep 17 00:00:00 2001 From: andryyy Date: Sat, 30 Mar 2019 19:14:24 +0100 Subject: [PATCH] [Web] Add ACL for unlimited quota (default 0) --- data/web/inc/functions.mailbox.inc.php | 17 +++++++++++++++++ data/web/inc/init_db.inc.php | 3 ++- data/web/lang/lang.de.php | 2 ++ data/web/lang/lang.en.php | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index 6ecb3a94..70dd0e1f 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -757,6 +757,14 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $password2 = $_data['password2']; $name = ltrim(rtrim($_data['name'], '>'), '<'); $quota_m = intval($_data['quota']); + if ((!isset($_SESSION['acl']['unlimited_quota']) || $_SESSION['acl']['quarantine_notification'] != "1") && $quota_m === 0) { + $_SESSION['return'][] = array( + 'type' => 'danger', + 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), + 'msg' => 'unlimited_quota_acl' + ); + return false; + } if (empty($name)) { $name = $local_part; } @@ -2000,6 +2008,15 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ); continue; } + // if already 0 == ok + if ((!isset($_SESSION['acl']['unlimited_quota']) || $_SESSION['acl']['unlimited_quota'] != "1") && ($quota_m == 0 && $is_now['quota'] != 0)) { + $_SESSION['return'][] = array( + 'type' => 'danger', + 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), + 'msg' => 'unlimited_quota_acl' + ); + return false; + } $stmt = $pdo->prepare("SELECT `quota`, `maxquota` FROM `domain` WHERE `domain` = :domain"); diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php index a66d2ab3..3c553bfd 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 = "27012019_1217"; + $db_version = "30032019_1905"; $stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -464,6 +464,7 @@ function init_db_schema() { "filters" => "TINYINT(1) NOT NULL DEFAULT '1'", "ratelimit" => "TINYINT(1) NOT NULL DEFAULT '1'", "spam_policy" => "TINYINT(1) NOT NULL DEFAULT '1'", + "unlimited_quota" => "TINYINT(1) NOT NULL DEFAULT '0'", "alias_domains" => "TINYINT(1) NOT NULL DEFAULT '0'", ), "keys" => array( diff --git a/data/web/lang/lang.de.php b/data/web/lang/lang.de.php index b5fc4642..4d0352d0 100644 --- a/data/web/lang/lang.de.php +++ b/data/web/lang/lang.de.php @@ -19,6 +19,7 @@ $lang['footer']['cancel'] = 'Abbrechen'; $lang['footer']['hibp_nok'] = 'Übereinstimmung gefunden! Dieses Passwort ist potentiell gefährlich!'; $lang['footer']['hibp_ok'] = 'Keine Übereinstimmung gefunden.'; +$lang['danger']['unlimited_quota_acl'] = "Unendliche Quota untersagt durch ACL"; $lang['danger']['mysql_error'] = "MySQL Fehler: %s"; $lang['danger']['redis_error'] = "Redis Fehler: %s"; $lang['danger']['unknown_tfa_method'] = "Unbekannte TFA Methode"; @@ -405,6 +406,7 @@ $lang['acl']['bcc_maps'] = 'BCC Maps'; $lang['acl']['filters'] = 'Filter'; $lang['acl']['ratelimit'] = 'Rate limit'; $lang['acl']['recipient_maps'] = 'Empfängerumschreibungen'; +$lang['acl']['unlimited_quota'] = 'Unendliche Quota für Mailboxen'; $lang['acl']['prohibited'] = 'Untersagt durch Richtlinie'; $lang['mailbox']['quarantine_notification'] = 'Quarantäne-Benachrichtigung'; diff --git a/data/web/lang/lang.en.php b/data/web/lang/lang.en.php index 0329a92d..3efe810e 100644 --- a/data/web/lang/lang.en.php +++ b/data/web/lang/lang.en.php @@ -20,6 +20,7 @@ $lang['footer']['cancel'] = 'Cancel'; $lang['footer']['hibp_nok'] = 'Matched! This is a potentially dangerous password!'; $lang['footer']['hibp_ok'] = 'No match found.'; +$lang['danger']['unlimited_quota_acl'] = "Unlimited quota prohibited by ACL"; $lang['danger']['mysql_error'] = "MySQL error: %s"; $lang['danger']['redis_error'] = "Redis error: %s"; $lang['danger']['unknown_tfa_method'] = "Unknown TFA method"; @@ -418,6 +419,7 @@ $lang['acl']['bcc_maps'] = 'BCC maps'; $lang['acl']['filters'] = 'Filters'; $lang['acl']['ratelimit'] = 'Rate limit'; $lang['acl']['recipient_maps'] = 'Recipient maps'; +$lang['acl']['unlimited_quota'] = 'Unlimited quota for mailboxes'; $lang['acl']['prohibited'] = 'Prohibited by ACL'; $lang['mailbox']['quarantine_notification'] = 'Quarantine notifications';