[vhffs-dev] [718] Adapted is_empty method and added repository and mailing lists handling.

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


Revision: 718
Author:   beuss
Date:     2007-07-12 14:02:23 +0000 (Thu, 12 Jul 2007)

Log Message:
-----------
Adapted is_empty method and added repository and mailing lists handling.

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


Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2007-07-12 13:37:55 UTC (rev 717)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2007-07-12 14:02:23 UTC (rev 718)
@@ -175,76 +175,83 @@
 	my $query;
 	my $request;
 
-	if( $config->use_web == 1 )
-	{
-		$query ='SELECT COUNT(*) FROM vhffs_httpd WHERE owner_gid=?';
+	if( $config->use_web == 1 ) {
+		$query ='SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid=?';
 	    $request = $self->{'db'}->prepare( $query );
-	    $request->execute( $self->get_gid );
+	    $request->execute( Vhffs::Constants::TYPE_HTTPD, $self->get_gid );
         ($rows) = $request->fetchrow();
 		return 0 if( $rows != 0 );
 	}
 	
-	if( $config->use_cvs == 1 )
-	{
-		$query ='SELECT COUNT(*) FROM vhffs_cvs WHERE owner_gid=?';
+	if( $config->use_cvs == 1 ) {
+		$query ='SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid=?';
 	    $request = $self->{'db'}->prepare( $query );
-	    $request->execute( $self->get_gid );
+	    $request->execute( Vhffs::Constants::TYPE_CVS, $self->get_gid );
         ($rows) = $request->fetchrow();
 		return 0 if( $rows != 0 );
 	}
 	
-	if( $config->use_svn == 1 )
-	{
-		$query ='SELECT COUNT(*) FROM vhffs_svn WHERE owner_gid=?';
+	if( $config->use_svn == 1 ) {
+		$query ='SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid=?';
 	    $request = $self->{'db'}->prepare( $query );
-	    $request->execute( $self->get_gid );
+	    $request->execute( Vhffs::Constants::TYPE_SVN, $self->get_gid );
         ($rows) = $request->fetchrow();
 		return 0 if( $rows != 0 );
 	}
 
 	
-	if( $config->use_mail == 1 )
-	{
-		$query ='SELECT COUNT(*) FROM vhffs_mxdomain WHERE owner_gid=?';
+	if( $config->use_mail == 1 ) { 
+		$query ='SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid=?';
 	    $request = $self->{'db'}->prepare( $query );
-	    $request->execute( $self->get_gid );
+	    $request->execute( Vhffs::Constants::TYPE_MAIL, $self->get_gid );
         ($rows) = $request->fetchrow();
 		return 0 if( $rows != 0 );
 	}
 
 
-	if( $config->use_dns == 1 )
-	{
-		$query ='SELECT COUNT(*) FROM vhffs_dns WHERE owner_gid=?';
+	if( $config->use_dns == 1 ) {
+		$query ='SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid=?';
 	    $request = $self->{'db'}->prepare( $query );
-	    $request->execute( $self->get_gid );
+	    $request->execute( Vhffs::Constants::TYPE_DNS, $self->get_gid );
         ($rows) = $request->fetchrow();
 		return 0 if( $rows != 0 );
 	}
 
 
-
-	if( $config->use_postgres == 1 )
-	{
-		$query ='SELECT COUNT(*) FROM vhffs_pgsql WHERE owner_gid=?';
+	if( $config->use_postgres == 1 ) { 
+		$query ='SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid=?';
 	    $request = $self->{'db'}->prepare( $query );
-	    $request->execute( $self->get_gid );
+	    $request->execute( Vhffs::Constants::TYPE_PGSQL, $self->get_gid );
         ($rows) = $request->fetchrow();
 		return 0 if( $rows != 0 );
 	}
 
 
-
-
-	if( $config->use_mysql == 1 )
-	{
-		$query ='SELECT COUNT(*) FROM vhffs_mysql WHERE owner_gid=?';
+	if( $config->use_mysql == 1 ) {
+		$query ='SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid=?';
 	    $request = $self->{'db'}->prepare( $query );
-	    $request->execute( $self->get_gid );
+	    $request->execute( Vhffs::Constants::TYPE_MYSQL, $self->get_gid );
         ($rows) = $request->fetchrow();
 		return 0 if( $rows != 0 );
 	}
 
+    if( $config->use_mailing == 1) {
+        $query = 'SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid = ?';
+        $request = $self->get_db_object()->prepare( $query );
+        $request->execute( Vhffs::Constants::TYPE_ML, $self->get_gid );
+        ($rows) = $request->fetchrow();
+        return 0 if( $rows != 0);
+    }
+
+    if( $config->use_repository == 1) {
+        $query = 'SELECT COUNT(*) FROM vhffs_object WHERE type = ? AND owner_gid = ?';
+        $request = $self->get_db_object()->prepare( $query );
+        $request->execute( Vhffs::Constants::TYPE_REPOSITORY, $self->get_gid );
+        ($rows) = $request->fetchrow();
+        return 0 if( $rows != 0);
+    }
+
+
 	return 1;
 
 }


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