[vhffs-dev] [465] Merged vhffs_user_info, vhffs_notes, vhffs_panel_user_prefs into vhffs_users, vhffs_groups_info into vhffs_groups.

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


Revision: 465
Author:   beuss
Date:     2007-02-16 23:09:28 +0000 (Fri, 16 Feb 2007)

Log Message:
-----------
Merged vhffs_user_info, vhffs_notes, vhffs_panel_user_prefs into vhffs_users, vhffs_groups_info into vhffs_groups. Fixed a typo in (commented) statement in 4.0.sql.
Tests on Object and User are OK. too late to fix others, will do it tomorrow.

Modified Paths:
--------------
    branches/vhffs_4.1/Makefile
    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/User.pm
    branches/vhffs_4.1/vhffs-tests/src/Object.pl
    branches/vhffs_4.1/vhffs-tests/src/User.pl


Modified: branches/vhffs_4.1/Makefile
===================================================================
--- branches/vhffs_4.1/Makefile	2007-02-16 22:44:42 UTC (rev 464)
+++ branches/vhffs_4.1/Makefile	2007-02-16 23:09:28 UTC (rev 465)
@@ -303,6 +303,8 @@
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Cvs.pl");'
 test-web:
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Httpd.pl");'
+test-mail:
+	@perl -I vhffs-tests/src/ -I vhffs-api/src/ vhffs-tests/src/Services/Mail.pl
 test-functions:
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Functions.pl");'
 

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2007-02-16 22:44:42 UTC (rev 464)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm	2007-02-16 23:09:28 UTC (rev 465)
@@ -172,21 +172,7 @@
     {
 	$self->{$_} = $hash->{$_};
     }
-    
-    
-    $request2 = 'SELECT * FROM vhffs_groups_info where gid=?';
-    
-    
-    $result2 = $self->{'db'}->prepare($request2) or return -1;    
-    $result2->execute($self->{'gid'}) or return -1;
-    $hash = $result2->fetchrow_hashref();
 
-    foreach ( keys %{$hash} )
-    {
-	    $self->{$_} = $hash->{$_};
-    }
-
-
 	return -2 if( $self->SUPER::fetch < 0 );
 
     return 1;
@@ -243,14 +229,10 @@
     # to avoid updates (cf Vhffs::User::create)
     ($gid) = $dbh->selectrow_array('SELECT nextval(\'vhffs_groups_gid_seq\')') unless defined $gid;
     
-    my $query = 'INSERT INTO vhffs_groups(gid, groupname, passwd, quota, quota_used, object_id) VALUES(?, ?, NULL, ?, 0, ?)';
+    my $query = 'INSERT INTO vhffs_groups(gid, groupname, passwd, quota, quota_used, owner_uid, uid_mod, object_id) VALUES(?, ?, NULL, ?, 0, ?, ?, ?)';
     my $sth = $dbh->prepare( $query ) or return undef;
-    $sth->execute($gid, $groupname, $quota, $parent->get_oid) or return undef;
+    $sth->execute($gid, $groupname, $quota, $owner_uid, $owner_uid, $parent->get_oid) or return undef;
 
-    $query = 'INSERT INTO vhffs_groups_info(gid, owner_uid, uid_mod) VALUES( ?, ?, ?)';
-    $sth = $dbh->prepare( $query ) or return undef;
-    $sth->execute($gid, $owner_uid, $owner_uid);
-    
     return get_by_gid($main, $gid);
 }
 
@@ -310,16 +292,11 @@
 
 	
     #finally, create the group
-	$query = 'INSERT INTO vhffs_groups(groupname, passwd, quota, quota_used, object_id) VALUES(?, NULL, ?, ?, ?)';
+	$query = 'INSERT INTO vhffs_groups(groupname, passwd, quota, quota_used, owner_uid, uid_mod, object_id) VALUES(?, NULL, ?, ?, ?, ?, ?)';
     $request = $self->{'db'}->prepare( $query ) or return -2;
-    $request->execute($self->{'groupname'}, $self->{'quota'}, $self->{'quota_used'}, $oid) or return -3;
+    $request->execute($self->{'groupname'}, $self->{'quota'}, $self->{'quota_used'}, $self->{'owner_uid'}, $self->{'owner_uid'}, $oid) or return -3;
     $self->{'gid'} = $self->{'db'}->last_insert_id(undef, undef, 'vhffs_groups', undef);
 
-
-	$query = 'INSERT INTO vhffs_groups_info(gid, owner_uid, uid_mod) VALUES( ?, ?, ?)';
-    $request = $self->{'db'}->prepare($query) or return -2;
-    $request->execute($self->{'gid'}, $self->{'owner_uid'}, $self->{'owner_uid'}) or return -3;
-
     $self->commit;
 
     $self->fetch;
@@ -359,17 +336,10 @@
 #    $self->{'quota'} = $self->{'main'}->get_config->get_users->{'default_quota'} if ( ! defined $self->{'quota'} );
  #   $self->{'quota_used'} = $self->{'quota'} if ( ! defined $self->{'quota_used'} );
    
-    my $request_unix = 'UPDATE vhffs_groups SET quota=?, quota_used=? WHERE gid=?';
+    my $sql = 'UPDATE vhffs_groups SET quota = ?, quota_used = ?, owner_uid = ?, uid_mod = ? WHERE gid = ?';
+    my $sth = $self->{db}->prepare($sql);
+    $sth->execute( $self->{'quota'}, $self->{'quota_used'}, $self->{'owner_uid'}, $self->{'uid_mod'}, $self->{'gid'}) or return -1;
 
-    $self->{'uid_mod'} = $self->{'owner_uid'} if ( !defined $self->{'uid_mod'} );
-
-    my $request_info = 'UPDATE vhffs_groups_info SET owner_uid=?, uid_mod=? WHERE gid=?';
-    my $result_unix = $self->{'db'}->prepare($request_unix);
-    my $result_info = $self->{'db'}->prepare($request_info);
-
-    $result_unix->execute( $self->{'quota'}, $self->{'quota_used'}, $self->{'gid'} ) or return -1;
-    $result_info->execute( $self->{'owner_uid'}, $self->{'uid_mod'}, $self->{'gid'} ) or return -1;
-
     #Exec the super method !
     return -2 if( $self->SUPER::commit < 0 );
 
@@ -807,7 +777,7 @@
 
 sub get_by_gid {
     my ($vhffs, $gid) = @_;
-    my $query = 'SELECT g.gid, o.object_id, o.owner_uid, gi.uid_mod, g.groupname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_groups_info gi ON g.gid = gi.gid INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.gid = ?';
+    my $query = 'SELECT g.gid, o.object_id, o.owner_uid, g.uid_mod, g.groupname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.gid = ?';
     
     my $dbh = $vhffs->get_db_object;
     my @params = $dbh->selectrow_array($query, undef, $gid);
@@ -818,7 +788,7 @@
 
 sub get_by_groupname {
     my ($vhffs, $groupname) = @_;
-    my $query = 'SELECT g.gid, o.object_id, o.owner_uid, gi.uid_mod, g.groupname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_groups_info gi ON g.gid = gi.gid INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.groupname = ?';
+    my $query = 'SELECT g.gid, o.object_id, o.owner_uid, g.uid_mod, g.groupname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.groupname = ?';
 
     my $dbh = $vhffs->get_db_object;
     my @params = $dbh->selectrow_array($query, undef, $groupname);

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm	2007-02-16 22:44:42 UTC (rev 464)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm	2007-02-16 23:09:28 UTC (rev 465)
@@ -99,7 +99,7 @@
 }
 
 sub _new {
-    my ($class, $main, $oid, $owner_uid, $date_creation, $description, $state) = @_;
+    my ($class, $main, $oid, $owner_uid, $date_creation, $description, $state, $type) = @_;
     
     $self = {};
 
@@ -114,6 +114,7 @@
     $self->{date_creation} = $date_creation;
     $self->{description} = $description;
     $self->{state} = $state;
+    $self->{type} = $type;
     
     return $self;
 }
@@ -172,11 +173,11 @@
 
 sub create {
     return old_create(@_) if($_[0]->isa('Vhffs::Object'));
-    my ($vhffs, $owner_uid, $description, $state) = @_;
+    my ($vhffs, $owner_uid, $description, $state, $type) = @_;
     $description = '' unless (defined $description);
     $state = ($vhffs->get_config->get_moderation ? Vhffs::Constants::WAITING_FOR_VALIDATION : Vhffs::Constants::WAITING_FOR_CREATION) unless defined $state;
-    my $sth = $vhffs->get_db_object->prepare('INSERT INTO vhffs_object(owner_uid, date_creation, state, description) VALUES ( ?, NOW(), ?, ?)');
-    $sth->execute($owner_uid, $state, $description) or return undef;
+    my $sth = $vhffs->get_db_object->prepare('INSERT INTO vhffs_object(owner_uid, date_creation, state, description, type) VALUES ( ?, NOW(), ?, ?, ?)');
+    $sth->execute($owner_uid, $state, $description, $type) or return undef;
     my $oid = $vhffs->get_db_object->last_insert_id(undef, undef, 'vhffs_object', undef);
 
     my $res = get_by_oid($vhffs, $oid);
@@ -257,6 +258,11 @@
 	return $self->{'owner_uid'};
 }
 
+sub get_type
+{
+    my $self = shift;
+    return $self->{type};
+}
 
 #The modify method for Vhffs::Object only tells if the API can modify some values
 #It protects some importants fields such as object_id
@@ -442,20 +448,25 @@
 	if( defined $name )
 	{
         $name = '%'.$name.'%';
-        $query = 'SELECT o.object_id, o.owner_uid, o.date_creation , o.state , o.description FROM vhffs_object o INNER JOIN vhffs_users u ON o.owner_uid = u.uid WHERE ( o.description LIKE ? ) OR ( o.object_id LIKE ? ) OR ( o.owner_uid LIKE ? ) OR ( state LIKE ? ) OR ( u.username LIKE ? )';
+        $query = 'SELECT o.object_id, o.owner_uid, o.date_creation , o.state , o.description, o.type FROM vhffs_object o INNER JOIN vhffs_users u ON o.owner_uid = u.uid WHERE ( o.description LIKE ? ) OR ( o.object_id LIKE ? ) OR ( o.owner_uid LIKE ? ) OR ( state LIKE ? ) OR ( u.username LIKE ? )';
         $request = $vhffs->get_db_object->prepare( $query ) or return -1;
 
         return undef if ( !$request->execute( $name, $name, $name, $name, $name ));
 	}
 	else
 	{
-		$query = 'SELECT o.object_id, o.owner_uid, o.date_creation , o.state , o.description FROM vhffs_object o';
+		$query = 'SELECT o.object_id, o.owner_uid, o.date_creation , o.state , o.description, o.type FROM vhffs_object o';
 		$request = $vhffs->get_db_object->prepare( $query ) or return -1;
 
     	return undef if ( !$request->execute() );
     }
 	
-	return( $request->fetchall_hashref('object_id') );
+    my $result;
+    my $rows = $request->fetchall_arrayref();
+    foreach(@$rows) {
+        push(@$result, _new Vhffs::Object($vhffs, @$_));
+    }
+    return $result;
 }
 
 sub get_group
@@ -500,15 +511,15 @@
 sub get_by_oid
 {
     my ($vhffs, $oid) = @_;
-    my $query = 'SELECT owner_uid, date_creation, state, description FROM vhffs_object WHERE object_id =?';
+    my $query = 'SELECT owner_uid, date_creation, description, state, type FROM vhffs_object WHERE object_id =?';
     my $sth = $vhffs->get_db_object->prepare( $query );
     my $rows = $sth->execute( $oid );
 
     return undef unless $rows == 1;
 
-    my $result = $sth->fetchrow_hashref();
+    my @result = $sth->fetchrow_array();
 
-    my $object = _new Vhffs::Object($vhffs, $oid, $result->{owner_uid}, $result->{date_creation}, $result->{description}, $result->{state});
+    my $object = _new Vhffs::Object($vhffs, $oid, @result);
 
     return $object;
 }

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2007-02-16 22:44:42 UTC (rev 464)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2007-02-16 23:09:28 UTC (rev 465)
@@ -170,7 +170,7 @@
 
     return $ret if( ( $ret = $self->fetch_unix() ) < 0 );
 
-    $request = $self->{'db'}->prepare('SELECT * FROM vhffs_user_info where uid=?') or return -2;
+    $request = $self->{'db'}->prepare('SELECT * FROM vhffs_users where uid=?') or return -2;
     
     $request->execute($self->{'uid'}) or return -2;
 
@@ -184,11 +184,6 @@
 
     $self->{'group'}->fetch;
 
-	my $v;
-	foreach $v qw(firstname lastname address zipcode city country)
-	{
-		$self->{$v} =~ s/[\\]//g if( defined $self->{$v} );	
-	}
 
 	$self->SUPER::fetch;
     return 1;    
@@ -265,10 +260,6 @@
         # Insert base information
         $admin = 0 unless (defined $admin);
         my $homedir = Vhffs::Functions::hash_homename( $username  , $main );
-        my $sth = $dbh->prepare('INSERT INTO vhffs_users (uid, gid, username, shell, passwd, homedir, admin, object_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?)');
-        $sth->execute($uid, $gid, $username, $userconf->{'shell'}, Vhffs::Functions::password_encrypt($password), $homedir, $admin, $parent->get_oid);
-        
-        # User infos
         $firstname = $userconf->{'default_firstname'} unless ( defined $firstname );
         $lastname = $userconf->{'default_lastname'} unless ( defined $lastname );
         $address = $userconf->{'default_address'} unless ( defined $address );
@@ -277,9 +268,10 @@
         $mail = $userconf->{'default_mail'} unless ( defined $mail );
         $gpg_key = " " unless ( defined $gpg_key && $gpg_key ne "" );
         $country = $userconf->{'default_country'} unless ( defined $country );
-        $sth = $dbh->prepare('INSERT INTO vhffs_user_info (uid, date_creation, firstname, lastname, address, zipcode, city, country, mail, gpg_key) VALUES(?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?)');
-        $sth->execute($uid, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key);
 
+        my $sth = $dbh->prepare('INSERT INTO vhffs_users (uid, gid, username, shell, passwd, homedir, admin, firstname, lastname, address, zipcode, city, country, mail, gpg_key, note, language, theme, object_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?)');
+        $sth->execute($uid, $gid, $username, $userconf->{'shell'}, Vhffs::Functions::password_encrypt($password), $homedir, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, Vhffs::Constants::DEFAULT_LANG, Vhffs::Constants::DEFAULT_THEME, $parent->get_oid);
+        
         my $group = Vhffs::Group::create($main, $username, $uid, $gid);
         die('Error creating group') unless (defined $group);
         $group->set_status(Vhffs::Constants::ACTIVATED);
@@ -410,21 +402,15 @@
     return -2 if( $field eq "username" );
 
 
-    # if the field is username, shell, passwd or homedir, we will modify the vhffs_users table
-    # if not, we modify vhffs_user_info table
     if ( $field eq "passwd" )
     {    	
         $request = $self->{'db'}->prepare("UPDATE vhffs_users SET passwd='" + Vhffs::Main::password_encrypt $value + "' WHERE uid='$self->{'uid'}'") or return -3;
 	
     }
-    elsif( $field =~ /shell|status|homedir/ )
+    else
     {
         $request = $self->{'db'}->prepare("UPDATE vhffs_users SET $field='$value' WHERE uid='$self->{'uid'}'") or return -3;
     }
-    else
-    {
-        $request = $self->{'db'}->prepare("UPDATE vhffs_user_info SET $field='$value' WHERE uid='$self->{'uid'}'") or return -3;
-    }
     
     $request->execute() or return -4;
 }
@@ -452,16 +438,12 @@
     
     return -1 if( $self->SUPER::commit < 0 );
     
-    # Update unix related stuff
-    my $result_unix = $self->{'db'}->prepare('UPDATE vhffs_users SET shell=?, passwd=?, admin=? WHERE uid=?') or return -1;
-    $result_unix->execute($self->{'shell'}, $self->{'passwd'}, $self->{'admin'}, $self->{'uid'}) or return -4;
-
-    # Update user infos
-    my $result_info = $self->{'db'}->prepare('UPDATE vhffs_user_info SET firstname=?, lastname=?, address=?, '.
-	'zipcode=?, country=?, mail=?, city=?, gpg_key=? WHERE uid=?') or return -2;
-    $result_info->execute($self->{'firstname'}, $self->{'lastname'}, $self->{'address'}, $self->{'zipcode'},
+    my $sql = 'UPDATE vhffs_users SET shell = ?, passwd = ?, admin = ?, firstname = ?, lastname = ?, address = ?, zipcode = ?, country = ?, mail = ?, city = ?, gpg_key = ? WHERE uid = ?';
+    my $sth = $self->{db}->prepare($sql) or return -1;
+    $sth->execute($self->{'shell'}, $self->{'passwd'}, $self->{'admin'}, 
+        $self->{'firstname'}, $self->{'lastname'}, $self->{'address'}, $self->{'zipcode'},
         $self->{'country'}, $self->{'mail'}, $self->{'city'}, $self->{'gpg_key'}, $self->{'uid'}) or return -3;
-    
+
     return 1;
 }
 
@@ -877,10 +859,10 @@
 	return if( ! defined $vhffs );
 
 	my $query;
-	$query = 'SELECT username FROM vhffs_users vu , vhffs_user_info vi, vhffs_object o  WHERE vu.uid=vi.uid AND o.object_id=vu.object_id ';
+	$query = 'SELECT username FROM vhffs_users vu INNER JOIN vhffs_object o ON o.object_id = vu.object_id WHERE o.object_id=vu.object_id ';
     if(defined $name) {
         $name = "\%$name\%";
-        $query.= ' AND ( vu.username LIKE ? OR vi.firstname LIKE ? OR vi.lastname LIKE ? )';
+        $query.= ' AND ( vu.username LIKE ? OR vu.firstname LIKE ? OR vu.lastname LIKE ? )';
         push @params, $name, $name, $name;
     }
 	(push(@params, $state), $query.= ' AND o.state=?') if( defined $state );
@@ -962,7 +944,7 @@
 
 sub get_by_uid {
     my ($main, $uid) = @_;
-    my $query = 'SELECT u.uid, u.gid, u.object_id, u.username, u.passwd, u.homedir, u.shell, u.admin, ui.firstname, ui.lastname, ui.address, ui.zipcode, ui.city, ui.country, ui.mail, ui.gpg_key, o.date_creation, o.description, o.state FROM vhffs_users u INNER JOIN vhffs_user_info ui ON u.uid = ui.uid INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE u.uid = ?';
+    my $query = 'SELECT u.uid, u.gid, u.object_id, u.username, u.passwd, u.homedir, u.shell, u.admin, u.firstname, u.lastname, u.address, u.zipcode, u.city, u.country, u.mail, u.gpg_key, o.date_creation, o.description, o.state FROM vhffs_users u INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE u.uid = ?';
     my $dbh = $main->get_db_object;
     my @params = $dbh->selectrow_array($query, undef, $uid);
     return undef unless(@params);
@@ -973,7 +955,7 @@
 
 sub get_by_username {
     my ($main, $username) = @_;
-    my $query = 'SELECT u.uid, u.gid, u.object_id, u.username, u.passwd, u.homedir, u.shell, u.admin, ui.firstname, ui.lastname, ui.address, ui.zipcode, ui.city, ui.country, ui.mail, ui.gpg_key, o.date_creation, o.description, o.state FROM vhffs_users u INNER JOIN vhffs_user_info ui ON u.uid = ui.uid INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE u.username = ?';
+    my $query = 'SELECT u.uid, u.gid, u.object_id, u.username, u.passwd, u.homedir, u.shell, u.admin, u.firstname, u.lastname, u.address, u.zipcode, u.city, u.country, u.mail, u.gpg_key, o.date_creation, o.description, o.state FROM vhffs_users u INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE u.username = ?';
     my $dbh = $main->get_db_object;
     my @params = $dbh->selectrow_array($query, undef, $username);
     return undef unless(@params);

Modified: branches/vhffs_4.1/vhffs-tests/src/Object.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Object.pl	2007-02-16 22:44:42 UTC (rev 464)
+++ branches/vhffs_4.1/vhffs-tests/src/Object.pl	2007-02-16 23:09:28 UTC (rev 465)
@@ -8,11 +8,9 @@
 my $main = init Vhffs::Tests::Main;
 Vhffs::Tests::Utils::init_db($main->get_db_object);
 
-my $owner1 = new Vhffs::User($main, 'test1', 401);
+my $owner1 = Vhffs::User::create($main, 'test1', '123');
 isa_ok($owner1, 'Vhffs::User', 'user1');
-ok(!$owner1->exists, 'First user doesn\'t exists');
-$owner1->set_password('abcdef');
-my $uid1 = $owner1->create;
+my $uid1 = $owner1->get_uid;
 cmp_ok($uid1, '>', 0, 'First user creation');
 ok($owner1->exists, 'First user exists');
 

Modified: branches/vhffs_4.1/vhffs-tests/src/User.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/User.pl	2007-02-16 22:44:42 UTC (rev 464)
+++ branches/vhffs_4.1/vhffs-tests/src/User.pl	2007-02-16 23:09:28 UTC (rev 465)
@@ -9,12 +9,6 @@
 
 Vhffs::Tests::Utils::init_db($main->get_db_object);
 
-#my $user1 = new Vhffs::User($main, 'test1', 401);
-#isa_ok($user1, 'Vhffs::User', 'user1');
-#ok(!$user1->exists, 'First user doesn\'t exists');
-#$user1->set_password('abcdef');
-#my $uid1 = $user1->create;
-#cmp_ok($uid1, '>', 0, 'First user creation');
 my $user1 = Vhffs::User::create($main, 'test1', 'abcdef', 0, 'test1@xxxxxxxx');
 isa_ok($user1, 'Vhffs::User', '$user1');
 
@@ -22,8 +16,8 @@
 ok($user1->exists, 'First user exists');
 ok(Vhffs::User::uid_exists($main->get_db_object, $uid1), 'First user UID exists');
 
-my $user2 = new Vhffs::User($main, 'test2', 401);
-cmp_ok($user2->create, '>', 0, 'Second user creation');
+my $user2 = Vhffs::User::create($main, 'test2', 'abcdef', 0, 'test2@xxxxxxxx');
+isa_ok($user2, 'Vhffs::User', '$user2');
 
 $user2 = new Vhffs::User($main, 'test1', 401);
 cmp_ok($user2->exists, '>', 0, 'User test1 exists');
@@ -32,8 +26,7 @@
 $main->get_db_object->{PrintError} = 1;
 cmp_ok($uid2, '<=', 0, 'User test1 can\'t be created twice');
 
-my $user3 = new Vhffs::User($main, 'test1', 401);
-cmp_ok($user3->fetch, '>', 0, 'User can be fetched');
+my $user3 = Vhffs::User::get_by_uid($main, $uid1);
 cmp_ok($user3->get_uid, '==', $uid1, 'Fetched UID matches');
 
 is_deeply($user3, $user1, 'Fetched user is a copy of original');
@@ -49,19 +42,16 @@
 
 cmp_ok($user1->get_gid, '>', 0, 'User\'s group is valid');
 
-my $group1 = new Vhffs::Group($main, '', 401, $user1->get_gid);
+my $group1 = Vhffs::Group::get_by_gid($main, $user1->get_gid);
 isa_ok($group1, 'Vhffs::Group', 'User\'s personal group');
-cmp_ok($group1->fetch, '>', 0, 'User\'s personnal group can be fetched');
 cmp_ok($user1->get_gid, '==', $group1->get_gid, 'User\'s personnal group GID matched fetched GID');
 cmp_ok($group1->get_groupname, 'eq', $user1->get_username, 'User\'s personnal group groupname matches username');
 
-my $group2 = new Vhffs::Group($main, 'test1group1', $user1->get_uid);
+my $group2 = Vhffs::Group::create($main, 'test1group1', $user1->get_uid, undef, 'Independant group');
 isa_ok($group2, 'Vhffs::Group', 'Independant group');
-cmp_ok($group2->create, '>', 0, 'Independant group creation');
 
-my $group3 = new Vhffs::Group($main, 'test1group1', 401);
+my $group3 = Vhffs::Group::get_by_groupname($main, 'test1group1');
 isa_ok($group3, 'Vhffs::Group', 'Group for fetching');
-cmp_ok($group3->fetch, '>', 0, 'Independant group can be fetched');
 cmp_ok($group3->get_owner_uid, '==', $user1->get_uid, 'Independant group owner matches');
 
 # An user can't have the name if a group, AND it should


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