2 # A single page just for editing smtpd_client_restrictions
3 # XXX editing access maps?
5 require './postfix-lib.pl';
7 $access{'client'} || &error($text{'client_ecannot'});
8 &ui_print_header(undef, $text{'client_title'}, "");
10 $default = $text{'opts_default'};
11 $none = $text{'opts_none'};
12 $no_ = $text{'opts_no'};
14 print &ui_form_start("save_client.cgi", "post");
15 print &ui_table_start($text{'client_title'}, undef, 2);
17 # Parse current settings, by building a map from names to indexes
18 @opts = split(/[\s,]+/, &get_current_value('smtpd_client_restrictions'));
19 for(my $i=0; $i<@opts; $i++) {
20 $opts{$opts[$i]} ||= [ ];
21 push(@{$opts{$opts[$i]}}, $i);
24 # Add binary restrictions to list
27 foreach $r (&list_client_restrictions()) {
28 push(@grid, &ui_checkbox("client", $r, $text{'sasl_'.$r},
29 defined($opts{$r})), undef);
33 # Add restrictions with values
34 foreach $r (&list_multi_client_restrictions()) {
38 $vals = join(" ", map { $opts[$_+1] } @v);
40 push(@grid, &ui_checkbox("client", $r, $text{'sasl_'.$r},
42 &ui_textbox("value_$r", $vals, 60).
43 ($r eq "check_client_access" ?
44 " ".&map_chooser_button("value_$r", $r) : ""));
47 $done{$opts[$v+1]} = 1;
49 if ($r eq "check_client_access" && @v) {
50 # Can show client access map
51 $has_client_access = 1;
55 # Show text field for the rest
56 @rest = grep { !$done{$_} } @opts;
58 push(@grid, &ui_checkbox("other", 1, $text{'client_other'}, 1),
59 &ui_textbox("other_list", join(" ", @rest), 40));
63 print &ui_table_row($text{'client_restrict'},
64 &ui_radio("client_def", @opts ? 0 : 1,
65 [ [ 1, $text{'client_restrict1'} ],
66 [ 0, $text{'client_restrict0'} ] ])."<br>\n".
67 &ui_grid_table(\@grid, 2));
69 print &ui_table_end();
70 print &ui_form_end([ [ undef, $text{'save'} ] ]);
72 if ($has_client_access) {
74 &generate_map_edit("smtpd_client_restrictions:check_client_access",
75 $text{'map_click'}." ".
76 "<font size=\"-1\">".&hlink("$text{'help_map_format'}",
77 "access")."</font>\n<br>\n", 1,
78 $text{'mapping_client'}, $text{'header_value'});
81 &ui_print_footer("", $text{'index_return'});