require 'lpadmin-lib.pl';
# acl_security_form(&options)
# Output HTML for editing security options for the lpadmin module
sub acl_security_form
{
print "
$text{'acl_printers'} \n";
print "\n";
printf " %s\n",
$_[0]->{'printers'} eq '*' ? 'checked' : '', $text{'acl_pall'};
printf " %s \n",
$_[0]->{'printers'} eq '*' ? '' : 'checked', $text{'acl_psel'};
print "\n";
local @plist = &list_printers();
local ($p, %pcan);
map { $pcan{$_}++ } split(/\s+/, $_[0]->{'printers'});
foreach $p (@plist) {
local $prn = &get_printer($p);
printf "%s (%s) \n",
$p, $pcan{$p} ? 'selected' : '',
$prn->{'desc'}, $p;
}
print " \n";
print " $text{'acl_cancel'} \n";
printf " $text{'no'}\n",
$_[0]->{'cancel'} == 0 ? "checked" : "";
printf " $text{'yes'}\n",
$_[0]->{'cancel'} == 1 ? "checked" : "";
printf " $text{'acl_listed'} \n",
$_[0]->{'cancel'} == 2 ? "checked" : "";
print "\n";
map { $jcan{$_}++ } split(/\s+/, $_[0]->{'jobs'});
foreach $p (@plist) {
local $prn = &get_printer($p);
printf "%s (%s) \n",
$p, $jcan{$p} ? 'selected' : '',
$prn->{'desc'}, $p;
}
print " \n";
print " $text{'acl_user'} \n";
printf " %s\n",
$_[0]->{'user'} eq '*' ? 'checked' : '', $text{'acl_user_all'};
printf " %s\n",
$_[0]->{'user'} ? '' : 'checked', $text{'acl_user_this'};
printf " \n",
$_[0]->{'user'} eq '*' || !$_[0]->{'user'} ? '' : 'checked';
printf " \n",
$_[0]->{'user'} eq '*' || !$_[0]->{'user'} ? '' : $_[0]->{'user'};
print " $text{'acl_add'} \n";
printf " $text{'yes'}\n",
$_[0]->{'add'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'add'} ? "" : "checked";
print "$text{'acl_stop'} \n";
printf " $text{'yes'}\n",
$_[0]->{'stop'} == 1 ? "checked" : "";
printf " $text{'acl_restart'}\n",
$_[0]->{'stop'} == 2 ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'stop'} == 0 ? "checked" : "";
print " $text{'acl_view'} \n";
printf " $text{'yes'}\n",
$_[0]->{'view'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'view'} ? "" : "checked";
print "$text{'acl_test'} \n";
printf " $text{'yes'}\n",
$_[0]->{'test'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'test'} ? "" : "checked";
print " $text{'acl_delete'} \n";
printf " $text{'yes'}\n",
$_[0]->{'delete'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'delete'} ? "" : "checked";
print "$text{'acl_cluster'} \n";
printf " $text{'yes'}\n",
$_[0]->{'cluster'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'cluster'} ? "" : "checked";
print "\n";
}
# acl_security_save(&options)
# Parse the form for security options for the lpadmin module
sub acl_security_save
{
if ($in{'printers_def'}) {
$_[0]->{'printers'} = '*';
}
else {
$_[0]->{'printers'} = join(" ", split(/\0/, $in{'printers'}));
}
$_[0]->{'cancel'} = $in{'cancel'};
$_[0]->{'jobs'} = $in{'cancel'} == 2 ? join(" ", split(/\0/, $in{'jobs'})) : "";
$_[0]->{'add'} = $in{'add'};
$_[0]->{'stop'} = $in{'stop'};
$_[0]->{'view'} = $in{'view'};
$_[0]->{'user'} = $in{'user_def'} == 1 ? '*' :
$in{'user_def'} == 2 ? undef : $in{'user'};
$_[0]->{'delete'} = $in{'delete'};
$_[0]->{'test'} = $in{'test'};
$_[0]->{'cluster'} = $in{'cluster'};
}