[vhffs-dev] [379] Almost all core code now use get_by_xxx for User and Group instead of new + fetch scheme

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


Revision: 379
Author:   beuss
Date:     2006-12-18 06:45:18 +0000 (Mon, 18 Dec 2006)

Log Message:
-----------
Almost all core code now use get_by_xxx for User and Group instead of new + fetch scheme

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/User.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Group.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.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-jabber/vhffspipe.pl
    branches/vhffs_4.1/vhffs-panel/acl/add_acl_user.pl
    branches/vhffs_4.1/vhffs-panel/acl/view.pl
    branches/vhffs_4.1/vhffs-panel/admin/moderation_submit.pl
    branches/vhffs_4.1/vhffs-panel/admin/user/edit.pl
    branches/vhffs_4.1/vhffs-panel/admin/user/edit_note.pl
    branches/vhffs_4.1/vhffs-panel/admin/user/edit_submit.pl
    branches/vhffs_4.1/vhffs-panel/admin/user/show.pl
    branches/vhffs_4.1/vhffs-panel/group/join_group.pl
    branches/vhffs_4.1/vhffs-panel/group/remove_user_from_group.pl
    branches/vhffs_4.1/vhffs-panel/login.pl
    branches/vhffs_4.1/vhffs-panel/lost_ack.pl
    branches/vhffs_4.1/vhffs-panel/panel.pl
    branches/vhffs_4.1/vhffs-panel/public/user.pl
    branches/vhffs_4.1/vhffs-tests/src/Group.pl
    branches/vhffs_4.1/vhffs-tools/src/vhffs-makeadmin
    branches/vhffs_4.1/vhffs-tools/src/vhffs-passwd
    branches/vhffs_4.1/vhffs-tools/src/vhffs-userdel
    branches/vhffs_4.1/vhffs-tools/src/vhffs-usermod


Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2006-12-18 06:45:18 UTC (rev 379)
@@ -224,7 +224,6 @@
     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 ) {
         foreach ( @{$badgroups} ) {
@@ -686,13 +685,13 @@
     return undef if( $self->fetch < 0 );
     my @users;
     my $gid = $self->get_gid;
-    my $query = 'SELECT u.username FROM vhffs_users u INNER JOIN vhffs_user_group ug ON u.uid = ug.uid WHERE ug.gid = ?';
+    my $query = 'SELECT ug.uid FROM vhffs_user_group ug WHERE ug.gid = ?';
     my $request = $self->{'db'}->prepare( $query );
     $request->execute($gid);
-    while( my $row = $request->fetchrow_arrayref )
+    while( my ($uid) = $request->fetchrow_array )
     {
-        my $user = new Vhffs::User( $self->{'main'} , $row->[0] , '401' );
-        push( @users , $user ) if( $user->fetch );
+        my $user = Vhffs::User::get_by_uid( $self->{'main'} , $uid );
+        push( @users , $user ) if( defined $user );
     }
     return \@users;
 }

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm	2006-12-18 06:45:18 UTC (rev 379)
@@ -179,8 +179,8 @@
     $sth->execute($owner_uid, $state, $description) or return undef;
     my $oid = $vhffs->get_db_object->last_insert_id(undef, undef, 'vhffs_object', undef);
 
-    $res = new Vhffs::Object($vhffs, $oid, $owner_uid);
-    $res->fetch;
+    my $res = get_by_id($vhffs, $oid);
+
     $res->add_history('Object created');
     return $res;
 }

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/User.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/User.pm	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/User.pm	2006-12-18 06:45:18 UTC (rev 379)
@@ -48,13 +48,13 @@
 
 	return if ( !defined $vhffs );
 
-	my $query = "SELECT username FROM vhffs_users ORDER BY uid LIMIT 0,10";
+	my $query = "SELECT uid FROM vhffs_users ORDER BY uid LIMIT 0,10";
     my $request = $vhffs->{'db'}->prepare( $query );
 
-	while( my $hash =  $request->fetchrow_hashref )
+	while( my ($uid) =  $request->fetchrow_array )
 	{
-		my $user = new Vhffs::Users( $vhffs , $hash->{username} , '401' );	
-		if( $user->fetch > 0 )
+		my $user = Vhffs::User::get_by_uid( $vhffs , $uid );	
+		if( defined $user )
 		{
 			push @users , $user;
 		}

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Group.pm	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Group.pm	2006-12-18 06:45:18 UTC (rev 379)
@@ -69,9 +69,11 @@
 	my $group = shift;
 
 	my $hash;
-	if( ( defined $group ) && ( $group->fetch > 0 ) )
+    # If we have a group object, it has been fetched
+    # and is complete, no need to fetch it again
+	if( defined $group )
 	{
-		my $user = new Vhffs::User( $main , $group->get_owner_username , 401 );
+		my $user = Vhffs::User::get_by_uid( $main , $group->get_owneruid );
 		my $hash = Vhffs::Functions::hash_groupname( $group->get_groupname , $main );	
 		$group->add_history("Ok, Robots will create the directory");
 		Vhffs::Functions::create_dir( $hash );
@@ -97,9 +99,10 @@
 
 
 	my $hash;
-	if( ( defined $group ) && ( $group->fetch > 0 ) )
+    # If group is defined, it is complete
+	if( defined $group )
 	{
-		my $user = new Vhffs::User( $main , $group->get_owner_username , 401 );
+		my $user = Vhffs::User::get_by_uid( $main , $group->get_owneruid );
 		my $hash = Vhffs::Functions::hash_groupname( $group->get_groupname , $main );	
 		if( -d $hash )
 		{

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm	2006-12-18 06:45:18 UTC (rev 379)
@@ -96,8 +96,8 @@
 
 	if( defined $config->{user} )
 	{
-		my $wuser = new Vhffs::User( $vhffs , $config->{user} , '401' );
-		if( $wuser->fetch )
+		my $wuser = Vhffs::User::get_by_username( $vhffs , $config->{user} );
+		if( defined $wuser )
 		{
 			$this->{wuser} = $wuser;
 		}
@@ -132,8 +132,8 @@
 {
 	my $self = shift;
 	my $config = $self->{main}->get_config->get_service( "mailuser");
-	my $user = new Vhffs::User( $self->{main} , $self->{part} , '401' );	
-	return 0 if( $user->fetch < 0 );
+	my $user = Vhffs::User::get_by_username( $self->{main} , $self->{part} );
+	return 0 unless( defined $user );
 	return 1 if( ( ! defined $config->{groupneeded} ) || ( $config->{groupneeded} ne "yes" ) || ( $user->have_activegroups > 0 ) );
 	return 0;
 }

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-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm	2006-12-18 06:45:18 UTC (rev 379)
@@ -156,7 +156,7 @@
     $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
     return -1 unless( defined $self->{'group'} );
     
-    $self->{'user'} = Vhffs::Group::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
+    $self->{'user'} = Vhffs::User::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
     return -1 unless( defined $self->{'user'} );
     
     

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2006-12-18 06:45:18 UTC (rev 379)
@@ -286,8 +286,7 @@
         $group->commit;
 
         $dbh->commit;
-        $user = new Vhffs::User($main, $username, $uid);
-        $user->fetch;
+        $user = get_by_uid($main, $uid);
     };
 
     if($@) {
@@ -874,10 +873,10 @@
 	
 	my $request = $vhffs->{'db'}->prepare( $query );
 	$request->execute(@params);
-	while( my $row = $request->fetchrow_arrayref )
+	while( my ($name) = $request->fetchrow_array )
 	{   
-	    my $user = new Vhffs::User( $vhffs , $row->[0]   , '401' );
-	    if( ( defined $user ) && ( $user->fetch > 0 ) )
+	    my $user = Vhffs::User::get_by_username( $vhffs , $name );
+	    if( defined $user )
 	    {   
 		push @users , $user;
 	    }
@@ -894,13 +893,13 @@
 
     return if ( !defined $vhffs );
 
-    my $query = 'SELECT username FROM vhffs_users ORDER BY uid DESC LIMIT 10';
+    my $query = 'SELECT uid FROM vhffs_users ORDER BY uid DESC LIMIT 10';
     my $request = $vhffs->{'db'}->prepare( $query );
 	$request->execute;
-    while( my $row = $request->fetchrow_arrayref )
+    while( my ($uid) = $request->fetchrow_array )
     {   
-        my $user = new Vhffs::User( $vhffs , $row->[0]   , '401' );
-        if( $user->fetch > 0 )
+        my $user = Vhffs::User::get_by_uid( $vhffs , $uid );
+        if( defined $user )
         {   
             push @users , $user;
         }

Modified: branches/vhffs_4.1/vhffs-jabber/vhffspipe.pl
===================================================================
--- branches/vhffs_4.1/vhffs-jabber/vhffspipe.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-jabber/vhffspipe.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -40,7 +40,7 @@
 	$vhffs = init Vhffs::Main if ( ! defined $vhffs );
 	return undef if ( ! defined $vhffs );
 
-	my $user = new Vhffs::User( $vhffs , $username , '401' );
+	my $user = Vhffs::User::get_by_username( $vhffs , $username );
 	return undef if( ! defined $user );
 
 	my $ret = $user->fetch;

Modified: branches/vhffs_4.1/vhffs-panel/acl/add_acl_user.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/acl/add_acl_user.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/acl/add_acl_user.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -74,8 +74,8 @@
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
-my $obj_src = new Vhffs::User( $vhffs , $username , '401' );
-my $obj_dst = new Vhffs::Object( $vhffs , $oid_dst , '401' );
+my $obj_src = Vhffs::User::get_by_username( $vhffs , $username );
+my $obj_dst = Vhffs::Object::get_by_id( $vhffs , $oid_dst );
 
 
 my $message;
@@ -88,10 +88,6 @@
 {
 	$message = gettext( "Object Error" );
 }
-elsif( ( $obj_src->fetch < 0 ) || ( $obj_dst->fetch  < 0) )
-{
-	$message = gettext( "The user does not exist" );
-}
 else
 {
 	if( ( Vhffs::Acl::what_perm_for_user( $user , $obj_dst , $vhffs ) < Vhffs::Constants::ACL_MANAGEACL ) && ( $user->is_admin != 1 ) )

Modified: branches/vhffs_4.1/vhffs-panel/acl/view.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/acl/view.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/acl/view.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -180,8 +180,7 @@
 
 		foreach( keys %{$user_rights} )
 		{
-			$u = new Vhffs::User( $vhffs , $user_rights->{$_}{'username'} , '401' );
-			$u->fetch;
+			$u = Vhffs::User::get_by_username( $vhffs , $user_rights->{$_}{'username'} );
 
 			$subtemplate = new HTML::Template( filename => $templatedir."/acl/view_each.tmpl" );
 			$subtemplate->param( NAME => $user_rights->{$_}{'username'} );

Modified: branches/vhffs_4.1/vhffs-panel/admin/moderation_submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/moderation_submit.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/admin/moderation_submit.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -82,24 +82,19 @@
 	use Vhffs::Object;
 	my $oid = $cgi->param("OID");
 	my $oidasker = $cgi->param("OID_ASKER");
-	my $object = new Vhffs::Object( $vhffs , $oid , '401' );
+	my $object = Vhffs::Object::get_by_id( $vhffs , $oid );
 
 	if( ( ! defined $oid ) || ( ! defined $object ) || ( ! defined $accept ) )
 	{
 		$template->param( MESSAGE  => gettext("CGI problem") );
 	}
-	elsif( $object->fetch < 0 )
-	{
-		$template->param( MESSAGE  => gettext("Cannot obtain information about this object") );
-	}
 	else
 	{
 		if( $accept == 1 )
 		{
 			$object->set_status( Vhffs::Constants::WAITING_FOR_CREATION );
-			my $username = Vhffs::User::get_name_by_uid( $vhffs , $object->get_owner_uid );
-			my $userbis = new Vhffs::User( $vhffs , $username , '401' );
-			if( $userbis->fetch > 0 )
+			my $userbis = Vhffs::User::get_by_uid( $vhffs , $object->get_owner_uid );
+			if( defined $userbis )
 			{
 			    my $mail;
 			    $mail  = gettext("Your request on VHFFS was accepted\n");
@@ -120,8 +115,7 @@
 		}
 		else
 		{
-			my $askerobject = new Vhffs::Object( $vhffs , $oidasker , '401' );
-			$askerobject->fetch;
+			my $askerobject = Vhffs::Object::get_by_id( $vhffs , $oidasker );
 		    $object->set_description( $reason );
 		    $object->set_status( Vhffs::Constants::VALIDATION_REFUSED );
 	        if( $vhffs->get_config->use_notation == 1 )

Modified: branches/vhffs_4.1/vhffs-panel/admin/user/edit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/user/edit.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/admin/user/edit.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -78,7 +78,7 @@
 	my $message = gettext( "CGI ERROR !");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::User( $vhffs , $username , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $object = Vhffs::User::get_by_username( $vhffs , $username ) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");

Modified: branches/vhffs_4.1/vhffs-panel/admin/user/edit_note.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/user/edit_note.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/admin/user/edit_note.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -80,7 +80,7 @@
     $message = gettext( "CGI ERROR !" );
     $template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::User( $vhffs , $username , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $object = Vhffs::User::get_by_username( $vhffs , $username) ) )
 {
     $message = gettext( "Cannot fetch object" );
     $template->param( MESSAGE => $message );

Modified: branches/vhffs_4.1/vhffs-panel/admin/user/edit_submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/user/edit_submit.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/admin/user/edit_submit.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -90,7 +90,7 @@
     $message = gettext( "CGI ERROR !" );
     $template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::User( $vhffs , $username , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $object = Vhffs::User::get_by_username( $vhffs , $username ) ) )
 {
     $message = gettext( "Cannot fetch object" );
     $template->param( MESSAGE => $message );

Modified: branches/vhffs_4.1/vhffs-panel/admin/user/show.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/user/show.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/admin/user/show.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -80,7 +80,7 @@
 	my $message = gettext( "CGI ERROR !");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::User( $vhffs , $username , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $object = Vhffs::User::get_by_username( $vhffs , $username ) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");

Modified: branches/vhffs_4.1/vhffs-panel/group/join_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/group/join_group.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/group/join_group.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -61,7 +61,7 @@
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $user2 = new Vhffs::User( $vhffs , $username , 401 );
+my $user2 = Vhffs::User::get_by_username( $vhffs , $username );
 my $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
 if( ! defined( $username )  )

Modified: branches/vhffs_4.1/vhffs-panel/group/remove_user_from_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/group/remove_user_from_group.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/group/remove_user_from_group.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -59,7 +59,7 @@
 my $message;
 
 my $username = $cgi->param("USERNAME");
-my $user2 = new Vhffs::User( $vhffs , $username , 401 );
+my $user2 = Vhffs::User::get_by_username( $vhffs , $username );
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 

Modified: branches/vhffs_4.1/vhffs-panel/login.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/login.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/login.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -62,7 +62,7 @@
 my $current_cgi = new CGI;
 my $username = $current_cgi->param("username");
 my $password = $current_cgi->param("password");
-my $user = new Vhffs::User( $vhffs, $username, 401 );
+my $user = Vhffs::User::get_by_username( $vhffs, $username );
 
 my $auth = 0;
 
@@ -92,13 +92,8 @@
 }
 else
 {
+	$auth=1 if ( $user->check_password( $password ) && ( $user->get_status == Vhffs::Constants::ACTIVATED ) );
 
-
-	my $ret = $user->fetch;
-	if ( $ret >= 0 )  {
-		$auth=1 if ( $user->check_password( $password ) && ( $user->get_status == Vhffs::Constants::ACTIVATED ) )
-	}
-
 	if( $auth == 1 )
 	{
 		my $session = new CGI::Session("driver:File", undef, {Directory=>'/tmp'});

Modified: branches/vhffs_4.1/vhffs-panel/lost_ack.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/lost_ack.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/lost_ack.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -52,9 +52,9 @@
 # recuperation des donnees des champs du form de login
 my $cgi = new CGI;
 my $username = $cgi->param("username");
-my $user = new Vhffs::User( $vhffs, $username, 401 );
+my $user = Vhffs::User::get_by_username( $vhffs, $username );
 my $template;
-if ( ( defined $user) && ( $user->fetch > 0 ) )  
+if ( defined $user)  
 {
     #create a new password for this user
     my $plainpassword = $user->generate_password;

Modified: branches/vhffs_4.1/vhffs-panel/panel.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/panel.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/panel.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -68,8 +68,8 @@
 {
 	if( $user->is_admin == 1 )
 	{
-		my $user_bis = new Vhffs::User( $vhffs , $su_user , '401' );
-		if( defined( $user_bis ) && ( $user_bis->fetch > 0 ) )
+		my $user_bis = Vhffs::User::get_by_username( $vhffs , $su_user );
+		if( defined( $user_bis ) ) 
 		{
 			$user = undef;
 			$user = $user_bis;

Modified: branches/vhffs_4.1/vhffs-panel/public/user.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/public/user.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-panel/public/user.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -57,18 +57,14 @@
 $name = Vhffs::Functions::check_arg( $name );
 
 my $user;
-$user= new Vhffs::User( $vhffs , $name , '401' );
 
-
-
-
 if( ! defined $name )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "CGI ERROR!");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ($user= new Vhffs::User( $vhffs , $name , '401' ) ) ) || ( $user->fetch < 0 ))
+elsif( ! defined ($user= Vhffs::User::get_by_username( $vhffs , $name ) ) )
 {
 
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );

Modified: branches/vhffs_4.1/vhffs-tests/src/Group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Group.pl	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-tests/src/Group.pl	2006-12-18 06:45:18 UTC (rev 379)
@@ -44,7 +44,7 @@
 ok($group1->is_user_in_group($user2), 'Second user addition visible in group1');
 ok($group1->remove_user($user2), 'Second user removed from group1');
 
-my $group3 = Vhffs::Group::create($main, 'fashion1', undef);
+my $group3 = Vhffs::Group::create($main, 'fashion1', $user1->get_uid);
 isa_ok($group3, 'Vhffs::Group', '$group3');
 cmp_ok($group3->get_gid, '>', 0, 'New way of creating groups produces correct GID');
 cmp_ok($group3->get_groupname, 'eq', 'fashion1', 'New way of creating group keep groupname');

Modified: branches/vhffs_4.1/vhffs-tools/src/vhffs-makeadmin
===================================================================
--- branches/vhffs_4.1/vhffs-tools/src/vhffs-makeadmin	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-tools/src/vhffs-makeadmin	2006-12-18 06:45:18 UTC (rev 379)
@@ -6,13 +6,13 @@
 
 if( scalar @ARGV != 1 )
 {
-	print "Usage: vhffs-firstadmin username password\n";
+	print "Usage: vhffs-makeadmin username\n";
 	exit( 1 );
 }
 
 my $vhffs = init Vhffs::Main;
-my $user = new Vhffs::User($vhffs, $ARGV[0], 401);
-if ( $user->fetch < 0 ) {
+my $user = Vhffs::User::get_by_username($vhffs, $ARGV[0]);
+if ( !defined $user ) {
     die "User >$ARGV[0]< does not exists !\n";
 }
 

Modified: branches/vhffs_4.1/vhffs-tools/src/vhffs-passwd
===================================================================
--- branches/vhffs_4.1/vhffs-tools/src/vhffs-passwd	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-tools/src/vhffs-passwd	2006-12-18 06:45:18 UTC (rev 379)
@@ -10,10 +10,10 @@
 }
 
 my $vhffs = init Vhffs::Main;
-my $user = new Vhffs::User( $vhffs , $ARGV[0] , '401' );
+my $user = Vhffs::User::get_by_username( $vhffs , $ARGV[0] );
 
 
-if( ( defined $user ) && ( $user->fetch == 1 ) )
+if( defined $user )
 {
 	$user->set_password( $ARGV[1] );
 	

Modified: branches/vhffs_4.1/vhffs-tools/src/vhffs-userdel
===================================================================
--- branches/vhffs_4.1/vhffs-tools/src/vhffs-userdel	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-tools/src/vhffs-userdel	2006-12-18 06:45:18 UTC (rev 379)
@@ -11,10 +11,10 @@
 }
 
 my $vhffs = init Vhffs::Main;
-my $user = new Vhffs::User( $vhffs , $ARGV[0] , '401' );
+my $user = Vhffs::User::get_by_username( $vhffs , $ARGV[0] );
 
 
-if( ( defined $user ) && ( $user->fetch == 1 ) )
+if( defined $user )
 {
 	$user->set_status( Vhffs::Constants::TO_DELETE );
 	

Modified: branches/vhffs_4.1/vhffs-tools/src/vhffs-usermod
===================================================================
--- branches/vhffs_4.1/vhffs-tools/src/vhffs-usermod	2006-12-17 01:57:40 UTC (rev 378)
+++ branches/vhffs_4.1/vhffs-tools/src/vhffs-usermod	2006-12-18 06:45:18 UTC (rev 379)
@@ -13,11 +13,11 @@
 }
 
 my $vhffs 	= init Vhffs::Main;
-my $user 	= new Vhffs::User( $vhffs , $ARGV[0] , '401' );
+my $user 	= Vhffs::User::get_by_username( $vhffs , $ARGV[0] );
 my $mod		= $ARGV[1];
 my $value	= $ARGV[2];
 
-if( ( defined $user ) && ( $user->fetch == 1 ) )
+if( defined $user )
 {
 	if( $mod =~ /shell|firstname|lastname|city|admin/ )
 	{


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