From 27caea6ca814332786158369f4d514b1929c12d5 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Tue, 26 Jul 2011 19:46:08 +0000 Subject: [PATCH] create-domain.php: - default aliases were always created, even when unchecking the checkbox (to be exact: after my last commit yesterday, they were never created) This bug was introduced in r867 (setting the default to "on") in combination with isset() falling back to the default value. For an unchecked checkbox, this means that it always used the default fallback which was "on" since r867. (Does _not_ affect the 2.3 branch.) - replaced two
with a TODO ;-) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1135 a1433add-5e2c-0410-b055-b7f2511e0802 --- create-domain.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/create-domain.php b/create-domain.php index f5e81b17..6d2cd482 100644 --- a/create-domain.php +++ b/create-domain.php @@ -48,12 +48,19 @@ $form_fields = array( 'fMaxquota' => array('type' => 'int', 'default' => $CONF['maxquota']), 'fDomainquota' => array('type' => 'int', 'default' => $CONF['domain_quota_default']), 'fTransport' => array('type' => 'str', 'default' => $CONF['transport_default'], 'options' => $CONF['transport_options']), - 'fDefaultaliases' => array('type' => 'str', 'default' => 'on', 'options' => array('on', 'off')), - 'fBackupmx' => array('type' => 'str', 'default' => 'off', 'options' => array('on', 'off')) + 'fDefaultaliases' => array('type' => 'bool', 'default' => 'on', 'options' => array('on', 'off')), + 'fBackupmx' => array('type' => 'bool', 'default' => 'off', 'options' => array('on', 'off')) ); +$fDefaultaliases = ""; +$tDefaultaliases = ""; + +# TODO: this foreach block should only be executed for POST foreach($form_fields as $key => $default) { - if(isset($_POST[$key]) && (strlen($_POST[$key]) > 0)) { + if($default['type'] == 'bool' && $_SERVER['REQUEST_METHOD'] == "POST") { + $$key = escape_string(safepost($key, 'off')); # isset for unchecked checkboxes is always false + } + elseif (isset($_POST[$key]) && (strlen($_POST[$key]) > 0)) { $$key = escape_string($_POST[$key]); } else { @@ -74,9 +81,6 @@ foreach($form_fields as $key => $default) { $fDomain = strtolower($fDomain); -$fDefaultaliases = ""; -$tDefaultaliases = ""; - if ($_SERVER['REQUEST_METHOD'] == "GET") { /* default values as set above */ @@ -130,7 +134,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") $result = db_query($sql_query); if ($result['rows'] != 1) { - $pAdminCreate_domain_domain_text_error = $PALANG['pAdminCreate_domain_result_error'] . "
($fDomain)
"; + $pAdminCreate_domain_domain_text_error = $PALANG['pAdminCreate_domain_result_error'] . "
($fDomain)"; # TODO: remove a sprintf string } else { @@ -142,7 +146,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified) VALUES ('$address','$goto','$fDomain',NOW(),NOW())"); } } - flash_info($PALANG['pAdminCreate_domain_result_success'] . "
($fDomain)
"); + flash_info($PALANG['pAdminCreate_domain_result_success'] . "
($fDomain)"); # TODO: use a sprintf string } if (!domain_postcreation($fDomain)) {