From ef392ef6ba44c103ac9eb7e77db779f77736f032 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Thu, 17 Nov 2022 08:36:03 +0100 Subject: [PATCH] add demo_mode for mailcow ui --- data/web/inc/functions.customize.inc.php | 28 ++++++++++++++++++++++++ data/web/inc/prerequisites.inc.php | 2 ++ data/web/lang/lang.de-de.json | 1 + data/web/lang/lang.en-gb.json | 1 + docker-compose.yml | 1 + 5 files changed, 33 insertions(+) diff --git a/data/web/inc/functions.customize.inc.php b/data/web/inc/functions.customize.inc.php index 1916b918..16c5c036 100644 --- a/data/web/inc/functions.customize.inc.php +++ b/data/web/inc/functions.customize.inc.php @@ -2,8 +2,18 @@ function customize($_action, $_item, $_data = null) { global $redis; global $lang; + switch ($_action) { case 'add': + // disable functionality when demo mode is enabled + if ($GLOBALS["DEMO_MODE"]) { + $_SESSION['return'][] = array( + 'type' => 'danger', + 'log' => array(__FUNCTION__, $_action, $_item, $_data), + 'msg' => 'demo_mode_enabled' + ); + return false; + } if ($_SESSION['mailcow_cc_role'] != "admin") { $_SESSION['return'][] = array( 'type' => 'danger', @@ -72,6 +82,15 @@ function customize($_action, $_item, $_data = null) { } break; case 'edit': + // disable functionality when demo mode is enabled + if ($GLOBALS["DEMO_MODE"]) { + $_SESSION['return'][] = array( + 'type' => 'danger', + 'log' => array(__FUNCTION__, $_action, $_item, $_data), + 'msg' => 'demo_mode_enabled' + ); + return false; + } if ($_SESSION['mailcow_cc_role'] != "admin") { $_SESSION['return'][] = array( 'type' => 'danger', @@ -144,6 +163,15 @@ function customize($_action, $_item, $_data = null) { } break; case 'delete': + // disable functionality when demo mode is enabled + if ($GLOBALS["DEMO_MODE"]) { + $_SESSION['return'][] = array( + 'type' => 'danger', + 'log' => array(__FUNCTION__, $_action, $_item, $_data), + 'msg' => 'demo_mode_enabled' + ); + return false; + } if ($_SESSION['mailcow_cc_role'] != "admin") { $_SESSION['return'][] = array( 'type' => 'danger', diff --git a/data/web/inc/prerequisites.inc.php b/data/web/inc/prerequisites.inc.php index 02b09e74..754d98d5 100644 --- a/data/web/inc/prerequisites.inc.php +++ b/data/web/inc/prerequisites.inc.php @@ -2,6 +2,8 @@ // check for development mode $DEV_MODE = (getenv('DEV_MODE') == 'y'); +// check for demo mode +$DEMO_MODE = (getenv('DEMO_MODE') == 'y'); // Slave does not serve UI /* if (!preg_match('/y|yes/i', getenv('MASTER'))) { diff --git a/data/web/lang/lang.de-de.json b/data/web/lang/lang.de-de.json index 925e0f2b..46e31c90 100644 --- a/data/web/lang/lang.de-de.json +++ b/data/web/lang/lang.de-de.json @@ -352,6 +352,7 @@ "bcc_must_be_email": "BCC-Ziel %s ist keine gültige E-Mail-Adresse", "comment_too_long": "Kommentarfeld darf maximal 160 Zeichen enthalten", "defquota_empty": "Standard-Quota darf nicht 0 sein", + "demo_mode_enabled": "Demo Mode ist aktiviert", "description_invalid": "Ressourcenbeschreibung für %s ist ungültig", "dkim_domain_or_sel_exists": "Ein DKIM-Key für die Domain \"%s\" existiert und wird nicht überschrieben", "dkim_domain_or_sel_invalid": "DKIM-Domain oder Selector nicht korrekt: %s", diff --git a/data/web/lang/lang.en-gb.json b/data/web/lang/lang.en-gb.json index ed685730..08494e2d 100644 --- a/data/web/lang/lang.en-gb.json +++ b/data/web/lang/lang.en-gb.json @@ -352,6 +352,7 @@ "bcc_must_be_email": "BCC destination %s is not a valid email address", "comment_too_long": "Comment too long, max 160 chars allowed", "defquota_empty": "Default quota per mailbox must not be 0.", + "demo_mode_enabled": "Demo Mode is enabled", "description_invalid": "Resource description for %s is invalid", "dkim_domain_or_sel_exists": "A DKIM key for \"%s\" exists and will not be overwritten", "dkim_domain_or_sel_invalid": "DKIM domain or selector invalid: %s", diff --git a/docker-compose.yml b/docker-compose.yml index 0a35e97d..fec3253e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -160,6 +160,7 @@ services: - ALLOW_ADMIN_EMAIL_LOGIN=${ALLOW_ADMIN_EMAIL_LOGIN:-n} - MASTER=${MASTER:-y} - DEV_MODE=${DEV_MODE:-n} + - DEMO_MODE=${DEMO_MODE:-n} - WEBAUTHN_ONLY_TRUSTED_VENDORS=${WEBAUTHN_ONLY_TRUSTED_VENDORS:-n} restart: always networks: