Handle hostnames with upper-case letters
[webmin.git] / lpadmin / acl_security.pl
1
2 require 'lpadmin-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the lpadmin module
6 sub acl_security_form
7 {
8 print "<tr> <td valign=top><b>$text{'acl_printers'}</b></td>\n";
9 print "<td colspan=3>\n";
10 printf "<input name=printers_def type=radio value=1 %s> %s\n",
11         $_[0]->{'printers'} eq '*' ? 'checked' : '', $text{'acl_pall'};
12 printf "<input name=printers_def type=radio value=0 %s> %s<br>\n",
13         $_[0]->{'printers'} eq '*' ? '' : 'checked', $text{'acl_psel'};
14 print "<select name=printers multiple size=4 width=15>\n";
15 local @plist = &list_printers();
16 local ($p, %pcan);
17 map { $pcan{$_}++ } split(/\s+/, $_[0]->{'printers'});
18 foreach $p (@plist) {
19         local $prn = &get_printer($p);
20         printf "<option value=%s %s>%s (%s)\n",
21                 $p, $pcan{$p} ? 'selected' : '',
22                 $prn->{'desc'}, $p;
23         }
24 print "</select></td> </tr>\n";
25
26 print "<tr> <td valign=top><b>$text{'acl_cancel'}</b></td> <td colspan=3>\n";
27 printf "<input type=radio name=cancel value=0 %s> $text{'no'}\n",
28         $_[0]->{'cancel'} == 0 ? "checked" : "";
29 printf "<input type=radio name=cancel value=1 %s> $text{'yes'}\n",
30         $_[0]->{'cancel'} == 1 ? "checked" : "";
31 printf "<input type=radio name=cancel value=2 %s> $text{'acl_listed'}<br>\n",
32         $_[0]->{'cancel'} == 2 ? "checked" : "";
33 print "<select name=jobs multiple size=4 width=15>\n";
34 map { $jcan{$_}++ } split(/\s+/, $_[0]->{'jobs'});
35 foreach $p (@plist) {
36         local $prn = &get_printer($p);
37         printf "<option value=%s %s>%s (%s)\n",
38                 $p, $jcan{$p} ? 'selected' : '',
39                 $prn->{'desc'}, $p;
40         }
41 print "</select></td> </tr>\n";
42
43 print "<tr> <td><b>$text{'acl_user'}</b></td> <td colspan=3>\n";
44 printf "<input type=radio name=user_def value=1 %s> %s\n",
45         $_[0]->{'user'} eq '*' ? 'checked' : '', $text{'acl_user_all'};
46 printf "<input type=radio name=user_def value=2 %s> %s\n",
47         $_[0]->{'user'} ? '' : 'checked', $text{'acl_user_this'};
48 printf "<input type=radio name=user_def value=0 %s>\n",
49         $_[0]->{'user'} eq '*' || !$_[0]->{'user'} ? '' : 'checked';
50 printf "<input name=user size=13 value='%s'></td> </tr>\n",
51         $_[0]->{'user'} eq '*' || !$_[0]->{'user'} ? '' : $_[0]->{'user'};
52
53 print "<tr> <td><b>$text{'acl_add'}</b></td>\n";
54 printf "<td><input type=radio name=add value=1 %s> $text{'yes'}\n",
55         $_[0]->{'add'} ? "checked" : "";
56 printf "<input type=radio name=add value=0 %s> $text{'no'}</td>\n",
57         $_[0]->{'add'} ? "" : "checked";
58
59 print "<td><b>$text{'acl_stop'}</b></td>\n";
60 printf "<td><input type=radio name=stop value=1 %s> $text{'yes'}\n",
61         $_[0]->{'stop'} == 1 ? "checked" : "";
62 printf "<input type=radio name=stop value=2 %s> $text{'acl_restart'}\n",
63         $_[0]->{'stop'} == 2 ? "checked" : "";
64 printf "<input type=radio name=stop value=0 %s> $text{'no'}</td> </tr>\n",
65         $_[0]->{'stop'} == 0 ? "checked" : "";
66
67 print "<tr> <td><b>$text{'acl_view'}</b></td>\n";
68 printf "<td><input type=radio name=view value=1 %s> $text{'yes'}\n",
69         $_[0]->{'view'} ? "checked" : "";
70 printf "<input type=radio name=view value=0 %s> $text{'no'}</td>\n",
71         $_[0]->{'view'} ? "" : "checked";
72
73 print "<td><b>$text{'acl_test'}</b></td>\n";
74 printf "<td><input type=radio name=test value=1 %s> $text{'yes'}\n",
75         $_[0]->{'test'} ? "checked" : "";
76 printf "<input type=radio name=test value=0 %s> $text{'no'}</td> </tr>\n",
77         $_[0]->{'test'} ? "" : "checked";
78
79 print "<tr> <td><b>$text{'acl_delete'}</b></td>\n";
80 printf "<td><input type=radio name=delete value=1 %s> $text{'yes'}\n",
81         $_[0]->{'delete'} ? "checked" : "";
82 printf "<input type=radio name=delete value=0 %s> $text{'no'}</td>\n",
83         $_[0]->{'delete'} ? "" : "checked";
84
85 print "<td><b>$text{'acl_cluster'}</b></td>\n";
86 printf "<td><input type=radio name=cluster value=1 %s> $text{'yes'}\n",
87         $_[0]->{'cluster'} ? "checked" : "";
88 printf "<input type=radio name=cluster value=0 %s> $text{'no'}</td> </tr>\n",
89         $_[0]->{'cluster'} ? "" : "checked";
90
91 print "</tr>\n";
92 }
93
94 # acl_security_save(&options)
95 # Parse the form for security options for the lpadmin module
96 sub acl_security_save
97 {
98 if ($in{'printers_def'}) {
99         $_[0]->{'printers'} = '*';
100         }
101 else {
102         $_[0]->{'printers'} = join(" ", split(/\0/, $in{'printers'}));
103         }
104 $_[0]->{'cancel'} = $in{'cancel'};
105 $_[0]->{'jobs'} = $in{'cancel'} == 2 ? join(" ", split(/\0/, $in{'jobs'})) : "";
106 $_[0]->{'add'} = $in{'add'};
107 $_[0]->{'stop'} = $in{'stop'};
108 $_[0]->{'view'} = $in{'view'};
109 $_[0]->{'user'} = $in{'user_def'} == 1 ? '*' :
110                   $in{'user_def'} == 2 ? undef : $in{'user'};
111 $_[0]->{'delete'} = $in{'delete'};
112 $_[0]->{'test'} = $in{'test'};
113 $_[0]->{'cluster'} = $in{'cluster'};
114 }
115