[vhffs-dev] [714] Begin database improvements

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


Revision: 714
Author:   gradator
Date:     2007-07-12 10:20:23 +0000 (Thu, 12 Jul 2007)

Log Message:
-----------
Begin database improvements

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Functions.pm
    trunk/vhffs-api/src/Vhffs/Group.pm
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-api/src/Vhffs/Robots/User.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-backend/src/pgsql/initdb.sql.in
    trunk/vhffs-compat/4.0.sql.in
    trunk/vhffs-robots/src/create_homes.pl


Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm	2007-07-12 10:20:23 UTC (rev 714)
@@ -148,7 +148,9 @@
 		$path .= "/".$value if( $value ne '' );
 		mkdir( $path ) if( ! -d $path );
 	}
-	return 1;
+
+	return -1 unless -d $dir;
+	return 0;
 }
 
 

Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2007-07-12 10:20:23 UTC (rev 714)
@@ -100,17 +100,18 @@
     }
 
     eval {
-        my $parent = Vhffs::Object::create($main, $owner_uid, $description, undef, Vhffs::Constants::TYPE_GROUP);
+        # Special case : sometimes, gid can't be passed to create
+        # to avoid updates (cf Vhffs::User::create)
+        ($gid) = $dbh->selectrow_array('SELECT nextval(\'vhffs_groups_gid_seq\')') unless defined $gid;
+
+        my $parent = Vhffs::Object::create($main, $owner_uid, $gid, $description, undef, Vhffs::Constants::TYPE_GROUP);
         die('Unable to create parent object') unless(defined $parent);
     
         my $quota = $groupconf->{default_quota} || 10;
-        # Special case : sometimes, gid can be passed to create
-        # 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, owner_uid, uid_mod, object_id) VALUES(?, ?, NULL, ?, 0, ?, ?, ?)';
+        my $query = 'INSERT INTO vhffs_groups(gid, groupname, passwd, quota, quota_used, object_id) VALUES(?, ?, NULL, ?, 0, ?)';
         my $sth = $dbh->prepare( $query );
-        $sth->execute($gid, $groupname, $quota, $owner_uid, $owner_uid, $parent->get_oid);
+        $sth->execute($gid, $groupname, $quota, $parent->get_oid);
 
         $dbh->commit if($transaction_started);
         $group = get_by_gid($main, $gid);
@@ -152,9 +153,9 @@
 {
     my $self = shift;
 
-    my $sql = 'UPDATE vhffs_groups SET quota = ?, quota_used = ?, owner_uid = ?, uid_mod = ? WHERE gid = ?';
+    my $sql = 'UPDATE vhffs_groups SET quota = ?, quota_used = ? 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;
+    $sth->execute( $self->{'quota'}, $self->{'quota_used'}, $self->{'gid'}) or return -1;
 
     #Exec the super method !
     return -2 if( $self->SUPER::commit < 0 );
@@ -618,7 +619,7 @@
 
 sub get_by_gid {
     my ($vhffs, $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 $query = 'SELECT g.gid, o.object_id, o.owner_uid, 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);
@@ -640,7 +641,7 @@
 
 sub get_by_groupname {
     my ($vhffs, $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 $query = 'SELECT g.gid, o.object_id, o.owner_uid, 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);
@@ -652,10 +653,10 @@
 
 sub _new {
     no strict 'refs';
-    my ($class, $main, $gid, $oid, $owner_uid, $uid_mod, $groupname, $passwd, $quota, $quota_used, $date_creation, $description, $state) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $date_creation, $description, $state, Vhffs::Constants::TYPE_GROUP);
+    my ($class, $main, $gid, $oid, $owner_uid, $groupname, $passwd, $quota, $quota_used, $date_creation, $description, $state) = @_;
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_GROUP);
     return undef unless(defined $self);
-    foreach (qw (gid uid_mod groupname passwd quota quota_used) ) {
+    foreach (qw (gid groupname passwd quota quota_used) ) {
         eval '$self->{$_} = $'.$_;
     }
     return $self;

Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2007-07-12 10:20:23 UTC (rev 714)
@@ -64,7 +64,7 @@
     my $class;
     
     
-    ( $this , $main , $id , $owner ) = @_;
+    ( $this , $main , $id , $owner_uid , $owner_gid ) = @_;
     
     $self={};
 
@@ -75,7 +75,8 @@
     
     $self->{'main'} = $main;
     $self->{'db'} = $main->get_db_object;
-    $self->{'owner_uid'} = $owner;
+    $self->{'owner_uid'} = $owner_uid;
+    $self->{'owner_gid'} = $owner_gid;
     $self->{'description'} = "";
     
     
@@ -92,7 +93,7 @@
 }
 
 sub _new {
-    my ($class, $main, $oid, $owner_uid, $date_creation, $description, $state, $type) = @_;
+    my ($class, $main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, $type) = @_;
     
     $self = {};
 
@@ -104,6 +105,7 @@
     $self->{db} = $main->get_db_object;
     $self->{object_id} = $oid;
     $self->{owner_uid} = $owner_uid;
+    $self->{owner_gid} = $owner_gid;
     $self->{date_creation} = $date_creation;
     $self->{description} = $description;
     $self->{state} = $state;
@@ -115,15 +117,7 @@
 sub get_main
 {
     my $self = shift;
-    
-    if( defined $self->{'main'} )
-    {
-	return $self->{'main'};
-    }
-    else
-    {
-	return undef;
-    }
+    return $self->{'main'};
 }
 
 sub get_db_object {
@@ -160,7 +154,7 @@
 
 =head2 create
 
-    my $object = Vhffs::Object::create($main, [$owner_uid, $description, $state, $type])
+    my $object = Vhffs::Object::create($main, [$owner_uid, $owner_gid, $description, $state, $type])
 
 Create (in database) and return a new object.
 
@@ -183,11 +177,11 @@
 =cut
 
 sub create {
-   my ($vhffs, $owner_uid, $description, $state, $type) = @_;
+   my ($vhffs, $owner_uid, $owner_gid, $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, type) VALUES ( ?, NOW(), ?, ?, ?)');
-    $sth->execute($owner_uid, $state, $description, $type) or return undef;
+    my $sth = $vhffs->get_db_object->prepare('INSERT INTO vhffs_object(owner_uid, owner_gid, date_creation, state, description, type) VALUES ( ?, ?, NOW(), ?, ?, ?)');
+    $sth->execute($owner_uid, $owner_gid, $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);
@@ -202,6 +196,12 @@
 	return $self->{'owner_uid'};
 }
 
+sub get_owner_gid
+{
+	my $self = shift;
+	return $self->{'owner_gid'};
+}
+
 sub get_type
 {
     my $self = shift;
@@ -229,23 +229,16 @@
     my $self = shift;
     my $request;
 
-    $request = 'UPDATE vhffs_object SET state=?, description=?, owner_uid=? WHERE object_id=?';
+    $request = 'UPDATE vhffs_object SET state=?, description=?, owner_uid=?, owner_gid=? WHERE object_id=?';
     my $result = $self->{'db'}->prepare($request);
-    $result->execute( $self->{'state'} , $self->{'description'} , $self->{'owner_uid'} , $self->{'object_id'} );;
+    $result->execute( $self->{'state'} , $self->{'description'} , $self->{'owner_uid'} , $self->{'owner_gid'} , $self->{'object_id'} );;
 
 }
 
 sub get_date
 {
 	my $self = shift;
-	if( defined $self->{'date_creation'} )
-	{
-		return $self->{'date_creation'};
-	}
-	else
-	{
-		return undef;
-	}
+	return $self->{'date_creation'};
 }
 
 sub get_oid
@@ -260,13 +253,19 @@
     return $self->{'description'};
 }
 
-sub set_owner
+sub set_owner_uid
 {
    my ( $self , $value ) = @_;
    $self->{'owner_uid'} = $value;
 }
 
+sub set_owner_gid
+{
+   my ( $self , $value ) = @_;
+   $self->{'owner_gid'} = $value;
+}
 
+
 sub get_status
 {
 	my $self = shift;
@@ -282,7 +281,7 @@
 	
 	if( $value == Vhffs::Constants::TO_DELETE )
 	{
-		$self->add_history( "Will be delete" );
+		$self->add_history( "Will be deleted" );
 	}
 	elsif( $value == Vhffs::Constants::WAITING_FOR_CREATION )
 	{
@@ -290,23 +289,23 @@
 	}
 	elsif( $value == Vhffs::Constants::CREATING_ERROR )
 	{
-		$self->add_history( "Creating error ! Robots can't create it." );
+		$self->add_history( "Creating error ! Robots can't create it" );
 	}
 	elsif( $value == Vhffs::Constants::CREATED )
 	{
-		$self->add_history( "Object is created." );
+		$self->add_history( "Object is created" );
 	}
 	elsif( $value == Vhffs::Constants::WAITING_FOR_VALIDATION )
 	{
-		$self->add_history( "Object is under moderation.");
+		$self->add_history( "Object is under moderation");
 	}
 	elsif( $value == Vhffs::Constants::VALIDATION_REFUSED )
 	{
-		$self->add_history( "Validation refused.");
+		$self->add_history( "Validation refused");
 	}
 	elsif( $value == Vhffs::Constants::ACTIVATED )
 	{
-		$self->add_history( "Is now active for production.");
+		$self->add_history( "Is now active for production");
 	}
 	
 	
@@ -315,7 +314,7 @@
 
 sub set_default_state
 {
-use Vhffs::Debug;
+	use Vhffs::Debug;
 	my $self = shift;
 	my $vhffs = $self->{'main'};
 
@@ -387,30 +386,30 @@
 	my $name = shift;
 
 	my $query;
-    my $request;
+	my $request;
 
 	if( defined $name )
 	{
         $name = '%'.$name.'%';
-        $query = 'SELECT o.object_id, o.owner_uid, o.date_creation , o.description, o.state, 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 ? ) ORDER BY object_id';
+        $query = 'SELECT o.object_id, o.owner_uid, o.owner_gid, o.date_creation , o.description, o.state, 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 ? ) ORDER BY object_id';
         $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.description, o.state, o.type FROM vhffs_object o ORDER BY object_id';
+		$query = 'SELECT o.object_id, o.owner_uid, o.owner_gid, o.date_creation , o.description, o.state, o.type FROM vhffs_object o ORDER BY object_id';
 		$request = $vhffs->get_db_object->prepare( $query ) or return -1;
 
-    	return undef if ( !$request->execute() );
-    }
+		return undef if ( !$request->execute() );
+	}
 	
-    my $result;
-    my $rows = $request->fetchall_arrayref();
-    foreach(@$rows) {
-        push(@$result, _new Vhffs::Object($vhffs, @$_));
-    }
-    return $result;
+	my $result;
+	my $rows = $request->fetchall_arrayref();
+	foreach(@$rows) {
+		push(@$result, _new Vhffs::Object($vhffs, @$_));
+	}
+	return $result;
 }
 
 sub get_group
@@ -466,7 +465,7 @@
 sub get_by_oid
 {
     my ($vhffs, $oid) = @_;
-    my $query = 'SELECT owner_uid, date_creation, description, state, type FROM vhffs_object WHERE object_id =?';
+    my $query = 'SELECT owner_uid, owner_gid, date_creation, description, state, type FROM vhffs_object WHERE object_id =?';
     my $sth = $vhffs->get_db_object->prepare( $query );
     my $rows = $sth->execute( $oid );
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm	2007-07-12 10:20:23 UTC (rev 714)
@@ -76,52 +76,37 @@
 
 sub create_home
 {
-	my( $main , $username , $user , $homedir , @subdirs , $path , $value );
-	$main = shift;
-	$user = shift;
+	my $main = shift;
+	my $user = shift;
 
-	if( defined $user )
-	{
-		$user->add_history( "Ok, robots take now the creation of the user" );
-		$homedir = $user->get_home;
+	return -1 unless defined $user;
 
-		@subdirs = split( /\// , $homedir );
-		@subdirs = reverse @subdirs;
+	my $homedir = $user->get_home;
 		
-		$path = "";
+	if( Vhffs::Functions::create_dir( $homedir ) )  {
+		chown $user->get_uid , $user->get_gid , $homedir;
+		chmod oct('1755'), $homedir;
 		
-		while( defined ( $value = pop ( @subdirs ) )  )
-		{
-			$path .= "/".$value if( $value ne '' );
-			Vhffs::Functions::create_dir( $path );
-			#return -1 if( mkdir( $path ) == false );
-		}
-		chown $user->get_uid , $user->get_gid , $path ;
-        chmod oct('1755'), $path;
-		
-		$user->add_history( "Creation complete for user. Homedir is now created." );
+		$user->add_history( 'homedir created' );
 		$user->set_status( Vhffs::Constants::ACTIVATED );
-		my $plainpassword = $user->generate_password;
+		return -1 if( $user->commit < 0 );
 
 		# Send a mail with plain password inside
+		my $plainpassword = $user->generate_password;
 		my $subject = "Welcome on VHFFS";
 		my $content = sprintf("Hello %s %s, Welcome on VHFFS\n\nHere are your login information :\nUser: %s\nPassword: %s\n\nVHFFS Administrators\n", $user->get_firstname, $user->get_lastname, $user->get_username, $plainpassword );
 		$user->send_mail_user( $subject, $content );
 
-		if( $user->commit < 0 )
-		{
-			return -1;
-		}
-		else
-		{
-			return 1;
-		}
 	}
+	else  {
+		$user->add_history( 'cannot create the homedir directory' );
+#		$user->set_status( Vhffs::Constants::CREATING_ERROR );
+#		$user->commit;
+		return -1;
+	}
 
-	return 1;
-
+	return 0;
 }
 
 
 1;
-

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2007-07-12 10:20:23 UTC (rev 714)
@@ -87,7 +87,7 @@
 
 sub _new {
     my ($class, $main, $uid, $gid, $oid, $username, $passwd, $homedir, $shell, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, $note, $language, $theme, $date_creation, $description, $state) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $uid, $date_creation, $description, $state, Vhffs::Constants::TYPE_USER);
+    my $self = $class->SUPER::_new($main, $oid, $uid, undef, $date_creation, $description, $state, Vhffs::Constants::TYPE_USER);
     return undef unless(defined $self);
     $self->{uid} = $uid;
     $self->{gid} = $gid;
@@ -203,7 +203,8 @@
         my ($gid) = $dbh->selectrow_array('SELECT nextval(\'vhffs_groups_gid_seq\')');
         
         # Create corresponding object
-        my $parent = Vhffs::Object::create($main, $uid, '', undef, Vhffs::Constants::TYPE_USER);
+	# -- TODO, user moderation (easy to do now)
+        my $parent = Vhffs::Object::create($main, $uid, $gid, '', Vhffs::Constants::WAITING_FOR_CREATION, Vhffs::Constants::TYPE_USER);
         die('Error creating parent') unless (defined $parent);
 
         # Insert base information
@@ -402,128 +403,82 @@
 
 sub get_username
 {
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'username'};
 }
 
-
-
 sub get_firstname
 {
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'firstname'};
 }
 
-
 sub get_lastname
 {
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'lastname'};
 }
 
-
 sub get_city
 {
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'city'};
 }
 
 sub get_country
 {
-     my $self;
-     $self = shift;
-
+     my $self = shift;
      return $self->{'country'};
 }
 
 sub get_gpg
 {
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'gpg_key'};
 }
 
 sub get_zipcode
 {
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'zipcode'};
 }
 
-
-
 sub get_home
 {
-    use Vhffs::Functions;
-
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'homedir'}
 }
 
-
 sub get_password
 {
-    my $self;
-    $self = shift;
-
+    my $self = shift;
     return $self->{'passwd'}
 }
 
-
 sub get_uid
 {
     my $self = shift;
-
-    if( defined $self->{'uid'} )
-    {
-        return $self->{'uid'};
-    }
-    else
-    {
-        return -1;
-    }
+    return $self->{'uid'} if( defined $self->{'uid'} );
+    return -1;
 }
 
-
-
 sub get_gid
 {
     my $self = shift;
-
-    if( defined $self->{'gid'} )
-    {
-        return $self->{'gid'};
-    }
-    else
-    {
-        return -1;
-    }
+    return $self->{'gid'} if( defined $self->{'gid'} );
+    return -1;
 }
 
 sub get_lang
 {
     my $self = shift;
-    my $request;
     return $self->{language};
 }
 
-
 sub get_mail
 {
-	my $self = shift;
-	return $self->{'mail'};
+    my $self = shift;
+    return $self->{'mail'};
 }
 
 sub get_theme
@@ -534,8 +489,8 @@
 
 sub get_address
 {
-	my $self = shift;
-	return $self->{'address'};
+    my $self = shift;
+    return $self->{'address'};
 }
 
 sub get_group
@@ -550,7 +505,13 @@
     return $self->{'shell'};
 }
 
+sub get_gpgkey
+{
+    my $self = shift;
+    return( $self->{'gpg_key'} );
+}
 
+
 sub set_shell
 {
     my $self = shift;
@@ -558,7 +519,6 @@
     $self->{'shell'} = $value;
 }
 
-
 sub set_firstname
 {
     my $self = shift;
@@ -580,13 +540,11 @@
     $self->{'city'} = $value;
 }
 
-
 sub set_zipcode
 {
     my $self = shift;
-    my $value = shift;
-    
-    $self->{'zipcode'} = $value if( $value =~ /^[\d]+$/ );
+    my $value = shift;    
+    $self->{'zipcode'} = $value;
 }
 
 sub set_country
@@ -609,9 +567,10 @@
    	my $self  = shift;
 	my $value = shift;
    
-	if(  Vhffs::Functions::valid_mail( $value ) == 1  )
+	if(  Vhffs::Functions::valid_mail( $value ) == 1 )
 	{
 		$self->{'mail'} = $value;
+		return 0;
 	}
 	else
 	{
@@ -619,15 +578,6 @@
 	}
 }
 
-
-sub get_gpgkey
-{
-    my $self  = shift;
-    return( $self->{'gpg_key'} );
-}
-
-
-
 sub set_gpgkey
 {
     my $self = shift;
@@ -647,7 +597,7 @@
 sub set_admin
 {
     my ( $self , $value ) = @_;
-	$self->{'admin'} = $value;
+    $self->{'admin'} = $value;
 }
 
 sub is_admin

Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in	2007-07-12 10:20:23 UTC (rev 714)
@@ -33,11 +33,12 @@
 CREATE TABLE vhffs_object
 (
 	object_id serial,
-	owner_uid int4,
-	date_creation timestamp,
+	owner_uid int4 NOT NULL,
+	owner_gid int4 NOT NULL,
+	date_creation timestamp NOT NULL,
 	state int4 NOT NULL,
 	description TEXT,
-	type int4 DEFAULT 0,
+	type int4 NOT NULL DEFAULT 0,
 	CONSTRAINT vhffs_object_pkey PRIMARY KEY (object_id)
 ) WITH OIDS;
 
@@ -58,8 +59,6 @@
 	quota int4 NOT NULL,
 	quota_used int4 NOT NULL DEFAULT 0,
 	object_id int4 NOT NULL,
-	owner_uid int4,
-	uid_mod int4,
 	CONSTRAINT vhffs_groups_pkey PRIMARY KEY (gid)
 ) WITH OIDS;
 
@@ -75,7 +74,6 @@
 	homedir varchar(40) NOT NULL DEFAULT ' ',
 	admin int4 NOT NULL,
 	object_id int4 NOT NULL,
-	date_creation timestamp,
 	firstname varchar(250),
 	lastname varchar(250),
 	address text,

Modified: trunk/vhffs-compat/4.0.sql.in
===================================================================
--- trunk/vhffs-compat/4.0.sql.in	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-compat/4.0.sql.in	2007-07-12 10:20:23 UTC (rev 714)
@@ -18,12 +18,23 @@
 SELECT setval('vhffs_repository_repository_id_seq', (SELECT COALESCE(MAX(repository_id), 1) FROM vhffs_repository));
 SELECT setval('vhffs_svn_svn_id_seq', (SELECT COALESCE(MAX(svn_id), 1) FROM vhffs_svn));
 
-ALTER TABLE vhffs_object ALTER owner_uid DROP NOT NULL;
-ALTER TABLE vhffs_users ALTER gid DROP NOT NULL;
-
 DROP TABLE vhffs_largefile CASCADE;
 DROP TABLE vhffs_confirmation CASCADE;
 
+-- vhffs_users
+ALTER TABLE vhffs_users ALTER gid DROP NOT NULL;
+- TODO merge date_creation to vhffs_object (check if this field is set in vhffs_users AND not in vhffs_object)
+DROP VIEW vhffs_forum;
+ALTER TABLE vhffs_users DROP COLUMN date_creation;
+
+-- vhffs_object
+ALTER TABLE vhffs_object ADD COLUMN owner_gid int4;
+ALTER TABLE vhffs_object ALTER owner_uid SET NOT NULL;
+ALTER TABLE vhffs_object ALTER owner_gid SET NOT NULL;
+ALTER TABLE vhffs_object ALTER date_creation SET NOT NULL;
+
+-- TODO: merge vhffs_$service:owner_uid|owner_gid -> vhffs_object
+
 -- add a column named "type" on object table in order to know the purpose of the object (web area, mysql, ...)
 -- existing types: unassigned[0], user[10], group[11], httpd[20], repository[21], mysql[30], pgsql[31], cvs[40], svn[41], dns[50], mail[60], ml[61]
 -- Pg 7.4 doesn't support default value in add column !
@@ -85,6 +96,10 @@
 
 -- DROP TABLE vhffs_panel_user_prefs;
 
+-- vhffs_groups
+ALTER TABLE vhffs_groups DROP COLUMN owner_uid;
+ALTER TABLE vhffs_groups DROP COLUMN uid_mod;
+
 -- merge vhffs_groups_info to vhffs_groups
 ALTER TABLE vhffs_groups ADD COLUMN owner_uid int4;
 ALTER TABLE vhffs_groups ADD COLUMN uid_mod int4;

Modified: trunk/vhffs-robots/src/create_homes.pl
===================================================================
--- trunk/vhffs-robots/src/create_homes.pl	2007-07-12 09:53:45 UTC (rev 713)
+++ trunk/vhffs-robots/src/create_homes.pl	2007-07-12 10:20:23 UTC (rev 714)
@@ -46,7 +46,7 @@
 
 foreach $user ( @{$users} )
 {
-	if( Vhffs::Robots::User::create_home( $vhffs , $user ) < 0 )
+	if( Vhffs::Robots::User::create_home( $vhffs , $user ) != 0 )
 	{
 		Vhffs::Robots::vhffs_log( sprintf( "Error while creating home for %s" , $user->get_username) , $vhffs);
 	}


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