diff --git a/postfix/general.cgi b/postfix/general.cgi index 477e0c03b..6aae831aa 100755 --- a/postfix/general.cgi +++ b/postfix/general.cgi @@ -89,7 +89,7 @@ print &ui_table_start($text{'general_title_others'}, "width=100%", 4); &option_radios_freefield("mynetworks", 60, $text{'default'}); &option_select("mynetworks_style", - [ [ "", $text{'default'} ], + [ [ &resolve_current_value("mynetworks_style"), $text{'default'} ], [ "subnet", $text{'opts_mynetworks_subnet'} ], [ "class", $text{'opts_mynetworks_class'} ], [ "host", $text{'opts_mynetworks_host'} ] ]); diff --git a/postfix/postfix-lib.pl b/postfix/postfix-lib.pl index 2d2f22e95..db629f648 100755 --- a/postfix/postfix-lib.pl +++ b/postfix/postfix-lib.pl @@ -163,6 +163,24 @@ if ($key) { return $out; } +# resolve_current_value(parameter_name) +# Returns the value of the parameter, with compatibility-level conditionals +sub resolve_current_value +{ +my ($parameter_name) = @_; + +my $raw_value = &get_current_value($parameter_name); +my $compatibility_level = &get_current_value("compatibility_level"); + +if ($raw_value =~ /\{\{\$compatibility_level\}\s*([<>=!]+)\s*\{(\d+)\}\s*\?\s*\{(.*?)\}\s*:\s*\{(.*?)\}\}/) { + my ($op, $lvl, $tval, $fval) = ($1, $2, $3, $4); + return undef if ($op !~ /^([<>]=?|==|!=)$/); + return eval "\$compatibility_level $op $lvl" ? $tval : $fval; + } + +return $raw_value; +} + # if_default_value(parameter_name) # returns if the value is the default value sub if_default_value