[vhffs-dev] [2156] as suggested by Laurent Bives from APINC organisation, we need to check if a user is free of groups before we sent a deletion request

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


Revision: 2156
Author:   gradator
Date:     2012-04-25 22:07:41 +0200 (Wed, 25 Apr 2012)
Log Message:
-----------
as suggested by Laurent Bives from APINC organisation, we need to check if a user is free of groups before we sent a deletion request

Modified Paths:
--------------
    trunk/vhffs-tools/src/vhffs-userdel

Modified: trunk/vhffs-tools/src/vhffs-userdel
===================================================================
--- trunk/vhffs-tools/src/vhffs-userdel	2012-04-24 21:01:46 UTC (rev 2155)
+++ trunk/vhffs-tools/src/vhffs-userdel	2012-04-25 20:07:41 UTC (rev 2156)
@@ -5,33 +5,30 @@
 use Vhffs;
 use Vhffs::Constants;
 
-if( $#ARGV != 0 )
-{
-	print "Usage: vhffs-userdel user\n";
+if( $#ARGV != 0 ) {
+	print 'Usage: vhffs-userdel user'."\n";
 	exit( 1 );
 }
 
 my $vhffs = new Vhffs;
 my $user = Vhffs::User::get_by_username( $vhffs , $ARGV[0] );
 
+unless( defined $user ) {
+	print 'No such user with this username'."\n";
+	exit(-1);
+}
 
-if( defined $user )
-{
-	$user->set_status( Vhffs::Constants::WAITING_FOR_DELETION );
+if( @{$user->get_groups} ) {
+	print 'This user is still in a group'."\n";
+	exit(-1);
+}
+
+$user->set_status( Vhffs::Constants::WAITING_FOR_DELETION );
 	
-	if( $user->commit <= 0 )
-	{
-		print "Status change failed\n";
-		exit( 2 );
-	}
-	else
-	{
-		print "This user WILL BE DELETED\n";
-		exit( 0 );
-	}
+if( $user->commit <= ) {
+	print 'Status change failed'."\n";
+	exit(-1);
 }
-else
-{
-	print "No such user with this username\n";
-	exit( -1 );
-}
+
+print 'This user WILL BE DELETED'."\n";
+exit(0);


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