[vhffs-dev] [2057] Reworked user robots, fixed a bug in panel which allowed users that are still in a group to be deleted

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


Revision: 2057
Author:   gradator
Date:     2012-02-25 18:48:14 +0100 (Sat, 25 Feb 2012)
Log Message:
-----------
Reworked user robots, fixed a bug in panel which allowed users that are still in a group to be deleted

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/User.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-robots/Makefile.am

Added Paths:
-----------
    trunk/vhffs-api/src/Vhffs/Robots/User.pm
    trunk/vhffs-robots/src/user.pl

Removed Paths:
-------------
    trunk/vhffs-api/src/Vhffs/Robots/User.pm
    trunk/vhffs-robots/src/user_create.pl
    trunk/vhffs-robots/src/user_delete.pl

Modified: trunk/vhffs-api/src/Vhffs/Panel/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/User.pm	2012-02-25 15:27:26 UTC (rev 2056)
+++ trunk/vhffs-api/src/Vhffs/Panel/User.pm	2012-02-25 17:48:14 UTC (rev 2057)
@@ -585,7 +585,7 @@
 			$message = gettext('You\'re not allowed to delete this user');
 		} else {
 			if( $delete == 1 ) {
-				if( $userp->have_activegroups ) {
+				if( @{$userp->get_groups} ) {
 					$message = gettext('This user is still in a group');
 				} else {
 					$userp->set_status( Vhffs::Constants::WAITING_FOR_DELETION );

Deleted: trunk/vhffs-api/src/Vhffs/Robots/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm	2012-02-25 15:27:26 UTC (rev 2056)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm	2012-02-25 17:48:14 UTC (rev 2057)
@@ -1,126 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in
-#   the documentation and/or other materials provided with the
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-#   may be used to endorse or promote products derived from this
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-use File::Path;
-use File::Basename;
-
-package Vhffs::Robots::User;
-
-use Vhffs::User;
-use Vhffs::Functions;
-use Vhffs::Constants;
-use Vhffs::Robots;
-
-sub create
-{
-	my $user = shift;
-	return if( ! defined $user );
-
-	create_home( $user->{'main'} , $user->get_username );
-}
-
-sub delete
-{
-	my $vhffs = shift;
-	my $user = shift;
-	return if( ! defined $user );
-	delete_home( $vhffs , $user );
-}
-
-sub delete_home
-{
-	my( $main , $user , $homedir , $cmd );
-
-	$main = shift;
-	$user = shift;
-
-	if( defined $user )
-	{
-		$user->add_history( "Ok, robots takes now the destruction of this user" );
-		$homedir = $user->get_home;	
-
-		if( $homedir && -d $homedir )
-		{
-			Vhffs::Robots::archive_targz( $user, $homedir );
-
-			File::Path::remove_tree( $homedir, { error => \my $errors });
-			# Home directories are hashed on two levels, so we've potentially two empty directories to delete
-			$homedir = File::Basename::dirname($homedir);
-			rmdir $homedir;
-			$homedir = File::Basename::dirname($homedir);
-			rmdir $homedir;
-
-			if(@$errors) {
-				Vhffs::Robots::vhffs_log( $main, sprintf( 'Something went wrong during %s home deletion: %s', $user->get_username, join(', ', @$errors) ) );
-			}
-		}
-	}
-
-	return 1;
-}
-
-
-sub create_home
-{
-	my $main = shift;
-	my $user = shift;
-
-	return -1 unless defined $user;
-
-	my $homedir = $user->get_home;
-
-	File::Path::make_path( $homedir, { error => \my $errors } );
-	unless( @$errors ) {
-		chown $user->get_uid , $user->get_gid , $homedir;
-		chmod 0700, $homedir;
-
-		$user->add_history( 'homedir created' );
-		$user->set_status( Vhffs::Constants::ACTIVATED );
-		return -1 if( $user->commit < 0 );
-
-		my $subject = sprintf("Account created on %s", $main->get_config->get_host_name );
-		my $content = sprintf("Hello %s %s,\n\nWe are pleased to announce that your account is now fully created on\n%s.\nYou can now login on the panel.\n\n%s Administrators\n", $user->get_firstname, $user->get_lastname, $main->get_config->get_host_name, $main->get_config->get_host_name );
-		$user->send_mail_user( $subject, $content );
-	}
-	else  {
-		$user->add_history( 'cannot create the homedir directory' );
-#		$user->set_status( Vhffs::Constants::CREATION_ERROR );
-#		$user->commit;
-		return -1;
-	}
-
-	return 0;
-}
-
-
-1;

Added: trunk/vhffs-api/src/Vhffs/Robots/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm	2012-02-25 17:48:14 UTC (rev 2057)
@@ -0,0 +1,127 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+#   may be used to endorse or promote products derived from this
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+use File::Path;
+use File::Basename;
+
+use Vhffs::Constants;
+use Vhffs::Functions;
+use Vhffs::Robots;
+use Vhffs::User;
+
+package Vhffs::Robots::User;
+
+sub create {
+	my $user = shift;
+	return undef unless defined $user and $user->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
+
+	my $vhffs = $user->get_main;
+	my $dir = $user->get_home;
+
+	if( -e $dir ) {
+		$user->set_status( Vhffs::Constants::CREATION_ERROR );
+		$user->commit;
+		Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while creating home dir for user '.$user->get_username.' to the filesystem' );
+		return undef;
+	}
+
+	File::Path::make_path( $dir, { error => \my $errors });
+	if(@$errors) {
+		$user->set_status( Vhffs::Constants::CREATION_ERROR );
+		$user->commit;
+		Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while creating home dir for user '.$user->get_username.' to the filesystem: '.join(', ', @$errors) );
+		return undef;
+	}
+
+	chown $user->get_uid, $user->get_gid, $dir;
+	chmod 0700, $dir;
+
+	my $subject = sprintf("Account created on %s", $vhffs->get_config->get_host_name );
+	my $content = sprintf("Hello %s %s,\n\nWe are pleased to announce that your account is now fully created on\n%s.\nYou can now login on the panel.\n\n%s Administrators\n",
+		$user->get_firstname, $user->get_lastname, $vhffs->get_config->get_host_name, $vhffs->get_config->get_host_name );
+	$user->send_mail_user( $subject, $content );
+
+	Vhffs::Robots::vhffs_log( $vhffs, 'Created home dir for user '.$user->get_username );
+	$user->set_status( Vhffs::Constants::ACTIVATED );	
+	$user->commit;
+}
+
+sub delete {
+	my $user = shift;
+	return undef unless defined $user and $user->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
+
+	my $vhffs = $user->get_main;
+	my $dir = $user->get_home;
+
+	if( @{$user->get_groups} ) {
+		$user->set_status( Vhffs::Constants::DELETION_ERROR );
+		$user->commit;
+		Vhffs::Robots::vhffs_log( $vhffs, 'Deletion required for user '.$user->get_username.', but this user was still in one or more groups' );
+		return undef;
+	}	
+
+	Vhffs::Robots::archive_targz( $user, $dir );
+
+	File::Path::remove_tree( $dir, { error => \my $errors });
+	my $parent = File::Basename::dirname($dir);
+	rmdir $parent;
+	$parent = File::Basename::dirname($parent);
+	rmdir $parent;
+
+	if(@$errors) {
+		$user->set_status( Vhffs::Constants::DELETION_ERROR );
+		$user->commit;
+		Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while removing home dir for user '.$user->get_username.' from the filesystem: '.join(', ', @$errors) );
+		return undef;
+	}
+
+	if( $user->delete ) {
+		Vhffs::Robots::vhffs_log( $vhffs, 'Deleted home dir for user '.$user->get_username );
+	} else {
+		$user->set_status( Vhffs::Constants::DELETION_ERROR );
+		$user->commit;
+		Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while deleting user '.$user->get_username.' object' );
+		return undef;
+	}
+
+	return 1;
+}
+
+sub modify {
+	my $user = shift;
+	return undef unless defined $user and $user->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
+	$user->set_status( Vhffs::Constants::ACTIVATED );
+	$user->commit;
+}
+
+1;

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2012-02-25 15:27:26 UTC (rev 2056)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2012-02-25 17:48:14 UTC (rev 2057)
@@ -1041,9 +1041,9 @@
 
 	my $uid = $self->get_uid;
 
-	my $query = 'SELECT COUNT(g.groupname) FROM vhffs_groups g, vhffs_user_group ug, vhffs_object o WHERE ug.uid=? AND g.gid=ug.gid AND o.object_id=g.object_id AND o.state='.Vhffs::Constants::ACTIVATED;
+	my $query = 'SELECT COUNT(g.groupname) FROM vhffs_groups g, vhffs_user_group ug, vhffs_object o WHERE ug.uid=? AND g.gid=ug.gid AND o.object_id=g.object_id AND o.state=?';
 	my $request = $self->{'db'}->prepare( $query );
-	return -1 unless $request->execute($uid);
+	return -1 unless $request->execute($uid, Vhffs::Constants::ACTIVATED);
 
 	my $row = $request->fetchrow_arrayref;
 	return -1 unless defined $row;
@@ -1060,17 +1060,15 @@
 sub get_groups {
 	my $self = shift;
 
-	my @groups;
-	my $uid = $self->get_uid;
+	my $groups = [];
 	my $query = 'SELECT g.groupname FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON g.gid=ug.gid WHERE ug.uid=? ORDER BY g.groupname';
 	my $request = $self->{'db'}->prepare( $query );
-	return undef if( ! $request->execute($uid) );
-	while( my ($groupname) = $request->fetchrow_array )
-	{
-		my $group = Vhffs::Group::get_by_groupname( $self->{'main'} , $groupname );
-		push( @groups , $group ) if( defined($group) );
+	return undef unless $request->execute($self->get_uid);
+	while( my ($groupname) = $request->fetchrow_array ) {
+		my $group = Vhffs::Group::get_by_groupname( $self->get_main, $groupname );
+		push( @$groups, $group ) if defined $group;
 	}
-	return \@groups;
+	return $groups;
 }
 
 1;

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2012-02-25 15:27:26 UTC (rev 2056)
+++ trunk/vhffs-robots/Makefile.am	2012-02-25 17:48:14 UTC (rev 2057)
@@ -50,9 +50,7 @@
 	src/git.pl \
 	src/mercurial.pl \
 	src/bazaar.pl \
-	src/user_create.pl \
-	src/user_delete.pl \
-	src/user_group.pl \
+	src/user.pl \
 	src/user_quota.pl \
 	src/user_cleanup.pl \
 	src/web.pl \

Copied: trunk/vhffs-robots/src/user.pl (from rev 2056, trunk/vhffs-robots/src/user_create.pl)
===================================================================
--- trunk/vhffs-robots/src/user.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/user.pl	2012-02-25 17:48:14 UTC (rev 2057)
@@ -0,0 +1,59 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Robots::User;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs, 'user' );
+
+my $repos = Vhffs::User::getall( $vhffs, Vhffs::Constants::WAITING_FOR_CREATION );
+foreach ( @{$repos} ) {
+	Vhffs::Robots::User::create( $_ );
+}
+
+$repos = Vhffs::User::getall( $vhffs, Vhffs::Constants::WAITING_FOR_DELETION );
+foreach ( @{$repos} ) {
+	Vhffs::Robots::User::delete( $_ );
+}
+
+$repos = Vhffs::User::getall( $vhffs, Vhffs::Constants::WAITING_FOR_MODIFICATION );
+foreach ( @{$repos} ) {
+	Vhffs::Robots::User::modify( $_ );
+}
+
+Vhffs::Robots::unlock( $vhffs, 'user' );
+exit 0;

Deleted: trunk/vhffs-robots/src/user_create.pl
===================================================================
--- trunk/vhffs-robots/src/user_create.pl	2012-02-25 15:27:26 UTC (rev 2056)
+++ trunk/vhffs-robots/src/user_create.pl	2012-02-25 17:48:14 UTC (rev 2057)
@@ -1,65 +0,0 @@
-#!%PERL%
-
-#This robot creates home directory of each users
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Robots::User;
-use Vhffs::Robots;
-use Vhffs::Main;
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "usergroup" );
-
-my $users = Vhffs::User::getall( $vhffs , Vhffs::Constants::WAITING_FOR_CREATION , undef , undef );
-my $user;
-
-foreach $user ( @{$users} )
-{
-	if( Vhffs::Robots::User::create_home( $vhffs , $user ) != 0 )
-	{
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Error while creating home for %s" , $user->get_username) );
-	}
-	else
-	{
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Creating home/account for %s" , $user->get_username) );
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "usergroup" );
-
-exit 0;
-

Deleted: trunk/vhffs-robots/src/user_delete.pl
===================================================================
--- trunk/vhffs-robots/src/user_delete.pl	2012-02-25 15:27:26 UTC (rev 2056)
+++ trunk/vhffs-robots/src/user_delete.pl	2012-02-25 17:48:14 UTC (rev 2057)
@@ -1,101 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Robots;
-use Vhffs::Robots::User;
-use Vhffs::User;
-use Vhffs::Constants;
-use Vhffs::Main;
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "usergroup" );
-
-my $lol = Vhffs::User::getall( $vhffs , Vhffs::Constants::WAITING_FOR_DELETION );
-my $user;
-my $groups;
-my $group;
-foreach $user ( @{$lol} )
-{
-	my $ok = 1;
-	if( defined $user ) 
-	{
-		$groups =  $user->get_groups;
-
-		if( defined $groups )
-		{
-			foreach $group ( @{$groups} )
-			{
-				Vhffs::Robots::vhffs_log( $vhffs, sprintf("Delete %s, remains group(s) : will delete %s " , $user->get_username , $group->get_groupname ) );
-				if( $group->get_owner_uid == $user->get_uid )
-				{
-					$ok = 0;
-					$group->set_status( Vhffs::Constants::WAITING_FOR_DELETION );
-					$group->commit;
-				}
-			}
-		}
-		
-		if( $ok == 1 )
-		{
-			Vhffs::Robots::vhffs_log( $vhffs, sprintf( "USER delete user %s" , $user->get_username ) );
-        	if( Vhffs::Robots::User::delete( $vhffs, $user ) < 0 )
-			{
-				Vhffs::Robots::vhffs_log( $vhffs, sprintf("Cannot delete user files %s" , $user->get_username ) );
-			}
-			else
-			{
-				Vhffs::Robots::vhffs_log( $vhffs, sprintf("Delete user files %s" , $user->get_username ) );
-			}
-
-			if( $user->delete < 0 )
-			{
-				Vhffs::Robots::vhffs_log( $vhffs, sprintf("Cannot delete user object %s" , $user->get_username ) );
-			}
-			else
-			{
-				Vhffs::Robots::vhffs_log( $vhffs, sprintf("Delete user object %s" , $user->get_username ) );
-			}
-		}
-		else
-		{
-			Vhffs::Robots::vhffs_log( $vhffs, sprintf("Cannot remove user %s, remains group(s)" , $user->get_username ) );
-		}
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "usergroup" );
-exit 0;


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