Handle hostnames with upper-case letters
[webmin.git] / usermin / edit_restrict.cgi
1 #!/usr/local/bin/perl
2 # edit_restrict.cgi
3 # Edit a user or group module restriction
4
5 require './usermin-lib.pl';
6 $access{'restrict'} || &error($text{'acl_ecannot'});
7 &ReadParse();
8 if ($in{'new'}) {
9         &ui_print_header(undef, $text{'restrict_create'}, "");
10         }
11 else {
12         &ui_print_header(undef, $text{'restrict_edit'}, "");
13         @usermods = &list_usermin_usermods();
14         $um = $usermods[$in{'idx'}];
15         }
16
17 print "<form action=save_restrict.cgi>\n";
18 print "<input type=hidden name=new value='$in{'new'}'>\n";
19 print "<input type=hidden name=all value='$in{'all'}'>\n";
20 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
21
22 print "<table border width=100%>\n";
23 print "<tr $tb> <td><b>$text{'restrict_header'}</b></td> </tr>\n";
24 print "<tr $cb> <td><table width=100%>\n";
25
26 print "<tr> <td valign=top><b>$text{'restrict_who2'}</b></td>\n";
27 $umode = $um->[0] eq "*" ? 2 :
28          $um->[0] =~ /^\@/ ? 1 :
29          $um->[0] =~ /^\// ? 3 :
30                              0;
31
32 printf "<td><input type=radio name=umode value=2 %s> %s<br>\n",
33         $umode == 2 ? "checked" : "", $text{'restrict_umode2'};
34
35 printf "<input type=radio name=umode value=0 %s> %s\n",
36         $umode == 0 ? "checked" : "", $text{'restrict_umode0'};
37 printf "<input name=user size=13 value='%s'> %s<br>\n",
38         $umode == 0 ? $um->[0] : "", &user_chooser_button("user");
39
40 printf "<input type=radio name=umode value=1 %s> %s\n",
41         $umode == 1 ? "checked" : "", $text{'restrict_umode1'};
42 printf "<input name=group size=13 value='%s'> %s<br>\n",
43         $umode == 1 ? substr($um->[0], 1) : "", &group_chooser_button("group");
44
45 if (&get_usermin_version() >= 1.031) {
46         printf "<input type=radio name=umode value=3 %s> %s\n",
47                 $umode == 3 ? "checked" : "", $text{'restrict_umode3'};
48         printf "<input name=file size=40 value='%s'> %s</td> </tr>\n",
49                 $umode == 3 ? $um->[0] : "", &file_chooser_button("file");
50         }
51
52 &read_usermin_acl(\%acl);
53 print "<tr> <td valign=top><b>$text{'restrict_mods'}</b><br>",
54       &text('restrict_modsdesc', "edit_acl.cgi"),"</td> <td>\n";
55 printf "<input type=radio name=mmode value=0 %s> %s\n",
56         $um->[1] eq "" ? "checked" : "", $text{'restrict_mmode0'};
57 printf "<input type=radio name=mmode value=1 %s> %s\n",
58         $um->[1] eq "+" ? "checked" : "", $text{'restrict_mmode1'};
59 printf "<input type=radio name=mmode value=2 %s> %s<br>\n",
60         $um->[1] eq "-" ? "checked" : "", $text{'restrict_mmode2'};
61 @mods = &list_modules();
62 print "<table>\n";
63 foreach $m (@mods) {
64         print "<tr>\n" if ($i % 3 == 0);
65         printf "<td width=33%%><input type=checkbox name=mod value=%s %s> %s</td>\n",
66                 $m->{'dir'}, &indexof($m->{'dir'}, @{$um->[2]}) >= 0 ?
67                                 'checked' : '',
68                 $acl{"user",$m->{'dir'}} ? $m->{'desc'} : "<font color=#ff0000>$m->{'desc'}</font>";
69         print "</tr>\n" if ($i % 3 == 2);
70         $i++;
71         }
72 print "</table>\n";
73 print &select_all_link("mod", 0),"\n";
74 print &select_invert_link("mod", 0),"\n";
75 print "</td> </tr>\n";
76
77 print "</table></td></tr></table>\n";
78 print "<table width=100%><tr>\n";
79 if ($in{'new'}) {
80         print "<td><input type=submit value='$text{'create'}'></td>\n";
81         }
82 else {
83         print "<td><input type=submit value='$text{'save'}'></td>\n";
84         print "<td align=right><input type=submit name=delete ",
85               "value='$text{'delete'}'></td>\n";
86         }
87 print "</tr></table></form>\n";
88
89 &ui_print_footer("list_restrict.cgi", $text{'restrict_return'});
90