[vhffs-dev] [2078] finished user<>group reworking |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2078
Author: gradator
Date: 2012-02-28 20:20:21 +0100 (Tue, 28 Feb 2012)
Log Message:
-----------
finished user<>group reworking
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Robots/UserGroup.pm
trunk/vhffs-api/src/Vhffs/UserGroup.pm
trunk/vhffs-robots/Makefile.am
Added Paths:
-----------
trunk/vhffs-robots/src/usergroup.pl
Removed Paths:
-------------
trunk/vhffs-robots/src/user_group.pl
Modified: trunk/vhffs-api/src/Vhffs/Robots/UserGroup.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/UserGroup.pm 2012-02-28 00:24:13 UTC (rev 2077)
+++ trunk/vhffs-api/src/Vhffs/Robots/UserGroup.pm 2012-02-28 19:20:21 UTC (rev 2078)
@@ -53,16 +53,19 @@
unless( $vhffs->get_config->use_vhffsfs ) {
my $groupdir = $group->get_dir;
my $path = $user->get_home.'/'.$group->get_groupname;
- symlink( $groupdir, $path );
+ unless( symlink( $groupdir, $path ) ) {
+ $usergroup->set_status( Vhffs::Constants::CREATION_ERROR );
+ $usergroup->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while adding user '.$user->get_username.' to group '.$group->get_groupname.' to the filesystem' );
+ return undef;
+ }
}
-# $group->add_history("The user ".$user->get_username." join the group");
-# $user->add_history("The user ".$user->get_username." join the group");
$usergroup->set_status( Vhffs::Constants::ACTIVATED );
$usergroup->commit;
-
-#Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Error while adding user %s to group %s" , $user->get_username , $group->get_groupname ));
-#Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Added user %s to group %s" , $user->get_username , $group->get_groupname ));
+ $user->add_history( 'Joined group '.$group->get_groupname );
+ $group->add_history( $user->get_username.' user joined' );
+ Vhffs::Robots::vhffs_log( $vhffs, 'Added user '.$user->get_username.' to group '.$group->get_groupname );
return 1;
}
@@ -76,15 +79,24 @@
unless( $vhffs->get_config->use_vhffsfs ) {
my $path = $user->get_home.'/'.$group->get_groupname;
- unlink( $path );
+ unless( unlink( $path ) ) {
+ $usergroup->set_status( Vhffs::Constants::DELETION_ERROR );
+ $usergroup->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while removing user '.$user->get_username.' from group '.$group->get_groupname.' from the filesystem' );
+ return undef;
+ }
}
- $usergroup->delete;
-# $group->add_history('The user '.$user->get_username.' left the group');
-# $user->add_history('The user '.$user->get_username.' left the group');
+ unless( $usergroup->delete ) {
+ $usergroup->set_status( Vhffs::Constants::DELETION_ERROR );
+ $usergroup->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while removing user '.$user->get_username.' from group '.$group->get_groupname.' object' );
+ return undef;
+ }
-#Vhffs::Robots::vhffs_log( $vhffs, sprintf( 'Removed user %s from group %s', $user->get_username, $group->get_groupname ));
-#Vhffs::Robots::vhffs_log( $vhffs, sprintf( 'Error while removing user %s from group %s', $user->get_username, $group->get_groupname ));
+ $user->add_history( 'Left group '.$group->get_groupname );
+ $group->add_history( $user->get_username.' user left' );
+ Vhffs::Robots::vhffs_log( $vhffs, 'Removed user '.$user->get_username.' from group '.$group->get_groupname );
return 1;
}
Modified: trunk/vhffs-api/src/Vhffs/UserGroup.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/UserGroup.pm 2012-02-28 00:24:13 UTC (rev 2077)
+++ trunk/vhffs-api/src/Vhffs/UserGroup.pm 2012-02-28 19:20:21 UTC (rev 2078)
@@ -169,7 +169,7 @@
my $query = 'UPDATE vhffs_user_group SET state=? WHERE uid=? AND gid=?';
my $dbh = $self->get_vhffs->get_db_object;
my $result = $dbh->prepare($query);
- $result->execute( $self->{'state'} , $self->{'user'}->get_uid , $self->{'group'}->get_gid ) or return undef;
+ $result->execute( $self->{'state'}, $self->{'user'}->get_uid, $self->{'group'}->get_gid ) or return undef;
return 1;
}
@@ -188,7 +188,7 @@
my $query = 'DELETE FROM vhffs_user_group WHERE uid=? AND gid=?';
my $dbh = $self->get_vhffs->get_db_object;
my $request = $dbh->prepare($query);
- $request->execute( $self->{'user'}->get_uid , $self->{'group'}->get_gid ) or return undef;
+ $request->execute( $self->{'user'}->get_uid, $self->{'group'}->get_gid ) or return undef;
return 1;
}
Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am 2012-02-28 00:24:13 UTC (rev 2077)
+++ trunk/vhffs-robots/Makefile.am 2012-02-28 19:20:21 UTC (rev 2078)
@@ -44,7 +44,7 @@
src/user.pl \
src/user_quota.pl \
src/user_cleanup.pl \
- src/user_group.pl \
+ src/usergroup.pl \
src/web.pl \
src/web_stats.pl \
src/cron.pl
Deleted: trunk/vhffs-robots/src/user_group.pl
===================================================================
--- trunk/vhffs-robots/src/user_group.pl 2012-02-28 00:24:13 UTC (rev 2077)
+++ trunk/vhffs-robots/src/user_group.pl 2012-02-28 19:20:21 UTC (rev 2078)
@@ -1,60 +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::UserGroup;
-
-my $vhffs = init Vhffs::Main;
-exit 1 unless defined $vhffs;
-
-Vhffs::Robots::lock( $vhffs , "usergroup" );
-
-my $usergroups = Vhffs::UserGroup::getall( $vhffs, Vhffs::Constants::WAITING_FOR_CREATION );
-foreach ( @{$usergroups} ) {
- Vhffs::Robots::UserGroup::create( $_ );
-}
-
-$usergroups = Vhffs::UserGroup::getall( $vhffs, Vhffs::Constants::WAITING_FOR_DELETION );
-foreach ( @{$usergroups} ) {
- Vhffs::Robots::UserGroup::delete( $_ );
-}
-
-$usergroups = Vhffs::UserGroup::getall( $vhffs, Vhffs::Constants::WAITING_FOR_MODIFICATION );
-foreach ( @{$usergroups} ) {
- Vhffs::Robots::UserGroup::modify( $_ );
-}
-
-Vhffs::Robots::unlock( $vhffs , 'usergroup' );
-
-exit 0;
Copied: trunk/vhffs-robots/src/usergroup.pl (from rev 2077, trunk/vhffs-robots/src/user_group.pl)
===================================================================
--- trunk/vhffs-robots/src/usergroup.pl (rev 0)
+++ trunk/vhffs-robots/src/usergroup.pl 2012-02-28 19:20:21 UTC (rev 2078)
@@ -0,0 +1,60 @@
+#!%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::UserGroup;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs , 'usergroup' );
+
+my $usergroups = Vhffs::UserGroup::getall( $vhffs, Vhffs::Constants::WAITING_FOR_CREATION );
+foreach ( @{$usergroups} ) {
+ Vhffs::Robots::UserGroup::create( $_ );
+}
+
+$usergroups = Vhffs::UserGroup::getall( $vhffs, Vhffs::Constants::WAITING_FOR_DELETION );
+foreach ( @{$usergroups} ) {
+ Vhffs::Robots::UserGroup::delete( $_ );
+}
+
+$usergroups = Vhffs::UserGroup::getall( $vhffs, Vhffs::Constants::WAITING_FOR_MODIFICATION );
+foreach ( @{$usergroups} ) {
+ Vhffs::Robots::UserGroup::modify( $_ );
+}
+
+Vhffs::Robots::unlock( $vhffs , 'usergroup' );
+
+exit 0;