2 # Show a form for editing an LDAP switch
4 if (-r 'ldap-client-lib.pl') {
5 require './ldap-client-lib.pl';
8 require './nis-lib.pl';
10 require './switch-lib.pl';
12 &ui_print_header(undef, $text{'eswitch_title'}, "");
14 # Get the current service
15 $conf = &get_nsswitch_config();
16 ($switch) = grep { $_->{'name'} eq $in{'name'} } @$conf;
17 $switch || &error($text{'eswitch_egone'});
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);
24 $desc = $text{'desc_'.$switch->{'name'}};
25 print &ui_table_row($text{'eswitch_name'},
26 $desc ? "$desc ($switch->{'name'})" : $switch->{'name'});
28 # Show sources in order, with fallback modes for each
30 ($allsrcs, $allowed) = &list_switch_sources();
31 foreach $s (@{$switch->{'srcs'}}, { }) {
32 @cansrcs = grep { !$allowed->{$_} ||
33 &indexof($switch->{'name'}, @{$allowed->{$_}}) >= 0 }
35 $stable = &ui_select("src_$i", $s->{'src'},
36 [ [ "", "<$text{'eswitch_none'}>" ],
37 map { [ $_, $text{'order_'.$_} || $_ ] } @cansrcs ],
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 [ [ "", "<$text{'default'}>" ],
46 map { [ $_, $text{'eswitch_'.$_} ] } @acts ]).
49 $stable .= "</table>\n";
50 print &ui_table_row($text{'eswitch_'.$i} ||
51 &text('eswitch_nth', $i+1), $stable);
55 print &ui_table_end();
56 print &ui_form_end([ [ "save", $text{'save'} ] ]);
58 &ui_print_footer("list_switches.cgi", $text{'switch_return'});