Handle hostnames with upper-case letters
[webmin.git] / postfix / edit_mapping.cgi
1 #!/usr/local/bin/perl
2 #
3 # postfix-module by Guillaume Cottenceau <gc@mandrakesoft.com>,
4 # for webmin by Jamie Cameron
5
6 # Edit a mapping
7
8 require './postfix-lib.pl';
9 &ReadParse();
10
11 &ui_print_header(undef, $text{'edit_map_title'}, "");
12
13 my $new_one = 0;
14 my $num;
15 ## added to split main_parameter:sub_parameter
16 my ($mainparm,$subparm)=split /:/,$in{'map_name'};
17
18 if (!exists($in{'num'}))
19 {
20     $num = &init_new_mapping($in{'map_name'});
21     $new_one = 1;
22 }
23 else
24 {
25     $num = $in{'num'};
26 }
27
28 my $maps = &get_maps($in{'map_name'});
29 my %map;
30
31 foreach $trans (@{$maps})
32 {
33     if ($trans->{'number'} == $num) { %map = %{$trans}; }
34 }    
35
36 print &ui_form_start("save_map.cgi");
37 print &ui_hidden("num", $num),"\n";
38 print &ui_hidden("map_name", $in{'map_name'}),"\n";
39 print &ui_table_start($text{'edit_map_title'}, "width=100%", 2);
40
41 # Show map comment
42 if (&can_map_comments($in{'map_name'})) {
43         print &ui_table_row($text{'mapping_cmt'},
44                             &ui_textbox("cmt", $map{'cmt'}, 50));
45         }
46
47 ##$nfunc = "edit_name_".$in{'map_name'};
48 ## modified to capture subparameters
49 $nfunc="edit_name_"; $nfunc.=($subparm)? $subparm : $mainparm;
50 if (defined(&$nfunc)) {
51         print &$nfunc(\%map);
52         }
53 else {
54         print &ui_table_row($text{'mapping_name'},
55                             &ui_textbox("name", $map{'name'}, 40));
56         }
57
58 ##$vfunc = "edit_value_".$in{'map_name'};
59 ## modified to capture subparameters
60 $vfunc="edit_value_"; $vfunc.=($subparm)? $subparm : $mainparm;
61 if (defined(&$vfunc)) {
62         print &$vfunc(\%map);
63         }
64 else {
65         print &ui_table_row($text{'mapping_value'},
66                             &ui_textbox("value", $map{'value'}, 40));
67         }
68
69 print &ui_table_end();
70 print &ui_form_end([ [ "save", $text{'map_save'} ],
71              $new_one ? ( ) : ( [ "delete", $text{'delete_map'} ] )
72              ]);
73
74 if ($in{'map_name'} eq $virtual_maps) {
75         &ui_print_footer("virtual.cgi", $text{'virtual_return'});
76         }
77 elsif ($in{'map_name'} eq 'canonical_maps') {
78         &ui_print_footer($ENV{'HTTP_REFERER'},
79                          $text{'canonical_return'});
80         }
81 elsif ($in{'map_name'} eq 'sender_canonical_maps') {
82         &ui_print_footer($ENV{'HTTP_REFERER'},
83                          $text{'canonical_return_sender'});
84         }
85 elsif ($in{'map_name'} eq 'recipient_canonical_maps') {
86         &ui_print_footer($ENV{'HTTP_REFERER'},
87                          $text{'canonical_return_recipient'});
88         }
89 elsif ($in{'map_name'} eq 'transport_maps') {
90         &ui_print_footer("transport.cgi", $text{'transport_return'});
91         }
92 elsif ($in{'map_name'} eq 'relocated_maps') {
93         &ui_print_footer("relocated.cgi", $text{'relocated_return'});
94         }
95 elsif ($in{'map_name'} eq 'header_checks') {
96         &ui_print_footer("header.cgi", $text{'header_return'});
97         }
98 elsif ($in{'map_name'} eq 'body_checks') {
99         &ui_print_footer("body.cgi", $text{'body_return'});
100         }
101 elsif ($in{'map_name'} =~ /^smtpd_client_restrictions:/) {
102         &ui_print_footer("client.cgi", $text{'client_return'});
103         }
104 else {
105         &ui_print_footer("", $text{'index_return'});
106         }
107