[vhffs-dev] [965] Oops, the query don't work in some cases, back to the previous query :-)

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


Revision: 965
Author:   gradator
Date:     2007-10-05 21:02:06 +0000 (Fri, 05 Oct 2007)

Log Message:
-----------
Oops, the query don't work in some cases, back to the previous query :-)

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 20:51:23 UTC (rev 964)
+++ trunk/vhffs-api/src/Vhffs/Acl.pm	2007-10-05 21:02:06 UTC (rev 965)
@@ -200,10 +200,20 @@
 	return undef unless( defined $vhffs && defined $object );
 
 	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 vhffs_acl aclu ON aclu.granted_oid=u.object_id WHERE (aclu.target_oid=? OR aclu.target_oid IS NULL) AND 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
+	   (
+	      ( 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_groups g ON ug.gid=g.gid INNER JOIN vhffs_object o ON o.owner_gid=g.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
 	' );
 	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/