* Add enclair_db option to UserDB.pm. Allows logging of enclair password
[interchange.git] / code / Widget / acl.widget
1 # Copyright 2005-2007 Interchange Development Group and others
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.  See the LICENSE file for details.
7
8 # $Id: acl.widget,v 1.3 2007-03-30 23:40:58 pajamian Exp $
9
10 CodeDef acl Widget 1
11 CodeDef acl Description ACL Settings
12 CodeDef acl Routine <<EOR
13 sub {
14         my($opt) = @_;
15         my($name, $val) = ($opt->{name}, $opt->{value});
16
17         my $del_label = errmsg('delete');
18         my $n_label = errmsg('none');
19         my $rw_label = errmsg('read-write');
20         my $r_label = errmsg('read');
21
22         my $opsub = 
23 sub  {
24         my ($name, $val, $lab, $width) = @_;
25         my ($nsel, $rsel, $rwsel, $tsel) = ('', '', '', '');
26
27 #::logDebug("$val=$lab");
28         if   ($lab =~ /n/) { $nsel = ' SELECTED' }
29         elsif($lab =~ /w/) { $rwsel = ' SELECTED' }
30         elsif($lab =~ /r/) { $rsel = ' SELECTED' }
31         if   ($lab =~ /t/) { $tsel = ' CHECKED' }
32 #::logDebug("nsel=$nsel, rsel=$rsel, rwsel=$rwsel");
33         $val =~ s/"/&quot;/g;
34         $lab =~ s/"/&quot;/g;
35         $width = 16 if ! $width;
36         return qq{      <tr>
37       <td>
38                   <input type="text" name="$name" value="$val" size="$width" style="font-size: small">
39                   <input type="hidden" name="$name" value="=">
40           </td>
41
42       <td>
43                 <select name="$name" style="font-size: small">
44                         <option value="n"$nsel>$n_label</option>
45                         <option value="r"$rsel>$r_label</option>
46                         <option value="rw"$rwsel>$rw_label</option>
47                         <option value="d">$del_label</option>
48                 </select>
49           </td>
50       <td align=center>
51                 <input type="checkbox" name="$name" value="t" style="font-size: small"$tsel>
52             <input type="hidden" name="$name" value=",">
53           </td>
54         </tr>};
55 };
56
57         
58         my $width = $opt->{width} || 16;
59         $opt->{pre_filter} = 'hash2acl'
60                 unless length($opt->{filter});
61         $opt->{filter} = 'acl2hash'
62                 unless length($opt->{filter});
63         $val = Vend::Interpolate::filter_value($opt->{pre_filter}, $val);
64         my @opts = split /\s*,\s*/, $val;
65
66         my $out = qq{<table cellpadding="0" cellspacing="0"><tr>};
67         $out .= qq{<th style="font-size: small">};
68         $out .= errmsg('Object');
69         $out .= qq{</th>};
70         $out .= qq{<th align="left" style="font-size: small">};
71         $out .= errmsg('Permissions');
72         $out .= qq{</th>};
73         $out .= qq{<th align="center" style="font-size: small">};
74         $out .= errmsg('Allow tar');
75         $out .= qq{</th>};
76         $out .= qq{</tr>};
77
78         my $done;
79         my $height = $opt->{height} || 5;
80         $height -= 2;
81         for(@opts) {
82                 my ($v,$l) = split /\s*=\s*/, $_, 2;
83                 next unless length($v);
84                 $done++;
85                 $out .= $opsub->($name, $v, $l, $width);
86         }
87         while($done++ < $height) {
88                 $out .= $opsub->($name, '', '', '', $width);
89         }
90         $out .= $opsub->($name, '', '', '', $width);
91         $out .= $opsub->($name, '', '', '', $width);
92         $out .= "</table>";
93 }
94 EOR