[vhffs-dev] [467] Removed all references to vhffs_user_info.

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


Revision: 467
Author:   beuss
Date:     2007-02-17 10:21:01 +0000 (Sat, 17 Feb 2007)

Log Message:
-----------
Removed all references to vhffs_user_info.

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/User.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
    branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf
    branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf.hash


Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/User.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/User.pm	2007-02-17 09:07:43 UTC (rev 466)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/User.pm	2007-02-17 10:21:01 UTC (rev 467)
@@ -72,11 +72,11 @@
 
     if( ! defined $name )
 	{
-		$query = "SELECT u.username, ui.firstname, ui.lastname , o.object_id FROM vhffs_users u, vhffs_user_info ui, vhffs_object o WHERE o.object_id=u.object_id AND u.uid=ui.uid";
+		$query = 'SELECT u.username, u.firstname, u.lastname , o.object_id FROM vhffs_users u, vhffs_object o WHERE o.object_id=u.object_id';
 	}
 	else
 	{
-		$query = "SELECT u.username, ui.firstname, ui.lastname , o.object_id FROM vhffs_users u, vhffs_user_info ui, vhffs_object o WHERE o.object_id=u.object_id AND u.uid=ui.uid AND ( ( u.username LIKE '%".$name."%' ) OR (ui.firstname LIKE '%".$name."%' ) OR (ui.lastname LIKE '%".$name."%') )";
+		$query = "SELECT u.username, u.firstname, u.lastname , o.object_id FROM vhffs_users u, vhffs_object o WHERE o.object_id=u.object_id AND ( ( u.username LIKE '%".$name."%' ) OR (u.firstname LIKE '%".$name."%' ) OR (u.lastname LIKE '%".$name."%') )";
 	}
 
 	

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2007-02-17 09:07:43 UTC (rev 466)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm	2007-02-17 10:21:01 UTC (rev 467)
@@ -154,41 +154,23 @@
         return -1;
     }
 
+    $self->{group}->fetch();
+    $self->SUPER::fetch();
+    return 1;
+
 }
 
 
 # get a complete user
-# it fetch informations in the vhffs_users table and vhffs_user_info
+# it fetch informations in the vhffs_users table
 sub fetch
 {
-    my $self;
-    my $request;
-    my $result;
-    my $ret;
-
-    $self = shift;
-
-    return $ret if( ( $ret = $self->fetch_unix() ) < 0 );
-
-    $request = $self->{'db'}->prepare('SELECT * FROM vhffs_users where uid=?') or return -2;
-    
-    $request->execute($self->{'uid'}) or return -2;
-
-    $result = $request->fetchrow_hashref();
-
-
-    foreach ( keys %{$result} )
-    {
-		$self->{$_} = $result->{$_}
-    }
-
-    $self->{'group'}->fetch;
-
-
-	$self->SUPER::fetch;
-    return 1;    
+    my ($package, $file, $line) = caller();
+    warn "Using deprecated method Vhffs::User::fetch from $package ($file:$line).\n";
+    return fetch_unix(@_);
 }
 
+
 #add a user to a group
 sub add_group
 {
@@ -225,7 +207,11 @@
 
 sub create {
     # for compatibility until complete refactoring
-    return old_create(@_) if($_[0]->isa('Vhffs::User'));
+    if($_[0]->isa('Vhffs::User')) {
+        my ($package, $file, $line) = caller();
+        warn "Using deprecated form of Vhffs::User::create from $package ($file:$line).\n";
+        return old_create(@_);
+    }
     
     my ( $main, $username, $password, $admin, $mail, $firstname, $lastname, $city, $zipcode, $country, $address, $gpg_key ) = @_;
     return undef unless check_username($username);
@@ -340,7 +326,7 @@
    
 	    $homedir = Vhffs::Functions::hash_homename( $self->{'username'}  , $self->{'main'} );
 
-        $request = $self->{'db'}->prepare('INSERT INTO vhffs_users (gid, username, shell, passwd, homedir, admin, object_id) VALUES(?, ?, ?, ?, ?, ?, ?)');
+        $request = $self->{'db'}->prepare('INSERT INTO vhffs_users (gid, username, shell, passwd, homedir, admin, date_creation, object_id) VALUES(?, ?, ?, ?, ?, ?, now(), ?)');
 
         $request->execute(3 , $self->{'username'}, $conf->{'shell'}, '' , $homedir, $self->{'admin'}, $oid);
     
@@ -348,11 +334,6 @@
         $self->SUPER::set_owner($self->{'uid'});
         $self->SUPER::commit();
 
-        # FIXME This two step creation is *ugly* we should consider using a kind
-        # of factory for the whole user creation.
-        $request = $self->{'db'}->prepare( 'INSERT INTO vhffs_user_info(uid, date_creation) VALUES(?, now())' );
-        $request->execute($self->{'uid'});
-    
         #Now, create the GID
         $self->{'group'} = new Vhffs::Group( $self->{'main'} , $self->{'username'} , $self->{'uid'} );
         $gid = $self->{'group'}->create;
@@ -364,7 +345,7 @@
         $request = $self->{'db'}->prepare('UPDATE vhffs_users SET gid = ? WHERE username=?');
         $request->execute($self->{'gid'}, $self->{'username'});
 
-        # Fill vhffs_user_info
+        # Fill User's informations
     	$self->commit;
         # If we are here all was fine so make changes permanent
         $self->{'db'}->commit;
@@ -987,7 +968,8 @@
 		print "User does not exists\n";
 	}
 	...
-	if( $user->create > 0 )
+    $user = Vhffs::User::create( $vhffs, 'myuser', 'apassword', 0, 'myuser@xxxxxxxxx');
+	if( defined $user )
 	{
 		print "User created";
 	}
@@ -1005,6 +987,8 @@
 
 =head1 METHODS
 
+I<FIXME : This sections isn't up to date>
+
 For each method, returns 1 if success, 0 otherwise. If the method should returns a reference, returns undef if fails.
 
 new( Vhffs::Main , "username" , "uid" ) : instanciate a new user

Modified: branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf
===================================================================
--- branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf	2007-02-17 09:07:43 UTC (rev 466)
+++ branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf	2007-02-17 10:21:01 UTC (rev 467)
@@ -6,7 +6,7 @@
 PGSQL_VIRTUAL_FORWARD_DATA = ${lookup pgsql{select remote_name from vhffs_forward, vhffs_mxdomain where local_part = '$local_part' and vhffs_forward.domain = vhffs_mxdomain.domain and vhffs_mxdomain.domain = '$domain'}}
 PGSQL_ML_EXIST = ${lookup pgsql{select domain from vhffs_ml where local_part='$local_part' and domain='$domain'}}
 PGSQL_VIRTUAL_CATCHALL = ${lookup pgsql{select catchall from vhffs_mxdomain where domain = '$domain' and catchall != ''}}
-PGSQL_GET_TX_USER = ${lookup pgsql{select vhffs_user_info.mail from vhffs_user_info, vhffs_users where vhffs_users.uid=vhffs_user_info.uid and vhffs_users.username='$local_part' and 'tuxfamily.org'='$domain'}}
+PGSQL_GET_TX_USER = ${lookup pgsql{select mail from vhffs_users where username='$local_part' and 'tuxfamily.org'='$domain'}}
 #PGSQL_VIRTUAL_LOCAL_QUOTA = ${lookup pgsql{select quota from popbox where local_part = "$local_part" and domaine = "$domain"}}
 #PGSQL_VIRTUAL_LOCAL_QFILE = ${lookup pgsql{select quota_f from popbox where local_part = "$local_part" and domain = "$domain"}}
 #PGSQL_VIRTUAL_LOCAL_Q_WARN = ${lookup pgsql{select quota_warn from popbox where local_part = "$local_part" and domain = "$domain"}}

Modified: branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf.hash
===================================================================
--- branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf.hash	2007-02-17 09:07:43 UTC (rev 466)
+++ branches/vhffs_4.1/vhffs-doc/config/exim4-mx1/exim4.conf.hash	2007-02-17 10:21:01 UTC (rev 467)
@@ -6,7 +6,7 @@
 PGSQL_VIRTUAL_FORWARD_DATA = ${lookup pgsql{select remote_name from vhffs_forward, vhffs_mxdomain where local_part = '$local_part' and vhffs_forward.domain = vhffs_mxdomain.domain and vhffs_mxdomain.domain = '$domain'}}
 PGSQL_ML_EXIST = ${lookup pgsql{select domain from mail_list where listname = '$local_part' and domain = '$domain'}}
 PGSQL_VIRTUAL_CATCHALL = ${lookup pgsql{select catchall from vhffs_mxdomain where domain = '$domain' and catchall != ''}}
-PGSQL_GET_TX_USER = ${lookup pgsql{select vhffs_user_info.mail from vhffs_user_info, vhffs_users where vhffs_users.uid=vhffs_user_info.uid and vhffs_users.username='$local_part' and 'tuxfamily.org'='$domain'}}
+PGSQL_GET_TX_USER = ${lookup pgsql{select mail from vhffs_users where username='$local_part' and 'tuxfamily.org'='$domain'}}
 #PGSQL_VIRTUAL_LOCAL_QUOTA = ${lookup pgsql{select quota from popbox where local_part = "$local_part" and domaine = "$domain"}}
 #PGSQL_VIRTUAL_LOCAL_QFILE = ${lookup pgsql{select quota_f from popbox where local_part = "$local_part" and domain = "$domain"}}
 #PGSQL_VIRTUAL_LOCAL_Q_WARN = ${lookup pgsql{select quota_warn from popbox where local_part = "$local_part" and domain = "$domain"}}


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