[vhffs-dev] [2037] moved from code from panel ACL management to API

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2037
Author:   gradator
Date:     2012-02-22 02:10:14 +0100 (Wed, 22 Feb 2012)
Log Message:
-----------
moved from code from panel ACL management to API

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Acl.pm
    trunk/vhffs-api/src/Vhffs/Panel/Acl.pm

Modified: trunk/vhffs-api/src/Vhffs/Acl.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Acl.pm	2012-02-22 00:32:40 UTC (rev 2036)
+++ trunk/vhffs-api/src/Vhffs/Acl.pm	2012-02-22 01:10:14 UTC (rev 2037)
@@ -190,17 +190,32 @@
 	return undef unless $sth->execute( $self->get_oid, $self->get_oid, $self->get_oid, $self->get_oid );
 	my $acls = $sth->fetchall_arrayref({});
 
+	my $default_acl;
+	my $owner_acl;
+	my $users_acls = [];
 	# If someone find a way to do that using SQL, please do ;-)
 	foreach my $acl ( @{$acls} )  {
+
+		# Owner
+		if( defined $acl->{uid} and $acl->{uid} == $self->get_owner_uid ) {
+			$acl->{perm} = Vhffs::Constants::ACL_DELETE unless defined $acl->{perm};
+			$owner_acl = $acl
+		}
+
+		# A real ACL
+		elsif( defined $acl->{name} ) {
+			$acl->{perm} = Vhffs::Constants::ACL_UNDEFINED unless defined $acl->{perm};
+			push( @$users_acls, $acl );
+		}
+
 		# Default ACL (group ACL)
-		$acl->{perm} = Vhffs::Constants::ACL_VIEW if not defined $acl->{name} and not defined $acl->{perm};
-		# Owner
-		$acl->{perm} = Vhffs::Constants::ACL_DELETE if defined $acl->{uid} and $acl->{uid} == $self->get_owner_uid and not defined $acl->{perm};
-		# Undef to ACL_UNDEFINED
-		$acl->{perm} = Vhffs::Constants::ACL_UNDEFINED unless defined $acl->{perm};
+		else {
+			$acl->{perm} = Vhffs::Constants::ACL_VIEW unless defined $acl->{perm};
+			$default_acl = $acl;
+		}
 	}
 
-	return $acls;
+	return ( $default_acl, $owner_acl, $users_acls );
 }
 
 =pod

Modified: trunk/vhffs-api/src/Vhffs/Panel/Acl.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Acl.pm	2012-02-22 00:32:40 UTC (rev 2036)
+++ trunk/vhffs-api/src/Vhffs/Panel/Acl.pm	2012-02-22 01:10:14 UTC (rev 2037)
@@ -97,25 +97,10 @@
 
 	$panel->set_title( gettext('ACL Administration') );
 	my $vars = { target => $object };
-	my $acls = $object->get_acl;
-	my $default_acl;
-	my $owner_acl;
-	my $users_acl = [];
-	foreach my $acl ( @{$acls} )  {
-		# Owner
-		if( defined $acl->{uid} and $acl->{uid} == $object->get_owner_uid ) {
-			$owner_acl = $acl;
-		# The real ACL
-		} elsif( defined $acl->{name} ) {
-			push( @$users_acl, $acl );
-		# Group ACL
-		} else {
-			$default_acl = $acl;
-		}
-	}
+	my ( $default_acl, $owner_acl, $users_acls ) = $object->get_acl;
 	$vars->{default_acl} = $default_acl;
 	$vars->{owner_acl} = $owner_acl;
-	$vars->{users_acl} = $users_acl;
+	$vars->{users_acl} = $users_acls;
 
 	$panel->render('acl/view.tt', $vars);
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/