[vhffs-dev] [968] Public area doesn't display unactivated users and groups anymore

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


Revision: 968
Author:   gradator
Date:     2007-10-06 13:45:14 +0000 (Sat, 06 Oct 2007)

Log Message:
-----------
Public area doesn't display unactivated users and groups anymore

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Group.pm
    trunk/vhffs-api/src/Vhffs/User.pm


Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2007-10-05 21:42:33 UTC (rev 967)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2007-10-06 13:45:14 UTC (rev 968)
@@ -458,19 +458,18 @@
 
 sub get_last_groups
 {   
-    my $vhffs = shift;
-    
-    return if ( !defined $vhffs );
-   	my @groups;
-    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 ($gid) = $request->fetchrow_array )
-    {
-        my $group = Vhffs::Group::get_by_gid( $vhffs , $gid );
-        push @groups , $group;
-    }
-    return \@groups;
+	my $vhffs = shift;
+	return unless defined $vhffs;
+
+	my $request = $vhffs->{'db'}->prepare( 'SELECT g.gid FROM vhffs_groups g LEFT OUTER JOIN vhffs_users u ON u.username=g.groupname INNER JOIN vhffs_object o ON o.object_id=g.object_id WHERE o.state=? AND u.username IS NULL ORDER BY g.gid DESC LIMIT 10' );
+	$request->execute( Vhffs::Constants::ACTIVATED );
+
+	my @groups;
+	while( my ($gid) = $request->fetchrow_array )
+	{
+		push @groups, Vhffs::Group::get_by_gid( $vhffs , $gid );
+	}
+	return \@groups;
 }
 
 

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2007-10-05 21:42:33 UTC (rev 967)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2007-10-06 13:45:14 UTC (rev 968)
@@ -691,24 +691,18 @@
 
 sub get_last_users
 {
-    my $vhffs = shift;
-    my @users;
+	my $vhffs = shift;
+	return unless defined $vhffs;
 
-    return if ( !defined $vhffs );
+	my $request = $vhffs->{'db'}->prepare( 'SELECT u.uid FROM vhffs_users u INNER JOIN vhffs_object o ON u.object_id=o.object_id WHERE o.state=? ORDER BY uid DESC LIMIT 10' );
+	$request->execute( Vhffs::Constants::ACTIVATED );
 
-    my $query = 'SELECT uid FROM vhffs_users ORDER BY uid DESC LIMIT 10';
-    my $request = $vhffs->{'db'}->prepare( $query );
-	$request->execute;
-    while( my ($uid) = $request->fetchrow_array )
-    {   
-        my $user = Vhffs::User::get_by_uid( $vhffs , $uid );
-        if( defined $user )
-        {   
-            push @users , $user;
-        }
-    }
-    return \@users;
-
+	my @users;
+	while( my ($uid) = $request->fetchrow_array )
+	{   
+		push @users, Vhffs::User::get_by_uid( $vhffs , $uid );
+	}
+	return \@users;
 }
 
 


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