[vhffs-dev] [855] create_groupdir always returned an undefined value, even if everything went fine |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [855] create_groupdir always returned an undefined value, even if everything went fine
- From: subversion@xxxxxxxxx
- Date: Sat, 01 Sep 2007 14:45:01 +0200
Revision: 855
Author: gradator
Date: 2007-09-01 12:45:01 +0000 (Sat, 01 Sep 2007)
Log Message:
-----------
create_groupdir always returned an undefined value, even if everything went fine
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Robots/Group.pm
Modified: trunk/vhffs-api/src/Vhffs/Robots/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Group.pm 2007-09-01 12:28:54 UTC (rev 854)
+++ trunk/vhffs-api/src/Vhffs/Robots/Group.pm 2007-09-01 12:45:01 UTC (rev 855)
@@ -42,25 +42,18 @@
my $main = shift;
my $group = shift;
- my $hash;
- # If we have a group object, it has been fetched
- # and is complete, no need to fetch it again
- if( defined $group )
- {
- my $user = Vhffs::User::get_by_uid( $main , $group->get_owner_uid );
- my $hash = Vhffs::Functions::hash_groupname( $group->get_groupname , $main );
- $group->add_history("Ok, Robots will create the directory");
- Vhffs::Functions::create_dir( $hash );
- $group->add_history("Ok, Robots finish create the directory");
- if( defined $group->get_owner_uid )
- {
- chown( $group->get_owner_uid , $group->get_gid , $hash );
- }
- chmod( 0555 , $hash );
- add_user( $user , $group , $main );
- $group->set_status( Vhffs::Constants::ACTIVATED );
- $group->commit;
- }
+ return undef unless ( defined $main && defined $group );
+
+ my $user = Vhffs::User::get_by_uid( $main , $group->get_owner_uid );
+ my $hash = Vhffs::Functions::hash_groupname( $group->get_groupname , $main );
+ $group->add_history('Ok, Robots is going to create the directory');
+ Vhffs::Functions::create_dir( $hash );
+ $group->add_history('Ok, Robots finished the creation of the directory');
+ chown( $group->get_owner_uid , $group->get_gid , $hash );
+ chmod( 0555 , $hash );
+ add_user( $user , $group , $main );
+ $group->set_status( Vhffs::Constants::ACTIVATED );
+ $group->commit;
return $hash;
}
@@ -69,25 +62,19 @@
{
my $main = shift;
my $group = shift;
- my $cmd;
+ return undef unless ( defined $main && defined $group );
- my $hash;
- # If group is defined, it is complete
- if( defined $group )
+ my $user = Vhffs::User::get_by_uid( $main , $group->get_owner_uid );
+ my $hash = Vhffs::Functions::hash_groupname( $group->get_groupname , $main );
+ if( -d $hash )
{
- my $user = Vhffs::User::get_by_uid( $main , $group->get_owner_uid );
- my $hash = Vhffs::Functions::hash_groupname( $group->get_groupname , $main );
- if( -d $hash )
- {
- $cmd = "rm -f $hash/* ";
- system( $cmd );
+ my $cmd = "rm -f $hash/* ";
+ system( $cmd );
- $cmd = "rmdir $hash ";
- system( $cmd );
- }
+ $cmd = "rmdir $hash ";
+ system( $cmd );
}
-
return 0;
}
@@ -156,9 +143,8 @@
$user->add_history("The user ".$user->get_username." leave the group");
my $query = "DELETE FROM vhffs_user_group WHERE uid='".$user->get_uid."' AND gid='".$group->get_gid."'";
- my $request = $main->{'db'}->prepare( $query ) or return -2;
- $request->execute;
-
+ my $request = $main->{'db'}->prepare( $query ) or return -2;
+ $request->execute;
}
@@ -179,8 +165,8 @@
$user->add_history("The user ".$user->get_username." join the group");
my $query = "UPDATE vhffs_user_group SET state='".Vhffs::Constants::ACTIVATED."' WHERE uid='".$user->get_uid."' AND gid='".$group->get_gid."'";
- my $request = $main->{'db'}->prepare( $query ) or return -2;
- $request->execute;
+ my $request = $main->{'db'}->prepare( $query ) or return -2;
+ $request->execute;
return 1;
}