config.inc.php + all files related to alias domains

- added $CONF['alias_domain'] switch to disable alias domains
  (includes lots of whitespace changes in list-virtual.php)

functions.php:
- added some comments to boolconf()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@419 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
Christian Boltz 17 years ago
parent 711df82fc8
commit 5fa76d73d9

@ -195,6 +195,13 @@ $CONF['special_alias_control'] = 'NO';
// '0' means no limits. // '0' means no limits.
$CONF['alias_goto_limit'] = '0'; $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 // Backup
// If you don't want backup tab set this to 'NO'; // If you don't want backup tab set this to 'NO';
$CONF['backup'] = 'YES'; $CONF['backup'] = 'YES';

@ -32,6 +32,12 @@
require_once('common.php'); require_once('common.php');
authentication_require_role('admin'); authentication_require_role('admin');
if (!boolconf['alias_domain']) {
header("Location: " . $CONF['postfix_admin_url'] . "/main.php");
exit;
}
$username = authentication_get_username(); $username = authentication_get_username();
$SESSID_USERNAME = $username; $SESSID_USERNAME = $username;
if(authentication_has_role('global-admin')) { if(authentication_has_role('global-admin')) {

@ -2189,6 +2189,7 @@ function create_admin($fUsername, $fPassword, $fPassword2, $fDomains, $no_genera
/* /*
Convert $CONF['whatever'] to boolean 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) 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) { function boolconf($setting) {
global $CONF; global $CONF;
if (!isset($CONF[$setting])) { # not set if (!isset($CONF[$setting])) { # not set
# TODO: show/log error message on unknown settings?
return false; return false;
} elseif (strtoupper($CONF[$setting]) == 'YES') { # YES } elseif (strtoupper($CONF[$setting]) == 'YES') { # YES
return true; return true;
} else { # NO, unknown value } else { # NO, unknown value
# TODO: show error on unknown value? # TODO: show/log error message on unknown value?
return false; return false;
} }
} }

@ -73,50 +73,51 @@ if (!check_owner(authentication_get_username(), $fDomain)) {
} }
# Alias-Domains if (boolconf('alias_domain')) {
# first try to get a list of other domains pointing # Alias-Domains
# to this currently chosen one (aka. alias domains) # first try to get a list of other domains pointing
$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"; # to this currently chosen one (aka. alias domains)
if ('pgsql'==$CONF['database_type']) $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 ('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']); if ('pgsql'==$CONF['database_type'])
$row['active']=('t'==$row['active']) ? 1 : 0; {
$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'";
} }
} $result = db_query ($query);
# now let's see if the current domain itself is an alias for another domain $tTargetDomain = "";
$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 ($result['rows'] > 0)
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']))
{ {
if ('pgsql'==$CONF['database_type']) if($row = db_array ($result['result']))
{ {
$row['modified']=gmstrftime('%c %Z',$row['modified']); if ('pgsql'==$CONF['database_type'])
$row['active']=('t'==$row['active']) ? 1 : 0; {
$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"; $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']) if ('pgsql'==$CONF['database_type'])
{ {

@ -72,7 +72,7 @@ if ($tDisplay_next_show == 1)
print "</td></tr></table></div>\n"; print "</td></tr></table></div>\n";
if ((sizeof ($tAliasDomains) > 0) || is_array ($tTargetDomain)) if (boolconf('alias_domain') && ((sizeof ($tAliasDomains) > 0) || is_array ($tTargetDomain)))
{ {
print "<table id=\"alias_domain_table\">\n"; print "<table id=\"alias_domain_table\">\n";
print " <tr>\n"; print " <tr>\n";

@ -16,8 +16,10 @@ $submenu_virtual = _menulink($url, $PALANG['pMenu_create_mailbox']);
$url = "create-alias.php"; if (isset ($_GET['domain'])) $url .= "?domain=" . $_GET['domain']; $url = "create-alias.php"; if (isset ($_GET['domain'])) $url .= "?domain=" . $_GET['domain'];
$submenu_virtual .= _menulink($url, $PALANG['pMenu_create_alias']); $submenu_virtual .= _menulink($url, $PALANG['pMenu_create_alias']);
$url = "create-alias-domain.php"; if (isset ($_GET['domain'])) $url .= "?target_domain=" . $_GET['domain']; if (boolconf('alias_domain')) {
$submenu_virtual .= _menulink($url, $PALANG['pMenu_create_alias_domain']); $url = "create-alias-domain.php"; if (isset ($_GET['domain'])) $url .= "?target_domain=" . $_GET['domain'];
$submenu_virtual .= _menulink($url, $PALANG['pMenu_create_alias_domain']);
}
$submenu_admin = _menulink("create-admin.php", $PALANG['pAdminMenu_create_admin']); $submenu_admin = _menulink("create-admin.php", $PALANG['pAdminMenu_create_admin']);

Loading…
Cancel
Save