1 # Copyright 2005-2007 Interchange Development Group and others
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.
8 # $Id: acl.widget,v 1.3 2007-03-30 23:40:58 pajamian Exp $
11 CodeDef acl Description ACL Settings
12 CodeDef acl Routine <<EOR
15 my($name, $val) = ($opt->{name}, $opt->{value});
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');
24 my ($name, $val, $lab, $width) = @_;
25 my ($nsel, $rsel, $rwsel, $tsel) = ('', '', '', '');
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");
35 $width = 16 if ! $width;
38 <input type="text" name="$name" value="$val" size="$width" style="font-size: small">
39 <input type="hidden" name="$name" value="=">
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>
51 <input type="checkbox" name="$name" value="t" style="font-size: small"$tsel>
52 <input type="hidden" name="$name" value=",">
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;
66 my $out = qq{<table cellpadding="0" cellspacing="0"><tr>};
67 $out .= qq{<th style="font-size: small">};
68 $out .= errmsg('Object');
70 $out .= qq{<th align="left" style="font-size: small">};
71 $out .= errmsg('Permissions');
73 $out .= qq{<th align="center" style="font-size: small">};
74 $out .= errmsg('Allow tar');
79 my $height = $opt->{height} || 5;
82 my ($v,$l) = split /\s*=\s*/, $_, 2;
83 next unless length($v);
85 $out .= $opsub->($name, $v, $l, $width);
87 while($done++ < $height) {
88 $out .= $opsub->($name, '', '', '', $width);
90 $out .= $opsub->($name, '', '', '', $width);
91 $out .= $opsub->($name, '', '', '', $width);