[vhffs-dev] [370] Welcome to our new christmas' bugs

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


Revision: 370
Author:   beuss
Date:     2006-12-10 20:43:03 +0000 (Sun, 10 Dec 2006)

Log Message:
-----------
Welcome to our new christmas' bugs
You can adopt one of them for free
Removed almost all calls to "$group = new Vhffs::Group( junk ); $group->fetch" by "$group = Vhffs::Group::get_by_xxx(only_useful_data)"

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Group.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Repository.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/LargeFile.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
    branches/vhffs_4.1/vhffs-irc/modobot.pl
    branches/vhffs_4.1/vhffs-panel/acl/add_acl_group.pl
    branches/vhffs_4.1/vhffs-panel/acl/view.pl
    branches/vhffs_4.1/vhffs-panel/admin/group/edit.pl
    branches/vhffs_4.1/vhffs-panel/admin/group/edit_submit.pl
    branches/vhffs_4.1/vhffs-panel/admin/group/show.pl
    branches/vhffs_4.1/vhffs-panel/group/prefs.pl
    branches/vhffs_4.1/vhffs-panel/group/project_submit.pl
    branches/vhffs_4.1/vhffs-panel/group/quota_used.pl
    branches/vhffs_4.1/vhffs-panel/largefile/complete.pl
    branches/vhffs_4.1/vhffs-panel/largefile/infos.pl
    branches/vhffs_4.1/vhffs-panel/largefile/prefs.pl
    branches/vhffs_4.1/vhffs-panel/panel.pl
    branches/vhffs_4.1/vhffs-panel/public/group.pl
    branches/vhffs_4.1/vhffs-panel/public/largefile.pl
    branches/vhffs_4.1/vhffs-robots/src/user_group.pl
    branches/vhffs_4.1/vhffs-tools/src/vhffs-groupdel
    branches/vhffs_4.1/vhffs-tools/src/vhffs-quota


Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -221,8 +221,9 @@
 
 sub create {
     return old_create(@_) if($_[0]->isa('Vhffs::Group'));
-    my ($main, $groupname, $owner_uid, $gid) = @_;
+    my ($main, $groupname, $owner_uid, $gid, $description) = @_;
     return undef unless check_groupname($groupname);
+    return undef unless defined($owner_uid);
 
     my $badgroups = $main->get_config->get_bad_groupname;
     if( defined $badgroups ) {
@@ -235,7 +236,7 @@
     my $dbh = $main->get_db_object;
     my $groupconf = $main->get_config->get_users;
 
-    my $parent = Vhffs::Object::create($main, $owner_uid, "Group $groupname");
+    my $parent = Vhffs::Object::create($main, $owner_uid, $description);
     return undef unless(defined $parent);
     
     my $quota = $groupconf->{default_quota} || 10;
@@ -662,12 +663,12 @@
     
     return if ( !defined $vhffs );
    	my @groups;
-    my $query = 'SELECT groupname FROM vhffs_groups g LEFT OUTER JOIN vhffs_users u ON u.username = g.groupname WHERE u.username IS NULL ORDER BY g.gid DESC LIMIT 10';
+    my $query = 'SELECT g.gid FROM vhffs_groups g LEFT OUTER JOIN vhffs_users u ON u.username = g.groupname WHERE u.username IS NULL ORDER BY g.gid DESC LIMIT 10';
     my $request = $vhffs->{'db'}->prepare( $query );
     $request->execute;
-    while( my $row = $request->fetchrow_arrayref )
+    while( my ($gid) = $request->fetchrow_array )
     {
-        my $group = new Vhffs::Group( $vhffs , $row->[0]   , '401' );
+        my $group = Vhffs::Group::get_by_gid( $vhffs , $gid );
         if( $group->fetch > 0 )
         {
             push @groups , $group;
@@ -721,7 +722,7 @@
     my $db = $vhffs->get_db_object;
     my @result;
 
-    my $query = 'SELECT groupname FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id INNER JOIN vhffs_user_group ug ON ug.gid=g.gid LEFT OUTER JOIN vhffs_users u ON u.username = g.groupname WHERE u.username IS NULL AND ug.uid = '.$user->get_uid;
+    my $query = 'SELECT g.gid  FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id INNER JOIN vhffs_user_group ug ON ug.gid=g.gid LEFT OUTER JOIN vhffs_users u ON u.username = g.groupname WHERE u.username IS NULL AND ug.uid = '.$user->get_uid;
 
     $query .= " AND o.state=$state " if( defined $state );
     $query .= " ORDER BY g.groupname";
@@ -731,14 +732,14 @@
 
     return undef if( $rows <= 0 );
 
-    my $names = $request->fetchall_arrayref;
+    my $gids = $request->fetchall_arrayref;
 
     my $group;
-    foreach $name ( @{$names} )
+    foreach $gid ( @{$gids} )
     {
 
-        $group = new Vhffs::Group( $vhffs , $name->[0] , '401' );
-        push( @result , $group) if( $group->fetch > 0 );
+        $group = Vhffs::Group::get_by_gid( $vhffs , $gid->[0] );
+        push( @result , $group) if( defined $group );
     }
     return \@result;
 }
@@ -769,9 +770,8 @@
 	my $group;
 	foreach $name ( @{$names} )
 	{
-		
-		$group = new Vhffs::Group( $vhffs , $name->[0] , '401' );
-		push( @result , $group) if( $group->fetch > 0 );
+		$group = Vhffs::Group::get_by_groupname( $vhffs , $name->[0] );
+		push( @result , $group) if( defined $group );
     }
     return \@result;
 }
@@ -799,8 +799,8 @@
     foreach my $name ( @{$names} )
     {   
 
-        $group = new Vhffs::Group( $vhffs , $name->[0] , '401' );
-        push( @result , $group) if( $group->fetch > 0 );
+        $group = Vhffs::Group::get_by_groupname( $vhffs , $name->[0] );
+        push( @result , $group) if( defined $group );
     }
     return \@result;
 
@@ -812,6 +812,7 @@
     
     my $dbh = $vhffs->get_db_object;
     my @params = $dbh->selectrow_array($query, undef, $gid);
+    return undef unless(@params);
     my $group = _new Vhffs::Group($vhffs, @params);
     return $group;
 }
@@ -822,6 +823,7 @@
 
     my $dbh = $vhffs->get_db_object;
     my @params = $dbh->selectrow_array($query, undef, $groupname);
+    return undef unless(@params);
     my $group = _new Vhffs::Group($vhffs, @params);
     return $group;
 }

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -474,8 +474,8 @@
 		if( defined $self->{'owner_gid'} )
 		{
 			use Vhffs::Group;
-			$self->{'group'} = new Vhffs::Group( $self->{'main'} , undef ,  $self->{'owner_uid'} , $self->{'owner_gid'} );
-			return( $self->{'group'} ) if( defined( $self->{'group'} ) && (  $self->{'group'}->fetch > 0 ) );
+			$self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
+			return( $self->{'group'} ) if( defined( $self->{'group'} ) );
 		}
 	}
     return undef;
@@ -494,8 +494,8 @@
 		if( defined $self->{'owner_uid'} )
 		{
 			use Vhffs::User;
-			$self->{'user'} = new  Vhffs::User( $self->{'main'} , undef , $self->{'owner_uid'} );
-			return( $self->{'user'} ) if( defined ( $self->{'user'} ) && (  $self->{'user'}->fetch > 0 ));
+			$self->{'user'} = Vhffs::User::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
+			return( $self->{'user'} ) if( defined ( $self->{'user'} ) );
 		}
 	}
     return undef;

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Group.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Group.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -130,21 +130,24 @@
 
 sub create_group
 {
-	my( $groupname , $user , $main ) = @_;
+	my( $groupname , $user , $main, $description ) = @_;
 
-	return undef if( $user->fetch < 0);
+	#return undef if( $user->fetch < 0);
 
-	my $group = new Vhffs::Group( $main , $groupname , $user->get_uid) ;
+	#my $group = new Vhffs::Group( $main , $groupname , $user->get_uid) ;
 
-	return -1 if( ! defined $group );
+	#return -1 if( ! defined $group );
 
-	return -2 if ($group->create < 0);
+	#return -2 if ($group->create < 0);
+	my $group = Vhffs::Group::create($main, $groupname, $user->get_uid, undef, $description);
 
-	return -3 if ($group->add_user( $user ) < 0 );
+    return undef unless( defined $group );
 
-    return -4 if ( Vhffs::Acl::add_acl( $user , $group , Vhffs::Constants::ACL_DELETE , $main ) < 0 ); 
+	return undef if ($group->add_user( $user ) < 0 );
 
-	return 1;
+    return undef if ( Vhffs::Acl::add_acl( $user , $group , Vhffs::Constants::ACL_DELETE , $main ) < 0 ); 
+
+	return $group;
 }
 
 

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Main.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -143,20 +143,13 @@
 
 	if( ! defined $bad_news )
 	{
-		$user = new Vhffs::User( $vhffs , $username , '401' );
-	
 		#Try to verify if the user exist and is allowed to browse panel
 		#Then, set some preferences
-		if( ! defined $user || $user->fetch < 0 )
-		{
+		unless( defined($user = Vhffs::User::get_by_uid($vhffs, $uid)) ) {
 			$bad_news = gettext("User does not exist");
-		}
-		elsif( $user->get_status != Vhffs::Constants::ACTIVATED )
-		{
+		} elsif( $user->get_status != Vhffs::Constants::ACTIVATED ) {
 			$bad_news = gettext("You're are not allowed to browse panel");
-		}
-		else
-		{
+		} else {
 			cookie_lang( $vhffs );
 		}
 	}
@@ -177,8 +170,8 @@
 	my $group;
 	$projectname = $session->param("project");
 	if( defined $projectname )  {
-		$group = new Vhffs::Group( $vhffs , $projectname , '401' );
-		if( $group->fetch < 0  ||  $group->get_status != Vhffs::Constants::ACTIVATED  ||  $group->is_user_in_group( $user ) != 1  )
+		$group = Vhffs::Group::get_by_groupname($vhffs, $projectname);
+		if( (! defined($group))  ||  $group->get_status != Vhffs::Constants::ACTIVATED  ||  $group->is_user_in_group( $user ) != 1  )
 		{
 			$session->param("project", NULL);
 			undef $group;
@@ -227,21 +220,18 @@
 
 sub project_info
 {
-	my ( $class , $vhffs , $session , $user ) = @_;
+	my ( $class , $vhffs, $group ) = @_;
 
-	my $projectname = $session->param("project");
 	my $temp;
 	my $object;
 	my $objects;
-	my $group;
 	my $template;
 	my $templatedir;
 	my $subtemplate;
 
 	$templatedir = $vhffs->get_config->get_templatedir;
 		
-	$group = new Vhffs::Group( $vhffs , $projectname , '401' );
-	if( ( ! defined( $group ) ) || ( $group->fetch <= 0 ) )
+	if( ! defined( $group ) ) 
 	{
 		$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 		$template->param( MESSAGE  => gettext("Group error" ) );
@@ -249,7 +239,7 @@
 	else
 	{
 	$template = new HTML::Template( filename => $templatedir."/group/info.tmpl" );
-	$template->param( TEXT_TITLE => sprintf( gettext("Group %s") , $projectname ));
+	$template->param( TEXT_TITLE => sprintf( gettext("Group %s") , $group->get_groupname ));
 	
 	$template->param( GROUPNAME => $group->get_groupname );
 	$template->param( QUOTA_VALUE => sprintf( gettext("Quota (used/total) : %s/%s") , $group->get_quota_used , $group->get_quota ) );

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Repository.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Repository.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Repository.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -97,8 +97,7 @@
 		system( $cmd );
 
 		# remove the link in group directory
-		my $groupname = Vhffs::Group::get_name_by_gid( $vhffs , $repo->get_ownergid );
-		my $group = new Vhffs::Group( $vhffs , $groupname , 401 );
+		my $group = Vhffs::Group::get_by_gid( $vhffs , $repo->get_ownergid );
 		Vhffs::Robots::unlink_to_group( $group, $repo->get_name.Vhffs::Constants::REPOSITORY_SUFFIX, $vhffs );
 
 		$repo->delete;
@@ -125,8 +124,7 @@
 	chown( $repo->get_owneruid , $repo->get_ownergid , $repodir );
 	chmod( 02775 , $repodir );
 
-	my $groupname = Vhffs::Group::get_name_by_gid( $vhffs , $repo->get_ownergid );
-	my $group = new Vhffs::Group( $vhffs , $groupname , 401 );
+	my $group = Vhffs::Group::get_by_gid( $vhffs , $repo->get_ownergid );
 
 	if(Vhffs::Robots::link_to_group( $repodir, $group, $repo->get_name.Vhffs::Constants::REPOSITORY_SUFFIX, $vhffs ) < 0)
 	{

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -89,8 +89,7 @@
 		chown( $web->get_owneruid , $web->get_ownergid , $webdir . "/tmp" ); 
 		chmod( 02775 , $webdir . "/tmp" );
 	
-		my $groupname = Vhffs::Group::get_name_by_gid( $main , $web->get_ownergid );
-		my $group = new Vhffs::Group( $main , $groupname , 401 );
+		my $group = Vhffs::Group::get_by_gid( $main , $web->get_ownergid );
 		if(Vhffs::Robots::link_to_group( $webdir,$group,$web->get_servername.Vhffs::Constants::WEB_SUFFIX,$main) < 0)
 		{
 			$web->add_history( "Can't link the webdirectory to the specified group");

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -153,8 +153,8 @@
     }
 
 
-    $self->{'group'} = new Vhffs::Group( $self->{'main'} , undef ,$self->{'owner_uid'}  , $self->{'owner_gid'} );
-    return -1 if( $self->{'group'}->fetch < 0 );
+    $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
+    return -1 unless( defined $self->{'group'} );
 
 
     $self->SUPER::fetch;

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -143,7 +143,7 @@
 
 	$self->SUPER::fetch;
 
-    $self->{'group'} = new Vhffs::Group( $self->{'main'} , undef ,  $self->{'owner_uid'} , $self->{'owner_gid'} );
+    $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
     return -1 if( $self->{'group'}->fetch < 0 );
 
     $self->{'user'} = new  Vhffs::User( $self->{'main'} , undef , $self->{'owner_uid'} );

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/LargeFile.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/LargeFile.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/LargeFile.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -170,10 +170,9 @@
 		$self->{$_} = $result->{$_}
     }
     
+    $self->{group} = Vhffs::Group::get_by_gid( $self->{main}, $self->{owner_gid} );
+    return -1 unless defined ($self->{group});
     
-    $self->{'group'} = new Vhffs::Group( $self->{'main'} , undef ,  $self->{'owner_uid'} , $self->{'owner_gid'} );
-    return -1 if( $self->{'group'}->fetch < 0 );
-    
     $self->{'user'} = new  Vhffs::User( $self->{'main'} , undef , $self->{'owner_uid'} );
     return -1 if( $self->{'user'}->fetch < 0 );
     
@@ -389,7 +388,7 @@
 
     while( $result = $request->fetchrow_hashref )
     {
-		$group = new Vhffs::Group( $vhffs , undef , $result->{'owner_uid'} , $result->{'owner_gid'} );
+        $group = Vhffs::Group::get_by_gid( $vhffs, $result->{owner_gid} );
 
         $tmp = new Vhffs::Services::LargeFile( $vhffs , $result->{'filename'} , undef , $group );
         if( ( defined ( $tmp ) ) && ( $tmp->fetch > 0 ) )

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -154,8 +154,8 @@
 		$self->{$_} = $result->{$_}
 	}
 
-	$self->{'group'} = new Vhffs::Group( $self->{'main'} , undef ,$self->{'owner_uid'}  , $self->{'owner_gid'} );
-	return -1 if( $self->{'group'}->fetch < 0 );
+	$self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
+	return -1 unless( defined $self->{'group'} );
 
 
 	$self->SUPER::fetch;

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -153,11 +153,11 @@
     }
     
     
-    $self->{'group'} = new Vhffs::Group( $self->{'main'} , undef ,  $self->{'owner_uid'} , $self->{'owner_gid'} );
-    return -1 if( $self->{'group'}->fetch < 0 );
+    $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
+    return -1 unless( defined $self->{'group'} );
     
-    $self->{'user'} = new  Vhffs::User( $self->{'main'} , undef , $self->{'owner_uid'} );
-    return -1 if( $self->{'user'}->fetch < 0 );
+    $self->{'user'} = Vhffs::Group::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
+    return -1 unless( defined $self->{'user'} );
     
     
     $self->SUPER::fetch;
@@ -283,7 +283,7 @@
 
     while( $result = $request->fetchrow_hashref )
     {
-	my $group = new Vhffs::Group( $vhffs , undef , $result->{'owner_uid'} , $result->{'owner_gid'} );
+	    my $group = Vhffs::Group::get_by_gid( $vhffs , $result->{'owner_gid'} );
 
         $tmp = new Vhffs::Services::Svn( $vhffs , $result->{'reponame'} , undef , $group );
         if( ( defined ( $tmp ) ) && ( $tmp->fetch > 0 ) )

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2006-12-10 20:43:03 UTC (rev 370)
@@ -920,10 +920,10 @@
 	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 $row = $request->fetchrow_arrayref )
+	while( my ($groupname) = $request->fetchrow_array )
 	{
-		my $group = new Vhffs::Group( $self->{'main'} , $row->[0] , '401' );
-		push( @groups , $group ) if( $group->fetch );
+		my $group = Vhffs::Group::get_by_groupname( $self->{'main'} , $groupname );
+		push( @groups , $group ) if( defined($group) );
 	}
 	return \@groups;
 }

Modified: branches/vhffs_4.1/vhffs-irc/modobot.pl
===================================================================
--- branches/vhffs_4.1/vhffs-irc/modobot.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-irc/modobot.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -490,13 +490,13 @@
 {
     my $name = shift;
     my $group;
-    if ((! defined ($group= new Vhffs::Group( $vhffs , $name , '401' ) ) ) || ( $group->fetch < 0 ))
+    if (! defined ($group= Vhffs::Group::get_by_groupname( $vhffs , $name ) ) )
     {
         irc_msg ("$name : No such group");
     }
     else
     {
-        irc_msg ("$name : " . Vhffs::Functions::stripslashes ($group->get_description));
+        irc_msg ("$name : " . $group->get_description );
     }
 }
 

Modified: branches/vhffs_4.1/vhffs-panel/acl/add_acl_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/acl/add_acl_group.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/acl/add_acl_group.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -74,8 +74,8 @@
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
-my $obj_src = new Vhffs::Group( $vhffs , $groupname , '401' );
-my $obj_dst = new Vhffs::Object( $vhffs , $oid_dst , '401' );
+my $obj_src = Vhffs::Group::get_by_groupname( $vhffs , $groupname );
+my $obj_dst = Vhffs::Object::get_by_id( $vhffs , $oid_dst );
 
 
 my $message;
@@ -86,10 +86,6 @@
 }
 elsif( ( ! defined $obj_src ) || ( ! defined $obj_dst ) )
 {
-	$message = gettext( "Object Error" );
-}
-elsif( ( $obj_src->fetch < 0 ) || ( $obj_dst->fetch  < 0) )
-{
 	$message = gettext( "The group does not exist" );
 }
 else

Modified: branches/vhffs_4.1/vhffs-panel/acl/view.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/acl/view.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/acl/view.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -227,8 +227,7 @@
 
         foreach( keys %{$group_rights} )
         {   
-			$g = new Vhffs::Group( $vhffs , $group_rights->{$_}{'groupname'} , '401' );
-			$g->fetch;
+			$g = Vhffs::Group::get_by_groupname($vhffs , $group_rights->{$_}{'groupname'} );
 
             $subtemplate = new HTML::Template( filename => $templatedir."/acl/view_each.tmpl" );
             $subtemplate->param( NAME => $group_rights->{$_}{'groupname'} );

Modified: branches/vhffs_4.1/vhffs-panel/admin/group/edit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/group/edit.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/admin/group/edit.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -55,16 +55,14 @@
 my $session = $panel->{'session'};
 my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-#my $group = $panel->{'group'};
 my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
 my $groupname = $cgi->param("NAME");
 my $template;
+my $group;
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $object;
-
 if( $user->is_admin != 1 )
 {
 	
@@ -73,12 +71,12 @@
 	$template->param( MESSAGE => $message );
 }
 elsif( ! defined $groupname )
-{
-	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
-	my $message = sprintf( gettext("CGI ERROR ! %s"), $groupname );
-	$template->param( MESSAGE => $message );
+{   
+    $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
+    my $message = gettext( "CGI ERROR !");
+    $template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::Group( $vhffs , $groupname , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $group = Vhffs::Group::get_by_groupname($vhffs, $groupname) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");
@@ -101,16 +99,16 @@
 	$template->param( SEND => gettext("Send") );
 	$template->param( TEXT_HISTORY => gettext("History") );
 
-	$template->param( VALUE_GROUPNAME => $object->get_groupname );
-	$template->param( VALUE_GID => $object->get_gid );
-	$template->param( VALUE_OWNER => $object->get_owner_username );
-	$template->param( VALUE_QUOTA => $object->get_quota );
-	$template->param( VALUE_QUOTA_USED => $object->get_quota_used );
-	$template->param( VALUE_DESCRIPTION => $object->get_description );
+	$template->param( VALUE_GROUPNAME => $group->get_groupname );
+	$template->param( VALUE_GID => $group->get_gid );
+	$template->param( VALUE_OWNER => $group->get_owner_username );
+	$template->param( VALUE_QUOTA => $group->get_quota );
+	$template->param( VALUE_QUOTA_USED => $group->get_quota_used );
+	$template->param( VALUE_DESCRIPTION => $group->get_description );
 
-$template->param( QUOTA_VALUE => sprintf( gettext("Quota (used/total) : %s/%s") , $object->get_quota_used , $object->get_quota ) );
+$template->param( QUOTA_VALUE => sprintf( gettext("Quota (used/total) : %s/%s") , $group->get_quota_used , $group->get_quota ) );
 
-	my $oid = $object->get_oid;
+	my $oid = $group->get_oid;
 	$template->param( VALUE_HISTORY => "/history.pl?OID=$oid" );
 
 	$template->param( TEXT_STATUS_WAITING_FOR_VALIDATION => gettext("Waiting for validation") );
@@ -140,7 +138,7 @@
 	$template->param( VALUE_STATUS_MODIFICATION_APPLIED => Vhffs::Constants::MODIFICATION_APPLIED );
 	$template->param( VALUE_STATUS_TO_DELETE => Vhffs::Constants::TO_DELETE );
 
-	my $status = $object->get_status;
+	my $status = $group->get_status;
 
 	if( $status == Vhffs::Constants::WAITING_FOR_VALIDATION )
 	{

Modified: branches/vhffs_4.1/vhffs-panel/admin/group/edit_submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/group/edit_submit.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/admin/group/edit_submit.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -55,7 +55,6 @@
 my $session = $panel->{'session'};
 my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-#my $group = $panel->{'group'};
 my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
 my $groupname = $cgi->param("NAME");
@@ -63,7 +62,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $object;
+my $group;
 my $message;
 my $status = $cgi->param( "STATUS" );
 my $quota = $cgi->param( "QUOTA" );
@@ -83,7 +82,7 @@
 	my $message = gettext( "CGI ERROR !");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::Group( $vhffs , $groupname , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $group = Vhffs::Group::get_by_groupname($vhffs, $groupname) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");
@@ -100,12 +99,12 @@
 
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
-	$object->set_status( $status );
-	$object->set_quota( $quota );
-	$object->set_quota_used( $quotau );
+	$group->set_status( $status );
+	$group->set_quota( $quota );
+	$group->set_quota_used( $quotau );
 
 
-	if( $object->commit < 0 )
+	if( $group->commit < 0 )
 	{
 		$message = gettext("Can't modify object...");
 	}

Modified: branches/vhffs_4.1/vhffs-panel/admin/group/show.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/group/show.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/admin/group/show.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -55,7 +55,6 @@
 my $session = $panel->{'session'};
 my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-#my $group = $panel->{'group'};
 my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
 my $groupname = $cgi->param("NAME");
@@ -63,7 +62,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $object;
+my $group;
 
 if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
 {
@@ -78,7 +77,7 @@
 	my $message = sprintf( gettext("CGI ERROR ! %s"), $groupname );
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::Group( $vhffs , $groupname , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $group = Vhffs::Group::get_by_groupname( $vhffs , $groupname ) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");
@@ -99,15 +98,15 @@
 	$template->param( TEXT_DESCRIPTION => gettext("Description") );
 	$template->param( TEXT_HISTORY => gettext("History") );
 
-	$template->param( VALUE_GROUPNAME => $object->get_groupname );
-	$template->param( VALUE_GID => $object->get_gid );
-	$template->param( VALUE_OWNER => $object->get_owner_username );
-	$template->param( VALUE_QUOTA => $object->get_quota );
-	$template->param( VALUE_QUOTA_USED => $object->get_quota_used );
-	$template->param( VALUE_DESCRIPTION => $object->get_description );
-	$template->param( VALUE_STATUS => Vhffs::Functions::status_string_from_status_id ($object->get_status) );
+	$template->param( VALUE_GROUPNAME => $group->get_groupname );
+	$template->param( VALUE_GID => $group->get_gid );
+	$template->param( VALUE_OWNER => $group->get_owner_username );
+	$template->param( VALUE_QUOTA => $group->get_quota );
+	$template->param( VALUE_QUOTA_USED => $group->get_quota_used );
+	$template->param( VALUE_DESCRIPTION => $group->get_description );
+	$template->param( VALUE_STATUS => Vhffs::Functions::status_string_from_status_id ($group->get_status) );
 
-	my $oid = $object->{'object_id'};
+	my $oid = $group->{'object_id'};
 	$template->param( VALUE_HISTORY => "/history.pl?OID=$oid" );
 }
 

Modified: branches/vhffs_4.1/vhffs-panel/group/prefs.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/group/prefs.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/group/prefs.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -61,9 +61,9 @@
 my $message;
 
 
-my $group = new Vhffs::Group( $vhffs , $projectname , '401' );
+my $group = $panel->{'group'};
 
-if( ( ! defined $group ) || ( $group->fetch < 0 ) )
+if( ! defined $group )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	$template->param( MESSAGE => gettext( "Error. This group doesn't exists") );

Modified: branches/vhffs_4.1/vhffs-panel/group/project_submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/group/project_submit.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/group/project_submit.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -78,29 +78,9 @@
 }
 else
 {
-	$retour = Vhffs::Panel::Group::create_group( $groupname , $user , $vhffs );
-
-	if( $retour == -1  )
-	{
-		$message = gettext("The groupname should contain at least 3 caracters and must contain only letters or numbers");
-	}
-	#elsif( ! defined ( $group = Vhffs::Panel::Group::create_group( $groupname , $user , $vhffs ) ) )
-	elsif( $retour == -2 )
-	{
-		$message = gettext("This group already exists");
-	}
-	elsif( $retour < -2 )
-	{
-		$message = gettext("Error while creation !");
-	}
-	else
-	{
-		$group = new Vhffs::Group( $vhffs , $groupname , $user );
-		$group->fetch;
-		$group->set_description( quotemeta( $description ) );
-	
-		# Commit all the changes for the current project
-		$group->commit;
+	if ( ! defined($group = Vhffs::Panel::Group::create_group( $groupname , $user , $vhffs, $description )) ) {
+        $message = gettext('Error creating group (maybe a group with the same name already exists)');
+	} else {
 		$message = gettext("Project Successfully created !");
 	}
 }

Modified: branches/vhffs_4.1/vhffs-panel/group/quota_used.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/group/quota_used.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/group/quota_used.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -60,7 +60,7 @@
 my $templatedir = $vhffs->get_config->get_templatedir;
 my $template;
 my $subtemplate;
-my $group = new Vhffs::Group( $vhffs , $groupname , '401' );
+my $group = Vhffs::Group::get_by_groupname( $vhffs , $groupname );
 
 my $status;
 my $quota;
@@ -80,7 +80,7 @@
 
 $status = 0;
 
-if( ( ! defined $group ) || ( $group->fetch < 0 ) )
+if( ( ! defined $group ) )
 {
 	$gd = GD::Image->new(70,100);
 	$white = $gd->colorAllocate(255,255,255);

Modified: branches/vhffs_4.1/vhffs-panel/largefile/complete.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/largefile/complete.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/largefile/complete.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -67,8 +67,7 @@
 
 if( defined $cgigroupname )
 {
-	$group = new Vhffs::Group( $vhffs , $cgigroupname , '401' );
-	$group->fetch;
+	$group = Vhffs::Group::get_by_groupname( $vhffs , $cgigroupname );
 }
 
 $file = new Vhffs::Services::LargeFile( $vhffs , $filename  , undef , $group );

Modified: branches/vhffs_4.1/vhffs-panel/largefile/infos.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/largefile/infos.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/largefile/infos.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -67,8 +67,7 @@
 
 if( defined $cgigroupname )
 {
-	$group = new Vhffs::Group( $vhffs , $cgigroupname , '401' );
-	$group->fetch;
+    $group = Vhffs::Group::get_by_groupname( $vhffs, $cgigroupname );
 }
 
 $file = new Vhffs::Services::LargeFile( $vhffs , $filename  , undef , $group );

Modified: branches/vhffs_4.1/vhffs-panel/largefile/prefs.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/largefile/prefs.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/largefile/prefs.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -67,7 +67,7 @@
 
 if( defined $cgigroupname )
 {
-	$group = new Vhffs::Group( $vhffs , $cgigroupname , '401' );
+	$group = Vhffs::Group::get_by_groupname( $vhffs , $cgigroupname );
 	$group->fetch;
 }
 

Modified: branches/vhffs_4.1/vhffs-panel/panel.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/panel.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/panel.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -103,7 +103,7 @@
 {
 	if( defined $projectname )
 	{
-		$template = project_info Vhffs::Panel::Main($vhffs , $session , $user);
+		$template = project_info Vhffs::Panel::Main($vhffs, $panel->{group});
 	}
 	else
 	{

Modified: branches/vhffs_4.1/vhffs-panel/public/group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/public/group.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/public/group.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -69,7 +69,7 @@
 	$message = gettext( "CGI ERROR!");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ($group= new Vhffs::Group( $vhffs , $name , '401' ) ) ) || ( $group->fetch < 0 ))
+elsif( ! defined ($group= Vhffs::Group::get_by_groupname( $vhffs , $name ) ) )
 {
 
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
@@ -96,7 +96,7 @@
 	my $user;
 	if( ! defined $users )
 	{
-		$template->param( VALUE_USERS => gettext("No group for this user") );
+		$template->param( VALUE_USERS => gettext("No user for this group") );
 	}
 	else
 	{

Modified: branches/vhffs_4.1/vhffs-panel/public/largefile.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/public/largefile.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-panel/public/largefile.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -85,7 +85,7 @@
 	$message = gettext( "Does not support largefile");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ($group= new Vhffs::Group( $vhffs , $groupname , '401' ) ) ) || ( $group->fetch < 0 ))
+elsif( ! defined ($group= Vhffs::Group::get_by_groupname( $vhffs , $groupname ) ) )
 {
 
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );

Modified: branches/vhffs_4.1/vhffs-robots/src/user_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/user_group.pl	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-robots/src/user_group.pl	2006-12-10 20:43:03 UTC (rev 370)
@@ -50,14 +50,12 @@
 {
 foreach( keys %{$joins} )
 {
-	$name = Vhffs::Group::get_name_by_gid( $vhffs , $_ );
-	$group = new Vhffs::Group( $vhffs , $name ,  '401' );
-	if( ( defined $group ) && ( $group->fetch > 0 ) )
+	$group = Vhffs::Group::get_by_gid( $vhffs , $_ );
+	if( defined $group )
 	{
-		$name = Vhffs::User::get_name_by_uid( $vhffs , $joins->{$_}{'uid'} );
-		$user = new Vhffs::User( $vhffs , $name , '401' );
+        $user = Vhffs::User::get_by_uid($vhffs, $joins->{$_}{'uid'} );
 
-		if( ( defined $user ) && ( $user->fetch > 0 ) )
+		if( defined $user )
 		{
 			if( Vhffs::Robots::Group::add_user( $user , $group , $vhffs ) < 0 )
 			{
@@ -76,7 +74,7 @@
 	}
 	else
 	{
-		Vhffs::Robots::vhffs_log( sprintf( "Cannot get user %s" , $_ ), $vhffs);
+		Vhffs::Robots::vhffs_log( sprintf( "Cannot get group %s" , $_ ), $vhffs);
 	}
 }
 }
@@ -93,14 +91,12 @@
 
 foreach( keys %{$joins} )
 {
-	$name = Vhffs::Group::get_name_by_gid( $vhffs , $_ );
-	$group = new Vhffs::Group( $vhffs , $name ,  '401' );
-	if( ( defined $group ) && ( $group->fetch > 0 ) )
+	$group = Vhffs::Group::get_by_gid( $vhffs , $_ );
+	if( defined $group )
 	{
-		$name = Vhffs::User::get_name_by_uid( $vhffs , $joins->{$_}{'uid'} );
-		$user = new Vhffs::User( $vhffs , $name , '401' );
+		$user = Vhffs::User::get_by_uid( $vhffs , $joins->{$_}{'uid'} );
 
-		if( ( defined $user ) && ( $user->fetch > 0 ) )
+		if( defined $user )
 		{
 			Vhffs::Robots::vhffs_log( sprintf( "Remove user %s from group %s" , $user->get_username , $group->get_groupname ), $vhffs);
 			Vhffs::Robots::Group::del_user( $user , $group , $vhffs );

Modified: branches/vhffs_4.1/vhffs-tools/src/vhffs-groupdel
===================================================================
--- branches/vhffs_4.1/vhffs-tools/src/vhffs-groupdel	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-tools/src/vhffs-groupdel	2006-12-10 20:43:03 UTC (rev 370)
@@ -11,10 +11,10 @@
 }
 
 my $vhffs = init Vhffs::Main;
-my $group = new Vhffs::Group( $vhffs , $ARGV[0] , '401' );
+my $group = Vhffs::Group::get_by_groupname( $vhffs , $ARGV[0] );
 
 
-if( ( defined $group ) && ( $group->fetch == 1 ) )
+if( defined $group )
 {
 	$group->set_status( Vhffs::Constants::TO_DELETE );
 	

Modified: branches/vhffs_4.1/vhffs-tools/src/vhffs-quota
===================================================================
--- branches/vhffs_4.1/vhffs-tools/src/vhffs-quota	2006-12-10 17:15:37 UTC (rev 369)
+++ branches/vhffs_4.1/vhffs-tools/src/vhffs-quota	2006-12-10 20:43:03 UTC (rev 370)
@@ -30,20 +30,14 @@
 my $vhffs = init Vhffs::Main;
 
 #Create new group
-my $group = new Vhffs::Group( $vhffs , $groupname  , '401' );
+my $group = Vhffs::Group::get_by_groupname( $vhffs , $groupname );
 
 if( ! defined $group )
 {
 	print "Error while build vhffs object\n";
 	exit( -1 );
 }
-elsif( $group->fetch < 0 )
-{
-	print "Group does not exists\n";
-	exit( -2 );
-}
 
-
 if( $action eq 'get' )
 {
 	print "Quota used for this group:\t".$group->get_quota_used."Mb\n";


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