Handle hostnames with upper-case letters
[webmin.git] / ldap-client / edit_switch.cgi
1 #!/usr/local/bin/perl
2 # Show a form for editing an LDAP switch
3
4 if (-r 'ldap-client-lib.pl') {
5         require './ldap-client-lib.pl';
6         }
7 else {
8         require './nis-lib.pl';
9         }
10 require './switch-lib.pl';
11 &ReadParse();
12 &ui_print_header(undef, $text{'eswitch_title'}, "");
13
14 # Get the current service
15 $conf = &get_nsswitch_config();
16 ($switch) = grep { $_->{'name'} eq $in{'name'} } @$conf;
17 $switch || &error($text{'eswitch_egone'});
18
19 print &ui_form_start("save_switch.cgi", "post");
20 print &ui_hidden("name", $in{'name'}),"\n";
21 print &ui_table_start($text{'eswitch_header'}, undef, 2);
22
23 # Show service name
24 $desc = $text{'desc_'.$switch->{'name'}};
25 print &ui_table_row($text{'eswitch_name'},
26                     $desc ? "$desc ($switch->{'name'})" : $switch->{'name'});
27
28 # Show sources in order, with fallback modes for each
29 $i = 0;
30 ($allsrcs, $allowed) = &list_switch_sources();
31 foreach $s (@{$switch->{'srcs'}}, { }) {
32         @cansrcs = grep { !$allowed->{$_} ||
33                           &indexof($switch->{'name'}, @{$allowed->{$_}}) >= 0 }
34                         @$allsrcs;
35         $stable = &ui_select("src_$i", $s->{'src'},
36                 [ [ "", "<$text{'eswitch_none'}>" ],
37                   map { [ $_, $text{'order_'.$_} || $_ ] } @cansrcs ],
38                 1, 0, 1)."<br>\n";
39         $stable .= "<table>\n";
40         foreach $st (&list_switch_statuses()) {
41                 $stable .= "<tr> <td>".$text{'eswitch_'.$st}."</td>\n";
42                 @acts = &list_switch_actions($st);
43                 $stable .= "<td>".&ui_select(
44                         "status_".$st."_".$i, $s->{$st},
45                         [ [ "", "&lt;$text{'default'}&gt;" ],
46                           map { [ $_, $text{'eswitch_'.$_} ] } @acts ]).
47                            "</td> </tr>\n";              
48                 }
49         $stable .= "</table>\n";
50         print &ui_table_row($text{'eswitch_'.$i} ||
51                             &text('eswitch_nth', $i+1), $stable);
52         $i++;
53         }
54
55 print &ui_table_end();
56 print &ui_form_end([ [ "save", $text{'save'} ] ]);
57
58 &ui_print_footer("list_switches.cgi", $text{'switch_return'});
59