[vhffs-dev] [588] Fixed a bug preventing ACL removal when only one person had ACL manage right .

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


Revision: 588
Author:   beuss
Date:     2007-04-21 13:49:23 +0000 (Sat, 21 Apr 2007)

Log Message:
-----------
Fixed a bug preventing ACL removal when only one person had ACL manage right.

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Acl.pm
    trunk/vhffs-api/src/Vhffs/Group.pm
    trunk/vhffs-panel/acl/view.pl


Modified: trunk/vhffs-api/src/Vhffs/Acl.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Acl.pm	2007-04-21 13:30:15 UTC (rev 587)
+++ trunk/vhffs-api/src/Vhffs/Acl.pm	2007-04-21 13:49:23 UTC (rev 588)
@@ -150,21 +150,24 @@
 
 	return -1 unless(defined $entity && defined $object );
 
-	my $query;
-	my $request;
-	my $rows;
-	
-    $query = 'SELECT COUNT(*) FROM vhffs_acl WHERE perm IN (?, ?) AND oid_dst=?';
-    $request = $main->{'db'}->prepare( $query );
-    $request->execute(Vhffs::Constants::ACL_MANAGEACL, Vhffs::Constants::ACL_DELETE, $object->{'object_id'}) or return -1;
-    ($rows) = $request->fetchrow();
+    my $dbh = $main->get_db_object();
+
+    $dbh->begin_work();
+    my $sql = 'DELETE FROM vhffs_acl WHERE oid_src = ? AND oid_dst = ?';
+    my $sth = $dbh->prepare( $sql );
+    $sth->execute( $entity->{'object_id'}, $object->{'object_id'}) or return -1;
+    
+    $sql = 'SELECT COUNT(*) FROM vhffs_acl WHERE perm IN (?, ?) AND oid_dst=?';
+    $sth = $dbh->prepare( $sql );
+    $sth->execute(Vhffs::Constants::ACL_MANAGEACL, Vhffs::Constants::ACL_DELETE, $object->get_oid) or return -1;
+    my ($count) = $sth->fetchrow();
     # We want to have at least one person who can handle ACLs
-	return -1 if( $rows <= 1 );
+	if( $count == 0 ) {
+        $dbh->rollback();
+        return -2;
+    }
 
-    # OK, there is someone to handle ACL after we delete this one => let's go
-    $query = 'DELETE FROM vhffs_acl WHERE oid_src = ? AND oid_dst = ?';
-    $request = $main->{'db'}->prepare( $query );
-    $request->execute( $entity->{'object_id'}, $object->{'object_id'});
+    $dbh->commit();
 
 	return 1;
 }

Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2007-04-21 13:30:15 UTC (rev 587)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2007-04-21 13:49:23 UTC (rev 588)
@@ -51,21 +51,6 @@
 
 =cut
 
-# get all unix groups and return it as an hashref
-#THIS IS NOT A METHOD IT'S JUST A FUNCTION
-sub get_all_unix
-{
-    my $dbh;
-    my $request;
-    my $result;
-    
-    $dbh = shift;
-
-    $result = $dbh->selectall_hashref('SELECT * FROM vhffs_groups' , "gid" ) || die( "cannot fetch all groups" );
-
-    return $result;    
-}
-
 sub check_groupname($) {
     my $groupname = shift;
     return ( defined $groupname  &&  $groupname =~ /^[a-z0-9]{3,12}$/ );

Modified: trunk/vhffs-panel/acl/view.pl
===================================================================
--- trunk/vhffs-panel/acl/view.pl	2007-04-21 13:30:15 UTC (rev 587)
+++ trunk/vhffs-panel/acl/view.pl	2007-04-21 13:49:23 UTC (rev 588)
@@ -145,7 +145,7 @@
 	{
 		$template = new HTML::Template( filename => $templatedir."/acl/view.tmpl" );
 	
-		$template->param( TITLE => gettext("ACL Administration for : ".$object->get_title) );
+		$template->param( TITLE => gettext('ACL Administration');
 
 		$template->param( TEXT_USERNAME => gettext("Username" ) . ": ");
 		$template->param( TEXT_GROUPNAME => gettext("Groupname" ) . ": ");


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