diff --git a/config.inc.php b/config.inc.php index f5f79d3f..d0927909 100644 --- a/config.inc.php +++ b/config.inc.php @@ -195,6 +195,13 @@ $CONF['special_alias_control'] = 'NO'; // '0' means no limits. $CONF['alias_goto_limit'] = '0'; +// Alias Domains +// Alias domains allow to "mirror" aliases and mailboxes to another domain. This makes +// configuration easier, but also requires postfix to do more database queries. +// Note: If you update from 2.2.x or earlier, you will have to update your postfix config. +// Set to 'NO' to disable alias domains. +$CONF['alias_domain'] = 'YES'; + // Backup // If you don't want backup tab set this to 'NO'; $CONF['backup'] = 'YES'; diff --git a/create-alias-domain.php b/create-alias-domain.php index d6ca4b6e..ebacc58d 100644 --- a/create-alias-domain.php +++ b/create-alias-domain.php @@ -32,6 +32,12 @@ require_once('common.php'); authentication_require_role('admin'); + +if (!boolconf['alias_domain']) { + header("Location: " . $CONF['postfix_admin_url'] . "/main.php"); + exit; +} + $username = authentication_get_username(); $SESSID_USERNAME = $username; if(authentication_has_role('global-admin')) { diff --git a/functions.inc.php b/functions.inc.php index b630fa7b..7d4963e7 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -2189,6 +2189,7 @@ function create_admin($fUsername, $fPassword, $fPassword2, $fDomains, $no_genera /* Convert $CONF['whatever'] to boolean + (obviously only useful for settings that can be YES or NO) Returns: TRUE (on YES/yes) or FALSE (on NO/no/not set/unknown value) */ @@ -2196,11 +2197,12 @@ function create_admin($fUsername, $fPassword, $fPassword2, $fDomains, $no_genera function boolconf($setting) { global $CONF; if (!isset($CONF[$setting])) { # not set + # TODO: show/log error message on unknown settings? return false; } elseif (strtoupper($CONF[$setting]) == 'YES') { # YES return true; } else { # NO, unknown value - # TODO: show error on unknown value? + # TODO: show/log error message on unknown value? return false; } } diff --git a/list-virtual.php b/list-virtual.php index 64964d30..8ad09040 100644 --- a/list-virtual.php +++ b/list-virtual.php @@ -73,50 +73,51 @@ if (!check_owner(authentication_get_username(), $fDomain)) { } -# Alias-Domains -# first try to get a list of other domains pointing -# to this currently chosen one (aka. alias domains) -$query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY $table_alias_domain.alias_domain LIMIT $fDisplay, $page_size"; -if ('pgsql'==$CONF['database_type']) -{ - $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY alias_domain LIMIT $page_size OFFSET $fDisplay"; -} -$result = db_query ($query); -$tAliasDomains = array(); -if ($result['rows'] > 0) -{ - while ($row = db_array ($result['result'])) +if (boolconf('alias_domain')) { + # Alias-Domains + # first try to get a list of other domains pointing + # to this currently chosen one (aka. alias domains) + $query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY $table_alias_domain.alias_domain LIMIT $fDisplay, $page_size"; + if ('pgsql'==$CONF['database_type']) { - if ('pgsql'==$CONF['database_type']) + $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY alias_domain LIMIT $page_size OFFSET $fDisplay"; + } + $result = db_query ($query); + $tAliasDomains = array(); + if ($result['rows'] > 0) + { + while ($row = db_array ($result['result'])) { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; + if ('pgsql'==$CONF['database_type']) + { + $row['modified']=gmstrftime('%c %Z',$row['modified']); + $row['active']=('t'==$row['active']) ? 1 : 0; + } + $tAliasDomains[] = $row; } - $tAliasDomains[] = $row; + } + # now let's see if the current domain itself is an alias for another domain + $query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; + if ('pgsql'==$CONF['database_type']) + { + $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; } -} -# now let's see if the current domain itself is an alias for another domain -$query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; -if ('pgsql'==$CONF['database_type']) -{ - $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; -} -$result = db_query ($query); -$tTargetDomain = ""; -if ($result['rows'] > 0) -{ - if($row = db_array ($result['result'])) + $result = db_query ($query); + $tTargetDomain = ""; + if ($result['rows'] > 0) { - if ('pgsql'==$CONF['database_type']) + if($row = db_array ($result['result'])) { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; + if ('pgsql'==$CONF['database_type']) + { + $row['modified']=gmstrftime('%c %Z',$row['modified']); + $row['active']=('t'==$row['active']) ? 1 : 0; + } + $tTargetDomain = $row; } - $tTargetDomain = $row; } } - $query = "SELECT $table_alias.address,$table_alias.goto,$table_alias.modified,$table_alias.active FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $fDisplay, $page_size"; if ('pgsql'==$CONF['database_type']) { diff --git a/templates/list-virtual.php b/templates/list-virtual.php index dbbffed8..f52215b6 100644 --- a/templates/list-virtual.php +++ b/templates/list-virtual.php @@ -72,7 +72,7 @@ if ($tDisplay_next_show == 1) print "\n"; -if ((sizeof ($tAliasDomains) > 0) || is_array ($tTargetDomain)) +if (boolconf('alias_domain') && ((sizeof ($tAliasDomains) > 0) || is_array ($tTargetDomain))) { print "