[interchange-cvs] interchange - heins modified 3 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Mon Apr 25 17:11:36 EDT 2005


User:      heins
Date:      2005-04-25 21:11:36 GMT
Added:     code/Filter acl2hash.filter hash2acl.filter
Added:     code/Widget acl.widget
Log:
* Add acl widget that edits the hash-style permissions used in

	[userdb function=check_file_acl location=foo mode=w]

* Add two supporting filters that are specific to this widget and
  probably should not be used otherwise (i.e. not Public). They
  don't need to be selected for the widget to operate in the
  table-editor.

Revision  Changes    Path
1.1                  interchange/code/Filter/acl2hash.filter


rev 1.1, prev_rev 1.0
Index: acl2hash.filter
===================================================================
# Copyright 2002-2004 Interchange Development Group (http://www.icdevgroup.org/)
# Copyright 1996-2002 Red Hat, Inc.
# Licensed under the GNU GPL v2. See file LICENSE for details.
# $Id: acl2hash.filter,v 1.1 2005/04/25 21:11:36 mheins Exp $

CodeDef acl2hash Filter
CodeDef acl2hash Description acl2hash
CodeDef acl2hash Visibility private
CodeDef acl2hash Routine <<EOR
sub {
	my ($value) = @_;
	my $orig = $value;
	$value =~ s/^[\s,\0]+//;
	$value =~ s/[\s,\0]+$//;
	return $value if $value =~ /^\{.*\}$/s;
	$value =~ s/\0//g;
	my $hash = Vend::Util::get_option_hash($value)
		or return '{}';

	my @del;
	while(my ($k, $v) = each %$hash) {
		push @del, $k if $v =~ /d/;
		push @del, $k if ! length($k);
	}
	delete @{$hash}{@del} if @del;
	my $out = ::uneval_it($hash);
	return $out;
}
EOR



1.1                  interchange/code/Filter/hash2acl.filter


rev 1.1, prev_rev 1.0
Index: hash2acl.filter
===================================================================
# Copyright 2002-2004 Interchange Development Group (http://www.icdevgroup.org/)
# Copyright 1996-2002 Red Hat, Inc.
# Licensed under the GNU GPL v2. See file LICENSE for details.
# $Id: hash2acl.filter,v 1.1 2005/04/25 21:11:36 mheins Exp $

CodeDef hash2acl Filter
CodeDef hash2acl Description hash2acl
CodeDef hash2acl Visibility private
CodeDef hash2acl Routine <<EOR
sub {
	my ($value) = @_;
	my $orig = $value;
	$value =~ s/^\s+//;
	$value =~ s/\s+$//;
	$value =~ s/\0+//g;
	my $hash = Vend::Util::get_option_hash($value)
		or return $orig;
	my @opts;
	for(sort keys %$hash) {
		! defined $hash and $hash->{$_} = '';
		my $val = $_;
		$val =~ s/,/&#44;/g;
		$val =~ s/=/&#61;/g;
		push @opts, "$val=$hash->{$_}";
	}
	$value = join ",", @opts;
	return $value;
}
EOR



1.1                  interchange/code/Widget/acl.widget


rev 1.1, prev_rev 1.0
Index: acl.widget
===================================================================
CodeDef acl Widget 1
CodeDef acl Description ACL Settings
CodeDef acl Routine <<EOR
sub {
	my($opt) = @_;
	my($name, $val) = ($opt->{name}, $opt->{value});

	my $del_label = errmsg('delete');
	my $n_label = errmsg('none');
	my $rw_label = errmsg('read-write');
	my $r_label = errmsg('read');

	my $opsub = 
sub  {
	my ($name, $val, $lab, $width) = @_;
	my ($nsel, $rsel, $rwsel, $tsel) = ('', '', '', '');

#::logDebug("$val=$lab");
	if   ($lab =~ /n/) { $nsel = ' SELECTED' }
	elsif($lab =~ /w/) { $rwsel = ' SELECTED' }
	elsif($lab =~ /r/) { $rsel = ' SELECTED' }
	if   ($lab =~ /t/) { $tsel = ' CHECKED' }
#::logDebug("nsel=$nsel, rsel=$rsel, rwsel=$rwsel");
	$val =~ s/"/&quot;/g;
	$lab =~ s/"/&quot;/g;
	$width = 16 if ! $width;
	return qq{	<tr>
      <td>
		  <input type="text" name="$name" value="$val" size="$width" style="font-size: small">
		  <input type="hidden" name="$name" value="=">
	  </td>

      <td>
	  	<select name="$name" style="font-size: small">
			<option value="n"$nsel>$n_label</option>
			<option value="r"$rsel>$r_label</option>
			<option value="rw"$rwsel>$rw_label</option>
			<option value="d">$del_label</option>
		</select>
	  </td>
      <td align=center>
	  	<input type="checkbox" name="$name" value="t" style="font-size: small"$tsel>
	    <input type="hidden" name="$name" value=",">
	  </td>
	</tr>};
};

	
	my $width = $opt->{width} || 16;
	$opt->{pre_filter} = 'hash2acl'
		unless length($opt->{filter});
	$opt->{filter} = 'acl2hash'
		unless length($opt->{filter});
	$val = Vend::Interpolate::filter_value($opt->{pre_filter}, $val);
	my @opts = split /\s*,\s*/, $val;

	my $out = qq{<table cellpadding="0" cellspacing="0"><tr>};
	$out .= qq{<th style="font-size: small">};
	$out .= errmsg('Object');
	$out .= qq{</th>};
	$out .= qq{<th align="left" style="font-size: small">};
	$out .= errmsg('Permissions');
	$out .= qq{</th>};
	$out .= qq{<th align="center" style="font-size: small">};
	$out .= errmsg('Allow tar');
	$out .= qq{</th>};
	$out .= qq{</tr>};

	my $done;
	my $height = $opt->{height} || 5;
	$height -= 2;
	for(@opts) {
		my ($v,$l) = split /\s*=\s*/, $_, 2;
		next unless length($v);
		$done++;
		$out .= $opsub->($name, $v, $l, $width);
	}
	while($done++ < $height) {
		$out .= $opsub->($name, '', '', '', $width);
	}
	$out .= $opsub->($name, '', '', '', $width);
	$out .= $opsub->($name, '', '', '', $width);
	$out .= "</table>";
}
EOR








More information about the interchange-cvs mailing list