| 
					
				 | 
			
			
				@@ -6,20 +6,30 @@ class chado_views_handler_filter_string extends views_handler_filter_string { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    * Defines the options form (form available to admin when they add a field to a view) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   function options_form(&$form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $form['msg'] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#type' => 'item', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     parent::options_form($form, $form_state); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $form['records_with'] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $form['agg'] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#type' => 'fieldset', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#title' => 'Apply to fields that are aggregated' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $form['agg']['records_with'] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#type' => 'checkbox', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#title' => t('Filter base table records'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#default_value' => ($this->options['records_with']) ? $this->options['records_with'] : TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $form['aggregates_with'] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $form['agg']['aggregates_with'] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#type' => 'checkbox', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#title' => t('Filter aggregates displayed'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#default_value' => ($this->options['aggregates_with']) ? $this->options['aggregates_with'] : TRUE,     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,7 +57,7 @@ class chado_views_handler_filter_string extends views_handler_filter_string { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // This doesn't restrict the items in the aggregate field 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $this->ensure_my_table(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $field = "$this->table_alias.$this->real_field"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if ($this->options['records_with']) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if ($this->options['agg']['records_with']) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $where = "'%s' = ANY($field)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->query->add_where($this->options['group'], $where, $this->value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -55,7 +65,7 @@ class chado_views_handler_filter_string extends views_handler_filter_string { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // To restrict the items in the aggregate... 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // Tell the join handler about the filter  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // so it can be done in the join query 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if ($this->options['aggregates_with']) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if ($this->options['agg']['aggregates_with']) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $table['join']->filter[] = $field ." = '". $this->value."'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |