[vhffs-dev] [967] The best query is here, please welcome it :) (thank for beuss)

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


Revision: 967
Author:   gradator
Date:     2007-10-05 21:42:33 +0000 (Fri, 05 Oct 2007)

Log Message:
-----------
The best query is here, please welcome it :) (thank for beuss)

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


Modified: trunk/vhffs-api/src/Vhffs/Acl.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Acl.pm	2007-10-05 21:32:48 UTC (rev 966)
+++ trunk/vhffs-api/src/Vhffs/Acl.pm	2007-10-05 21:42:33 UTC (rev 967)
@@ -199,22 +199,7 @@
 	my ( $vhffs , $object ) = @_;
 	return undef unless( defined $vhffs && defined $object );
 
-	my $sth = $vhffs->get_db_object->prepare( '
-	   (
-	      ( SELECT allusers.object_id AS granted_oid, allusers.name, aclusers.perm
-	      FROM
-	         ( SELECT u.object_id, u.username AS name FROM vhffs_users u INNER JOIN vhffs_user_group ug ON ug.uid=u.uid INNER JOIN vhffs_object o ON o.owner_gid=ug.gid WHERE o.object_id=? )
-	            AS allusers
-	      LEFT OUTER JOIN
-	         ( SELECT acl.granted_oid, acl.perm FROM vhffs_acl acl INNER JOIN vhffs_users u ON u.object_id=acl.granted_oid WHERE acl.target_oid=? )
-	            AS aclusers
-	         ON allusers.object_id=aclusers.granted_oid
-	      )
-	      UNION
-	      ( SELECT acl.granted_oid, NULL AS name, acl.perm FROM vhffs_acl acl INNER JOIN vhffs_groups g ON acl.granted_oid=g.object_id WHERE acl.target_oid=? )
-	   )
-	   ORDER BY name ASC
-	' );
+	my $sth = $vhffs->get_db_object->prepare( 'SELECT u.object_id AS granted_oid, u.username AS name, aclu.perm FROM vhffs_users u INNER JOIN vhffs_user_group ug ON ug.uid=u.uid INNER JOIN vhffs_object o ON o.owner_gid=ug.gid LEFT OUTER JOIN (SELECT acl.granted_oid, acl.perm FROM vhffs_acl acl WHERE acl.target_oid=?) AS aclu ON aclu.granted_oid=u.object_id WHERE o.object_id=? UNION SELECT g.object_id, NULL, aclg.perm FROM vhffs_groups g INNER JOIN vhffs_object o ON g.gid=o.owner_gid INNER JOIN vhffs_acl aclg ON aclg.granted_oid=g.object_id WHERE aclg.target_oid=? ORDER BY name ASC' );
 	return undef unless $sth->execute( $object->get_oid, $object->get_oid, $object->get_oid );
 	return $sth->fetchall_arrayref({});
 }


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