2 require 'postgresql-lib.pl';
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the postgresql module
8 my (@listdb)=&list_databases();
9 print "<tr> <td valign=top rowspan=4><b>$text{'acl_dbs'}</b>\n";
10 print "<br>$text{'acl_dbscannot'}" unless @listdb;
12 print "<td rowspan=4 valign=top>\n";
14 printf "<input type=radio name=dbs_def value=1 %s> %s\n",
15 $_[0]->{'dbs'} eq '*' ? 'checked' : '', $text{'acl_dall'};
16 printf "<input type=radio name=dbs_def value=0 %s> %s<br>\n",
17 $_[0]->{'dbs'} eq '*' ? '' : 'checked', $text{'acl_dsel'};
18 print "<select name=dbs size=5 multiple width=100>\n";
19 map { $dcan{$_}++ } split(/\s+/, $_[0]->{'dbs'});
20 foreach $d (@listdb) {
21 printf "<option %s>%s\n",
22 $dcan{$d} ? 'selected' : '', $d;
25 print "<input type=hidden name=dblist value=\"1\">\n";
28 print "<input type=hidden name=dblist value=\"0 ".$_[0]->{'dbs'}."\">\n";
32 print "<td><b>$text{'acl_create'}</b></td> <td>\n";
33 printf "<input type=radio name=create value=1 %s> %s\n",
34 $_[0]->{'create'} == 1 ? 'checked' : '', $text{'yes'};
35 printf "<input type=radio name=create value=2 %s> %s\n",
36 $_[0]->{'create'} == 2 ? 'checked' : '', $text{'acl_max'};
37 printf "<input name=max size=5 value='%s'>\n",
39 printf "<input type=radio name=create value=0 %s> %s</td> </tr>\n",
40 $_[0]->{'create'} == 0 ? 'checked' : '', $text{'no'};
42 print "<tr> <td><b>$text{'acl_delete'}</b></td> <td>\n";
43 printf "<input type=radio name=delete value=1 %s> %s\n",
44 $_[0]->{'delete'} ? 'checked' : '', $text{'yes'};
45 printf "<input type=radio name=delete value=0 %s> %s</td> </tr>\n",
46 $_[0]->{'delete'} ? '' : 'checked', $text{'no'};
48 print "<tr> <td><b>$text{'acl_stop'}</b></td> <td>\n";
49 printf "<input type=radio name=stop value=1 %s> %s\n",
50 $_[0]->{'stop'} ? 'checked' : '', $text{'yes'};
51 printf "<input type=radio name=stop value=0 %s> %s</td> </tr>\n",
52 $_[0]->{'stop'} ? '' : 'checked', $text{'no'};
54 print "<tr> <td><b>$text{'acl_users'}</b></td> <td>\n";
55 printf "<input type=radio name=users value=1 %s> %s\n",
56 $_[0]->{'users'} ? 'checked' : '', $text{'yes'};
57 printf "<input type=radio name=users value=0 %s> %s</td> </tr>\n",
58 $_[0]->{'users'} ? '' : 'checked', $text{'no'};
60 print "<tr> <td valign=top><b>$text{'acl_login'}</b></td> <td colspan=3>\n";
61 printf "<input type=radio name=user_def value=1 %s> %s<br>\n",
62 $_[0]->{'user'} ? '' : 'checked', $text{'acl_user_def'};
63 printf "<input type=radio name=user_def value=0 %s>\n",
64 $_[0]->{'user'} ? 'checked' : '';
65 printf "%s <input name=user size=10 value='%s'>\n",
66 $text{'acl_user'}, $_[0]->{'user'};
67 printf "%s <input name=pass type=password size=10 value='%s'><br>\n",
68 $text{'acl_pass'}, $_[0]->{'pass'};
69 print " \n";
70 printf "<input type=checkbox name=sameunix value=1 %s> %s</td> </tr>\n",
71 $_[0]->{'sameunix'} ? "checked" : "", $text{'acl_sameunix'};
73 print "<tr> <td><b>$text{'acl_backup'}</b></td> <td>\n";
74 printf "<input type=radio name=backup value=1 %s> %s\n",
75 $_[0]->{'backup'} ? 'checked' : '', $text{'yes'};
76 printf "<input type=radio name=backup value=0 %s> %s</td>\n",
77 $_[0]->{'backup'} ? '' : 'checked', $text{'no'};
79 print "<td><b>$text{'acl_restore'}</b></td> <td>\n";
80 printf "<input type=radio name=restore value=1 %s> %s\n",
81 $_[0]->{'restore'} ? 'checked' : '', $text{'yes'};
82 printf "<input type=radio name=restore value=0 %s> %s</td> </tr>\n",
83 $_[0]->{'restore'} ? '' : 'checked', $text{'no'};
85 print "<tr> <td valign=top><b>$text{'acl_cmds'}</b></td> <td>\n";
86 printf "<input type=radio name=cmds value=1 %s> %s\n",
87 $_[0]->{'cmds'} ? "checked" : "", $text{'yes'};
88 printf "<input type=radio name=cmds value=0 %s> %s</td>\n",
89 $_[0]->{'cmds'} ? "" : "checked", $text{'no'};
91 print "<td><b>$text{'acl_views'}</b></td> <td>\n";
92 printf "<input type=radio name=views value=1 %s> %s\n",
93 $_[0]->{'views'} ? 'checked' : '', $text{'yes'};
94 printf "<input type=radio name=views value=0 %s> %s</td> </tr>\n",
95 $_[0]->{'views'} ? '' : 'checked', $text{'no'};
97 print "<tr> <td valign=top><b>$text{'acl_indexes'}</b></td> <td>\n";
98 printf "<input type=radio name=indexes value=1 %s> %s\n",
99 $_[0]->{'indexes'} ? "checked" : "", $text{'yes'};
100 printf "<input type=radio name=indexes value=0 %s> %s</td>\n",
101 $_[0]->{'indexes'} ? "" : "checked", $text{'no'};
103 print "<td><b>$text{'acl_seqs'}</b></td> <td>\n";
104 printf "<input type=radio name=seqs value=1 %s> %s\n",
105 $_[0]->{'seqs'} ? 'checked' : '', $text{'yes'};
106 printf "<input type=radio name=seqs value=0 %s> %s</td> </tr>\n",
107 $_[0]->{'seqs'} ? '' : 'checked', $text{'no'};
112 # acl_security_save(&options)
113 # Parse the form for security options for the postgresql module
114 sub acl_security_save
116 if ($in{'dblist'} eq '1') {
117 if ($in{'dbs_def'}) {
118 $_[0]->{'dbs'} = '*';
121 $_[0]->{'dbs'} = join(" ", split(/\0/, $in{'dbs'}));
125 $_[0]->{'dbs'} = $in{'dblist'};
126 $_[0]->{'dbs'} =~ s/^0 //;
128 $_[0]->{'create'} = $in{'create'};
129 $_[0]->{'max'} = $in{'max'};
130 $_[0]->{'delete'} = $in{'delete'};
131 $_[0]->{'stop'} = $in{'stop'};
132 $_[0]->{'users'} = $in{'users'};
133 $_[0]->{'backup'} = $in{'backup'};
134 $_[0]->{'restore'} = $in{'restore'};
135 $_[0]->{'cmds'} = $in{'cmds'};
136 $_[0]->{'views'} = $in{'views'};
137 $_[0]->{'indexes'} = $in{'indexes'};
138 $_[0]->{'seqs'} = $in{'seqs'};
139 if ($in{'user_def'}) {
140 delete($_[0]->{'user'});
141 delete($_[0]->{'pass'});
144 $_[0]->{'user'} = $in{'user'};
145 $_[0]->{'pass'} = $in{'pass'};
147 $_[0]->{'sameunix'} = $in{'sameunix'};