diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index d728794b..508f8049 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -348,6 +348,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$active = intval($_data['active']);
$relay_all_recipients = intval($_data['relay_all_recipients']);
$backupmx = intval($_data['backupmx']);
+ $gal = intval($_data['gal']);
($relay_all_recipients == 1) ? $backupmx = '1' : null;
if (!is_valid_domain_name($domain)) {
$_SESSION['return'][] = array(
@@ -391,8 +392,8 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
);
return false;
}
- $stmt = $pdo->prepare("INSERT INTO `domain` (`domain`, `description`, `aliases`, `mailboxes`, `maxquota`, `quota`, `backupmx`, `active`, `relay_all_recipients`)
- VALUES (:domain, :description, :aliases, :mailboxes, :maxquota, :quota, :backupmx, :active, :relay_all_recipients)");
+ $stmt = $pdo->prepare("INSERT INTO `domain` (`domain`, `description`, `aliases`, `mailboxes`, `maxquota`, `quota`, `backupmx`, `gal`, `active`, `relay_all_recipients`)
+ VALUES (:domain, :description, :aliases, :mailboxes, :maxquota, :quota, :backupmx, :gal, :active, :relay_all_recipients)");
$stmt->execute(array(
':domain' => $domain,
':description' => $description,
@@ -401,6 +402,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
':maxquota' => $maxquota,
':quota' => $quota,
':backupmx' => $backupmx,
+ ':gal' => $gal,
':active' => $active,
':relay_all_recipients' => $relay_all_recipients
));
@@ -1738,13 +1740,26 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
}
if ($_SESSION['mailcow_cc_role'] == "domainadmin" &&
hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
- $description = $_data['description'];
- $active = intval($_data['active']);
+ $is_now = mailbox('get', 'domain_details', $domain);
+ if (!empty($is_now)) {
+ $gal = (isset($_data['gal'])) ? intval($_data['gal']) : $is_now['gal_int'];
+ $description = (!empty($_data['description'])) ? $_data['description'] : $is_now['description'];
+ }
+ else {
+ $_SESSION['return'][] = array(
+ 'type' => 'danger',
+ 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
+ 'msg' => 'domain_invalid'
+ );
+ continue;
+ }
$stmt = $pdo->prepare("UPDATE `domain` SET
- `description` = :description
+ `description` = :description,
+ `gal` = :gal
WHERE `domain` = :domain");
$stmt->execute(array(
':description' => $description,
+ ':gal' => $gal,
':domain' => $domain
));
$_SESSION['return'][] = array(
@@ -1758,6 +1773,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
if (!empty($is_now)) {
$active = (isset($_data['active'])) ? intval($_data['active']) : $is_now['active_int'];
$backupmx = (isset($_data['backupmx'])) ? intval($_data['backupmx']) : $is_now['backupmx_int'];
+ $gal = (isset($_data['gal'])) ? intval($_data['gal']) : $is_now['gal_int'];
$relay_all_recipients = (isset($_data['relay_all_recipients'])) ? intval($_data['relay_all_recipients']) : $is_now['relay_all_recipients_int'];
$relayhost = (isset($_data['relayhost'])) ? intval($_data['relayhost']) : $is_now['relayhost'];
$aliases = (!empty($_data['aliases'])) ? $_data['aliases'] : $is_now['max_num_aliases_for_domain'];
@@ -1844,6 +1860,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$stmt = $pdo->prepare("UPDATE `domain` SET
`relay_all_recipients` = :relay_all_recipients,
`backupmx` = :backupmx,
+ `gal` = :gal,
`active` = :active,
`quota` = :quota,
`maxquota` = :maxquota,
@@ -1855,6 +1872,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$stmt->execute(array(
':relay_all_recipients' => $relay_all_recipients,
':backupmx' => $backupmx,
+ ':gal' => $gal,
':active' => $active,
':quota' => $quota,
':maxquota' => $maxquota,
@@ -2789,9 +2807,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
`relayhost`,
`relay_all_recipients` as `relay_all_recipients_int`,
`backupmx` as `backupmx_int`,
+ `gal` as `gal_int`,
`active` as `active_int`,
CASE `relay_all_recipients` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `relay_all_recipients`,
CASE `backupmx` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `backupmx`,
+ CASE `gal` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `gal`,
CASE `active` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `active`
FROM `domain` WHERE `domain`= :domain");
$stmt->execute(array(
@@ -2824,7 +2844,9 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$domaindata['max_quota_for_domain'] = $row['quota'] * 1048576;
$domaindata['relayhost'] = $row['relayhost'];
$domaindata['backupmx'] = $row['backupmx'];
+ $domaindata['gal'] = $row['gal'];
$domaindata['backupmx_int'] = $row['backupmx_int'];
+ $domaindata['gal_int'] = $row['gal_int'];
$domaindata['rl'] = $rl;
$domaindata['active'] = $row['active'];
$domaindata['active_int'] = $row['active_int'];
diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php
index 0c3323ab..2c961890 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 = "14012019_0717";
+ $db_version = "16012019_0717";
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
@@ -181,6 +181,7 @@ function init_db_schema() {
"attr" => "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC"
),
"domain" => array(
+ // Todo: Move some attributes to json
"cols" => array(
"domain" => "VARCHAR(255) NOT NULL",
"description" => "VARCHAR(255)",
@@ -190,6 +191,7 @@ function init_db_schema() {
"quota" => "BIGINT(20) NOT NULL DEFAULT '102400'",
"relayhost" => "VARCHAR(255) NOT NULL DEFAULT '0'",
"backupmx" => "TINYINT(1) NOT NULL DEFAULT '0'",
+ "gal" => "TINYINT(1) NOT NULL DEFAULT '1'",
"relay_all_recipients" => "TINYINT(1) NOT NULL DEFAULT '0'",
"created" => "DATETIME(0) NOT NULL DEFAULT NOW(0)",
"modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP",
diff --git a/data/web/lang/lang.de.php b/data/web/lang/lang.de.php
index c28bf289..eb89d62c 100644
--- a/data/web/lang/lang.de.php
+++ b/data/web/lang/lang.de.php
@@ -344,6 +344,8 @@ $lang['edit']['max_mailboxes'] = 'Max. Mailboxanzahl:';
$lang['edit']['title'] = 'Objekt bearbeiten';
$lang['edit']['target_address'] = 'Ziel-Adresse(n) (getrennt durch Komma):';
$lang['edit']['active'] = 'Aktiv';
+$lang['edit']['gal'] = 'Globales Adressbuch';
+$lang['edit']['gal_info'] = 'Das Globale Adressbuch enthält alle Objekte einer Domain und kann durch keinen Benutzer editiert werden. Zum Anwenden einer Änderung muss SOGo neugestartet werden.';
$lang['edit']['force_pw_update'] = 'Erzwinge Passwortänderung bei nächstem Login';
$lang['edit']['force_pw_update_info'] = 'Dem Benutzer wird lediglich der Zugang zur mailcow UI ermöglicht.';
$lang['edit']['sogo_access'] = 'SOGo Zugriffsrecht';
diff --git a/data/web/lang/lang.en.php b/data/web/lang/lang.en.php
index f9d352be..32c05630 100644
--- a/data/web/lang/lang.en.php
+++ b/data/web/lang/lang.en.php
@@ -357,6 +357,8 @@ $lang['edit']['max_mailboxes'] = 'Max. possible mailboxes';
$lang['edit']['title'] = 'Edit object';
$lang['edit']['target_address'] = 'Goto address/es (comma-separated)';
$lang['edit']['active'] = 'Active';
+$lang['edit']['gal'] = 'Global Address List';
+$lang['edit']['gal_info'] = 'The GAL contains all objects of a domain and cannot be edited by any user. Restart SOGo to apply changes.';
$lang['edit']['force_pw_update'] = 'Force password update at next login';
$lang['edit']['force_pw_update_info'] = 'This user will only be able to login to mailcow UI.';
$lang['edit']['sogo_access'] = 'Grant access to SOGo';