Index: /trunk/web2/addons/job_monarch/image.php
===================================================================
--- /trunk/web2/addons/job_monarch/image.php	(revision 581)
+++ /trunk/web2/addons/job_monarch/image.php	(revision 582)
@@ -28,17 +28,21 @@
 include_once "./libtoga.php";
 
-if ( !empty( $_GET ) ) {
+if ( !empty( $_GET ) )
+{
         extract( $_GET );
 }
 
-function checkSessionData() {
-
+function checkSessionData()
+{
 	global $_SESSION;
 
 	session_start();
 
-	if( isset( $_SESSION["data"] ) ) {
-		$myxml_data	= &$_SESSION["data"];
-	} else {
+	if( isset( $_SESSION['data'] ) )
+	{
+		$myxml_data	= &$_SESSION['data'];
+	}
+	else
+	{
 		$myxml_data	= 0;
 	}
@@ -48,5 +52,4 @@
 		$myxml_data     = $ds->getData();
 
-		//print_f( "%s\n", $myxml_data );
 	}
 	return $myxml_data;
@@ -54,17 +57,16 @@
 
 
-$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
-$view = $httpvars->getHttpVar( "view" );
-$host = $httpvars->getHttpVar( "host" );
-$query = $httpvars->getHttpVar( "query" );
-$clustername = $httpvars->getClusterName();
+$httpvars	= new HTTPVariables( $HTTP_GET_VARS, $_GET );
+$view		= $httpvars->getHttpVar( "view" );
+$host		= $httpvars->getHttpVar( "host" );
+$query		= $httpvars->getHttpVar( "query" );
+$clustername	= $httpvars->getClusterName();
 
-if( isset($jid) && ($jid!='')) $filter[jid]=$jid;
-if( isset($state) && ($state!='')) $filter[state]=$state;
-if( isset($owner) && ($owner!='')) $filter[owner]=$owner;
-if( isset($queue) && ($queue!='')) $filter[queue]=$queue;
-if( isset($host) && ($host!='')) $filter[host]=$host;
-if( isset($query) && ($query!='')) $filter[query]=$query;
-//printf("host = %s\n", $filter[host] );
+if( isset($jid) && ($jid!='')) $filter['jid']=$jid;
+if( isset($state) && ($state!='')) $filter['state']=$state;
+if( isset($owner) && ($owner!='')) $filter['owner']=$owner;
+if( isset($queue) && ($queue!='')) $filter['queue']=$queue;
+if( isset($host) && ($host!='')) $filter['host']=$host;
+if( isset($query) && ($query!='')) $filter['query']=$query;
 
 function drawHostImage() {
@@ -80,7 +82,11 @@
 
 	if( $data_gatherer->isJobmonRunning() )
+	{
 		$ic = new HostImage( $data_gatherer, $clustername, $hostname );
+	}
 	else
+	{
 		$ic = new EmptyImage();
+	}
 
 	$ic->draw();
@@ -98,8 +104,11 @@
 	$data_gatherer->parseXML( $myxml_data );
 
-	if( $data_gatherer->isJobmonRunning() ) {
+	if( $data_gatherer->isJobmonRunning() )
+	{
 		$ic = new ClusterImage( $myxml_data, $clustername );
 		$ic->setSmall();
-	} else {
+	}
+	else
+	{
 		$ic = new EmptyImage();
 	}
@@ -117,30 +126,9 @@
 	$ic->setBig();
 
-	if( isset( $filter ) ) {
-		foreach( $filter as $filtername=>$filtervalue ) {
-			//printf("filter %s,%s\n", $filtername, $filtervalue);
-			switch( $filtername ) {
-
-				case "jid":
-					$ic->setFilter( 'jobid', $filtervalue );
-					break;
-				case "owner":
-					$ic->setFilter( 'owner', $filtervalue);
-					break;
-				case "queue":
-					$ic->setFilter( 'queue', $filtervalue);
-					break;
-				case "state":
-					$ic->setFilter( 'status', $filtervalue);
-					break;
-				case "host":
-					$ic->setFilter( 'host', $filtervalue);
-					break;
-				case "query":
-					$ic->setFilter( 'query', $filtervalue);
-					break;
-				default:
-					break;
-			}
+	if( isset( $filter ) )
+	{
+		foreach( $filter as $filtername=>$filtervalue )
+		{
+			$ic->setFilter( $filtername, $filtervalue );
 		}
 	}
Index: /trunk/web2/addons/job_monarch/libtoga.php
===================================================================
--- /trunk/web2/addons/job_monarch/libtoga.php	(revision 581)
+++ /trunk/web2/addons/job_monarch/libtoga.php	(revision 582)
@@ -1402,93 +1402,86 @@
 		$filtered_nodes = array();
 
+		$filter_checks	= array();
+
 		foreach( $nodes as $node )
 		{
-			$hostname = $node->getHostname();
-
-			$addhost = 1;
-
-			if( count( $this->filters ) > 0 )
-			{
-				$mynjobs = $node->getJobs();
-
-				if( $filtername == 'host' && $hostname == $filtervalue )
-				{
-					$addhost	= 1;
-					$this->selected	= $hostname;
-				}
-				else if( count( $mynjobs ) > 0 )
-				{
-					foreach( $mynjobs as $myjob )
-					{
-						foreach( $this->filters as $filtername => $filtervalue )
-						{
-							if( $filtername!=null && $filtername!='' )
+			$hostname	= $node->getHostname();
+			$mynjobs	= $node->getJobs();
+
+			foreach( $this->filters as $filtername => $filtervalue )
+			{
+				$filter_checks[$filtername] = false;
+			}
+
+			if( array_key_exists( 'host', $this->filters ) )
+			{
+				if( $hostname == $this->filters['host'] )
+				{
+					$this->selected		= $hostname;
+					$filtered_nodes[] = $hostname;
+					//$filter_checks['host']	= true;
+				}
+			}
+
+			if( count( $mynjobs ) == 0 )
+			{
+				continue;
+			}
+
+			foreach( $mynjobs as $myjob )
+			{
+				foreach( $this->filters as $filtername => $filtervalue )
+				{
+					if( $filtername == 'jid' )
+					{
+						if( $myjob == $filtervalue )
+						{
+							$filter_checks['jid'] = true;
+						}
+					}
+					if( $filtername == 'query' )
+					{
+						foreach( $jobs[$myjob] as $myj_attr => $myj_val )
+						{
+							if( is_array( $myj_val ) )
 							{
-								if( $filtername == 'jobid' )
+								foreach( $myj_val as $myj_v )
 								{
-									if ( $myjob != $filtervalue )
+									if( strpos( $myj_v, $filtervalue ) !== false )
 									{
-										$addhost = 0;
-										break;
-									}
-									else
-									{
-										$addhost = 1;
-										break;
-									}
-								}
-								else
-								{
-									if( $jobs[$myjob][$filtername] == $filtervalue )
-									{
-										$addhost = 1;
-										continue;
-									}
-									else if( $jobs[$myjob][$filtername] != $filtervalue )
-									{
-										$addhost = 0;
-									}
-									if( $filtername == 'query' )
-									{
-										foreach( $jobs[$myjob] as $myj_attr => $myj_val )
-										{
-											if(!is_array( $myj_val ) )
-											{
-												if( strpos( $myj_val, $filtervalue ) !== false )
-												{
-													$addhost = 1;
-													continue;
-												}
-											}
-											else
-											{
-												foreach( $myj_val as $myj_v )
-												{
-													if( strpos( $myj_v, $filtervalue ) !== false )
-													{
-														$addhost = 1;
-														continue;
-													}
-												}
-											}
-											if( strpos( $myjob, $filtervalue ) !== false )
-											{
-												$addhost	= 1;
-												continue;
-											}
-										}
+										$filter_checks['query'] = true;
 									}
 								}
 							}
-						}
-					}
-				}
-				else
-				{
-					$addhost = 0;
-				}
-			}
-
-			if( $addhost )
+							else
+							{
+								if( strpos( $myj_v, $filtervalue ) !== false )
+								{
+									$filter_checks['query'] = true;
+								}
+							}
+						}
+					}
+					if( $filtername != 'host' )
+					{
+						if( $jobs[$myjob][$filtername] == $filtervalue )
+						{
+							$filter_checks[$filtername] = true;
+						}
+					}
+				}
+			}
+
+			$addhost	= true;
+
+			foreach( $filter_checks as $c_filtername => $c_filterfound )
+			{
+				if( ! $c_filterfound )
+				{
+					$addhost	= false;
+				}
+			}
+
+			if( $addhost == true )
 			{
 				$filtered_nodes[] = $hostname;
