forked from virtualmin/virtualmin-gpl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acl_security.pl
executable file
·71 lines (64 loc) · 2.41 KB
/
acl_security.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require 'virtual-server-lib.pl';
# acl_security_form(&options)
# Output HTML for editing security options for the virtual server module
sub acl_security_form
{
print "<tr> <td colspan=4>$text{'acl_warn'}</td> </tr>\n";
print "<tr> <td valign=top rowspan=4><b>$text{'acl_domains'}</b></td>\n";
printf "<td rowspan=4><input type=radio name=domains_def value=1 %s> %s\n",
$_[0]->{'domains'} eq '*' ? "checked" : "", $text{'acl_all'};
printf "<input type=radio name=domains_def value=0 %s> %s<br>\n",
$_[0]->{'domains'} eq '*' ? "" : "checked", $text{'acl_sel'};
local %doms = map { $_, 1 } split(/\s+/, $_[0]->{'domains'});
print "<select name=domains multiple size=5>\n";
local $d;
foreach $d (&list_domains()) {
printf "<option value=%s %s>%s\n",
$d->{'id'}, $doms{$d->{'id'}} ? "selected" : "", $d->{'dom'};
}
print "</select></td> </tr>\n";
foreach $q ('create', 'import', 'migrate', 'edit', 'local', 'stop') {
print "<tr> <td><b>",$text{'acl_'.$q},"</b></td> <td>\n";
printf "<input type=radio name=%s value=1 %s> %s\n",
$q, $_[0]->{$q} == 1 ? "checked" : "", $text{'yes'};
if ($q eq "create") {
printf "<input type=radio name=%s value=2 %s> %s\n",
$q, $_[0]->{$q} == 2 ? "checked" : "",
$text{'acl_only'};
}
elsif ($q eq "edit") {
printf "<input type=radio name=%s value=2 %s> %s\n",
$q, $_[0]->{$q} == 2 ? "checked" : "",
$text{'acl_lim'};
}
printf "<input type=radio name=%s value=0 %s> %s\n",
$q, $_[0]->{$q} == 0 ? "checked" : "", $text{'no'};
print "</td> </tr>\n";
}
print "<tr> <td valign=top><b>$text{'limits_features'}</b></td>\n";
print "<td colspan=3><table>\n";
foreach $f (@opt_features) {
print "<tr>\n" if ($i%2 == 0);
printf "<td><input type=checkbox name=features value=%s %s> %s</td>\n",
$f, $_[0]->{"feature_$f"} ? "checked" : "",
$text{'feature_'.$f};
print "</tr>\n" if ($i++%2 == 1);
}
print "</table></td> </tr>\n";
}
# acl_security_save(&options)
# Parse the form for security options for the useradmin module
sub acl_security_save
{
$_[0]->{'domains'} = $in{'domains_def'} ? "*" :
join(" ", split(/\0/, $in{'domains'}));
$_[0]->{'create'} = $in{'create'};
$_[0]->{'import'} = $in{'import'};
$_[0]->{'edit'} = $in{'edit'};
$_[0]->{'local'} = $in{'local'};
$_[0]->{'stop'} = $in{'stop'};
%sel_features = map { $_, 1 } split(/\0/, $in{'features'});
foreach $f (@opt_features) {
$_[0]->{"feature_".$f} = $sel_features{$f};
}
}