2 require 'lpadmin-lib.pl';
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the lpadmin module
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();
17 map { $pcan{$_}++ } split(/\s+/, $_[0]->{'printers'});
19 local $prn = &get_printer($p);
20 printf "<option value=%s %s>%s (%s)\n",
21 $p, $pcan{$p} ? 'selected' : '',
24 print "</select></td> </tr>\n";
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'});
36 local $prn = &get_printer($p);
37 printf "<option value=%s %s>%s (%s)\n",
38 $p, $jcan{$p} ? 'selected' : '',
41 print "</select></td> </tr>\n";
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'};
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";
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" : "";
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";
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";
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";
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";
94 # acl_security_save(&options)
95 # Parse the form for security options for the lpadmin module
98 if ($in{'printers_def'}) {
99 $_[0]->{'printers'} = '*';
102 $_[0]->{'printers'} = join(" ", split(/\0/, $in{'printers'}));
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'};