Handle hostnames with upper-case letters
[webmin.git] / servers / acl_security.pl
1
2 require 'servers-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the servers module
6 sub acl_security_form
7 {
8 print "<tr> <td valign=top><b>$text{'acl_servers'}</b></td>\n";
9 print "<td colspan=3>\n";
10 printf "<input type=radio name=servers_def value=1 %s> %s\n",
11         $_[0]->{'servers'} eq '*' ? 'checked' : '', $text{'acl_sall'};
12 printf "<input type=radio name=servers_def value=0 %s> %s<br>\n",
13         $_[0]->{'servers'} eq '*' ? '' : 'checked', $text{'acl_ssel'};
14 print "<select name=servers multiple size=4 width=15>\n";
15 local @servers = sort { $a->{'host'} cmp $b->{'host'} } &list_servers();
16 local ($z, %zcan);
17 map { $zcan{$_}++ } split(/\s+/, $_[0]->{'servers'});
18 foreach $z (sort { $a->{'value'} cmp $b->{'value'} } @servers) {
19         printf "<option value='%s' %s>%s\n",
20                 $z->{'id'},
21                 $zcan{$z->{'host'}} || $zcan{$z->{'id'}} ? "selected" : "",
22                 $z->{'host'} ;
23         }
24 print "</select></td></tr>\n";
25
26 print "<tr> <td><b>$text{'acl_edit'}</b></td> <td>\n";
27 print &ui_yesno_radio("edit", $_[0]->{'edit'}),"</td>\n";
28
29 print "<td><b>$text{'acl_find'}</b></td> <td>\n";
30 print &ui_yesno_radio("find", $_[0]->{'find'}),"</td> </tr>\n";
31
32 print "<tr> <td><b>$text{'acl_auto'}</b></td> <td>\n";
33 print &ui_yesno_radio("auto", $_[0]->{'auto'}),"</td>\n";
34
35 print "<td><b>$text{'acl_add'}</b></td> <td>\n";
36 print &ui_yesno_radio("add", $_[0]->{'add'}),"</td> </tr>\n";
37
38 print "<tr> <td><b>$text{'acl_forcefast'}</b></td> <td>\n";
39 print &ui_yesno_radio("forcefast", $_[0]->{'forcefast'}),"</td>\n";
40
41 print "<td><b>$text{'acl_forcetype'}</b></td> <td>\n";
42 print &ui_yesno_radio("forcetype", $_[0]->{'forcetype'}),"</td> </tr>\n";
43
44 print "<tr> <td><b>$text{'acl_forcelink'}</b></td> <td>\n";
45 print &ui_yesno_radio("forcelink", $_[0]->{'forcelink'}),"</td>\n";
46
47 print "<td><b>$text{'acl_links'}</b></td> <td>\n";
48 print &ui_yesno_radio("links", $_[0]->{'links'}),"</td> </tr>\n";
49 }
50
51 # acl_security_save(&options)
52 # Parse the form for security options for the servers module
53 sub acl_security_save
54 {
55 if ($in{'servers_def'}) {
56         $_[0]->{'servers'} = "*";
57         }
58 else {
59         $_[0]->{'servers'} = join(" ", split(/\0/, $in{'servers'}));
60         }
61 $_[0]->{'edit'} = $in{'edit'};
62 $_[0]->{'find'} = $in{'find'};
63 $_[0]->{'auto'} = $in{'auto'};
64 $_[0]->{'add'} = $in{'add'};
65 $_[0]->{'forcefast'} = $in{'forcefast'};
66 $_[0]->{'forcetype'} = $in{'forcetype'};
67 $_[0]->{'forcelink'} = $in{'forcelink'};
68 $_[0]->{'links'} = $in{'links'};
69 }
70