From db5a3ae47f97ff9bd21e5b0366938131aed80f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Thu, 26 Oct 2017 10:21:12 +0200 Subject: [PATCH] [Web] Start work on ACL; [Helper] Nextcloud helper script --- data/web/edit.php | 17 +++++++++++++++++ data/web/inc/functions.inc.php | 17 +++++++++++++++++ data/web/inc/init_db.inc.php | 3 +-- data/web/lang/lang.en.php | 12 ++++++++++-- data/web/user.php | 10 ++++------ helper-scripts/nextcloud.sh | 4 ++++ 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/data/web/edit.php b/data/web/edit.php index fd6682ff..ea9424e9 100644 --- a/data/web/edit.php +++ b/data/web/edit.php @@ -457,6 +457,23 @@ if (isset($_SESSION['mailcow_cc_role'])) { + +
+ +
+ +
+
diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index 817b9c71..79a449eb 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -244,6 +244,23 @@ function set_acl() { return false; } } +function get_acl($username) { + global $pdo; + if ($_SESSION['mailcow_cc_role'] != "admin") { + return false; + } + $username = strtolower(trim($username)); + $stmt = $pdo->prepare("SELECT * FROM `user_acl` WHERE `username` = :username"); + $stmt->execute(array(':username' => $username)); + $acl = $stmt->fetch(PDO::FETCH_ASSOC); + unset($acl['username']); + if (!empty($acl)) { + return $acl; + } + else { + return false; + } +} function formatBytes($size, $precision = 2) { if(!is_numeric($size)) { return "0"; diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php index e2d18517..16f3fdf2 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 = "02102017_0748"; + $db_version = "25102017_0748"; $stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -165,7 +165,6 @@ function init_db_schema() { "delimiter_action" => "TINYINT(1) NOT NULL DEFAULT '1'", "syncjobs" => "TINYINT(1) NOT NULL DEFAULT '1'", "eas_reset" => "TINYINT(1) NOT NULL DEFAULT '1'", - "eas_autoconfig" => "TINYINT(1) NOT NULL DEFAULT '1'" ), "keys" => array( "fkey" => array( diff --git a/data/web/lang/lang.en.php b/data/web/lang/lang.en.php index 527ded11..c29d8e17 100644 --- a/data/web/lang/lang.en.php +++ b/data/web/lang/lang.en.php @@ -141,9 +141,9 @@ $lang['user']['weeks'] = 'Weeks'; $lang['user']['spamfilter'] = 'Spam filter'; $lang['admin']['spamfilter'] = 'Spam filter'; $lang['user']['spamfilter_wl'] = 'Whitelist'; -$lang['user']['spamfilter_wl_desc'] = 'Whitelisted email addresses to never classify as spam. Wildcards maybe used.'; +$lang['user']['spamfilter_wl_desc'] = 'Whitelisted email addresses to never classify as spam. Wildcards may be used.'; $lang['user']['spamfilter_bl'] = 'Blacklist'; -$lang['user']['spamfilter_bl_desc'] = 'Blacklisted email addresses to always classify as spam and reject. Wildcards maybe used.'; +$lang['user']['spamfilter_bl_desc'] = 'Blacklisted email addresses to always classify as spam and reject. Wildcards may be used.'; $lang['user']['spamfilter_behavior'] = 'Rating'; $lang['user']['spamfilter_table_rule'] = 'Rule'; $lang['user']['spamfilter_table_action'] = 'Action'; @@ -537,3 +537,11 @@ $lang['admin']['remove_row'] = "Remove row"; $lang['admin']['add_row'] = "Add row"; $lang['admin']['reset_default'] = "Reset to default"; $lang['admin']['merged_vars_hint'] = 'Greyed out rows were merged from vars.inc.(local.)php and cannot be modified.'; + +$lang['edit']['tls_policy'] = "Change TLS policy"; +$lang['edit']['spam_score'] = "Set a custom spam score"; +$lang['edit']['spam_policy'] = "Add or remove items to white-/blacklist"; +$lang['edit']['delimiter_action'] = "Change delimiter action"; +$lang['edit']['syncjobs'] = "Add or change sync jobs"; +$lang['edit']['eas_reset'] = "Reset EAS devices"; +$lang['edit']['spam_alias'] = "Create or change time limited alias addresses"; diff --git a/data/web/user.php b/data/web/user.php index 0d95790d..50583515 100644 --- a/data/web/user.php +++ b/data/web/user.php @@ -268,8 +268,8 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '

-
- + -
- +
@@ -349,7 +348,6 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
-
@@ -358,7 +356,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == ' - +
diff --git a/helper-scripts/nextcloud.sh b/helper-scripts/nextcloud.sh index b3c23e23..08aa652c 100755 --- a/helper-scripts/nextcloud.sh +++ b/helper-scripts/nextcloud.sh @@ -2,6 +2,10 @@ [[ -z ${1} ]] && { echo "No parameters given"; exit 1; } +for bin in curl dirmngr; do + if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi +done + while [ "$1" != '' ]; do case "${1}" in -p|--purge) NC_PURGE=y && shift;;