? config_inc_old.php
? error.log
? core/filter_api.phpx
Index: view_all_set.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/view_all_set.php,v
retrieving revision 1.45
diff -u -r1.45 view_all_set.php
--- view_all_set.php	12 Feb 2005 20:01:08 -0000	1.45
+++ view_all_set.php	15 Feb 2005 15:29:28 -0000
@@ -151,6 +151,9 @@
 			}
 		}
 	}
+	
+	$f_relationship_type = gpc_get_string( 'relationship_type', 'any' );
+	$f_relationship_bug = gpc_get_string( 'relationship_bug', 0 );
 
 	if ( $f_temp_filter ) {
 		$f_type = 1;
@@ -218,6 +221,9 @@
 	22: $f_show_version
 	23: $f_do_filter_by_date
 	24: $f_custom_field
+	25: $f_relationship_type
+	26: $f_relationship_bug
+	
 */
 	# Set new filter values.  These are stored in a cookie
 	$t_view_all_cookie_id = gpc_get_cookie( config_get( 'view_all_cookie' ), '' );
@@ -285,6 +291,8 @@
 				$t_setting_arr['view_state'] = $f_view_state;
 				$t_setting_arr['custom_fields'] = $f_custom_fields_data;
 				$t_setting_arr['sticky_issues'] = $f_sticky_issues;
+				$t_setting_arr['relationship_type'] = $f_relationship_type;
+				$t_setting_arr['relationship_bug'] = $f_relationship_bug;
 
 				break;
 		# Set the sort order and direction
@@ -317,6 +325,8 @@
 				$t_setting_arr['show_priority']	= array( '[any]' );
 				$t_setting_arr['fixed_in_version']	= array( '[any]' );
 				$t_setting_arr['user_monitor'] 		= array( '[any]' );
+				$t_setting_arr['relationship_type'] = "any";
+				$t_setting_arr['relationship_bug'] = 0;
 
 				$t_custom_fields 		= custom_field_get_ids();
 				$t_custom_fields_data 	= array();
Index: view_filters_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/view_filters_page.php,v
retrieving revision 1.28
diff -u -r1.28 view_filters_page.php
--- view_filters_page.php	12 Feb 2005 20:01:08 -0000	1.28
+++ view_filters_page.php	15 Feb 2005 17:13:27 -0000
@@ -11,6 +11,7 @@
 
 	require_once( $t_core_path.'compress_api.php' );
 	require_once( $t_core_path.'filter_api.php' );
+	require_once( $t_core_path.'relationship_api.php' );
 	require_once( $t_core_path.'current_user_api.php' );
 	require_once( $t_core_path.'bug_api.php' );
 	require_once( $t_core_path.'string_api.php' );
@@ -248,13 +249,14 @@
 	<td class="small-caption" colspan="<?php echo ( 1 * $t_custom_cols ); ?>"><?php echo lang_get( 'view_status' ) ?></td>
 	<td class="small-caption" colspan="<?php echo ( 1 * $t_custom_cols ); ?>"><?php echo lang_get( 'sticky' ) ?></td>
 	<td class="small-caption" colspan="<?php echo ( 1 * $t_custom_cols ); ?>"><?php echo lang_get( 'changed' ) ?></td>
-	<td class="small-caption" colspan="<?php echo ( 4 * $t_custom_cols ); ?>">
+	<td class="small-caption" colspan="<?php echo ( 2 * $t_custom_cols ); ?>">
 		<input type="checkbox" name="do_filter_by_date" <?php
 			check_checked( $t_filter['do_filter_by_date'], 'on' );
 			if ( ON == config_get( 'use_javascript' ) ) {
 				print "onclick=\"SwitchDateFields();\""; } ?> />
 		<?php echo lang_get( 'use_date_filters' ) ?>
 	</td>
+	<td class="small-caption" colspan="<?php echo ( 2 * $t_custom_cols ); ?>"><?php echo lang_get( 'bug_relationships' ) ?></td>
 </tr>
 <tr class="row-2">
 	<!-- Number of bugs per page -->
@@ -273,9 +275,12 @@
 	<td valign="top" colspan="<?php echo ( 1 * $t_custom_cols ); ?>">
 		<?php print_filter_highlight_changed(); ?>
 	</td>
-	<td valign="top" class="left" colspan="<?php echo ( 4 * $t_custom_cols ); ?>">
+	<td valign="top" class="left" colspan="<?php echo ( 2 * $t_custom_cols ); ?>">
 		<?php print_filter_do_filter_by_date( true ); # hide checkbox as it's already been shown ?>
 	</td>
+	<td valign="top" colspan="<?php echo ( 2 * $t_custom_cols ); ?>">
+        <?php print_filter_relationship_type(); ?>
+	</td>
 </tr>
 
 <?php
Index: core/filter_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/filter_api.php,v
retrieving revision 1.84
diff -u -r1.84 filter_api.php
--- core/filter_api.php	13 Feb 2005 21:36:37 -0000	1.84
+++ core/filter_api.php	15 Feb 2005 17:13:19 -0000
@@ -15,6 +15,7 @@
 	require_once( $t_core_dir . 'user_api.php' );
 	require_once( $t_core_dir . 'bug_api.php' );
 	require_once( $t_core_dir . 'collapse_api.php' );
+	require_once( $t_core_dir . 'relationship_api.php' );
 
 	###########################################################################
 	# Filter API
@@ -55,6 +56,7 @@
 		$t_project_table		= config_get( 'mantis_project_table' );
 		$t_bug_monitor_table	= config_get( 'mantis_bug_monitor_table' );
 		$t_limit_reporters		= config_get( 'limit_reporters' );
+		$t_bug_relationship_table	= config_get( 'mantis_bug_relationship_table' );
 		$t_report_bug_threshold		= config_get( 'report_bug_threshold' );
 
 		$t_current_user_id = auth_get_current_user_id();
@@ -507,6 +509,28 @@
 				array_push( $t_where_clauses, "( $t_table_name.user_id=$t_clauses[0] )" );
 			}
 		}
+		# bug relationship
+		$t_any_found = false;
+		$c_rel_type = $t_filter['relationship_type'];
+		$c_rel_bug = $t_filter['relationship_bug'];
+		if ( 'any' == $c_rel_type || '' == $c_rel_bug) {
+			$t_any_found = true;
+		}
+		echo ("relation type $c_rel_type");
+		if ( !$t_any_found ) {
+		    # use the complementary type
+		    $c_rel_type = relationship_get_complementary_type($c_rel_type);
+			$t_clauses = array();
+			$t_table_name = 'relationship';
+			array_push( $t_from_clauses, $t_bug_relationship_table );
+			array_push( $t_join_clauses, "LEFT JOIN $t_bug_relationship_table as $t_table_name ON $t_table_name.destination_bug_id = $t_bug_table.id" );
+			// get reverse relationships
+			if ( $c_rel_type == 1 ) array_push( $t_join_clauses, "LEFT JOIN $t_bug_relationship_table as $t_table_name"."2 ON $t_table_name"."2.source_bug_id = $t_bug_table.id" );
+ 			array_push( $t_clauses, "($t_table_name.relationship_type='$c_rel_type' AND $t_table_name.source_bug_id='$c_rel_bug')" );
+ 			// get reverse relationships
+			if ( $c_rel_type == 1 ) array_push( $t_clauses, "($t_table_name"."2.relationship_type='$c_rel_type' AND $t_table_name"."2.destination_bug_id='$c_rel_bug')" );
+			array_push( $t_where_clauses, '('. implode( ' OR ', $t_clauses ) .')' );
+		}
 
 		# custom field filters
 		if( ON == config_get( 'filter_by_custom_fields' ) ) {
@@ -1389,9 +1413,12 @@
 			<td class="small-caption" valign="top">
 				<a href="<?php PRINT $t_filters_url . 'highlight_changed'; ?>" id="highlight_changed_filter"><?php PRINT lang_get( 'changed' ) ?>:</a>
 			</td>
-			<td class="small-caption" valign="top" colspan="4">
+			<td class="small-caption" valign="top" colspan="2">
 				<a href="<?php PRINT $t_filters_url . 'do_filter_by_date'; ?>" id="do_filter_by_date_filter"><?php PRINT lang_get( 'use_date_filters' ) ?>:</a>
 			</td>
+			<td class="small-caption" valign="top" colspan="2">
+				<a href="<?php PRINT $t_filters_url . 'relationship_type'; ?>" id="relationship_type_filter"><?php PRINT lang_get( 'bug_relationships' ) ?>:</a>
+			</td>
 		</tr>
 		<tr class="row-1">
 			<td class="small-caption" valign="top" id="per_page_filter_target">
@@ -1418,7 +1445,7 @@
 				<?php PRINT $t_filter['highlight_changed']; ?>
 				<input type="hidden" name="highlight_changed" value="<?php echo $t_filter['highlight_changed'];?>" />
 			</td>
-			<td class="small-caption" valign="top" colspan="4" id="do_filter_by_date_filter_target">
+			<td class="small-caption" valign="top" colspan="2" id="do_filter_by_date_filter_target">
 							<?php
 							if ( 'on' == $t_filter['do_filter_by_date'] ) {
 								?>
@@ -1469,6 +1496,30 @@
 							}
 							?>
 			</td>
+
+			<td class="small-caption" valign="top" colspan="2" id="relationship_type_filter_target">
+							<?php
+								$t_output = '';
+								$t_any_found = false;
+								$c_rel_type = $t_filter['relationship_type'];
+								$c_rel_bug = $t_filter['relationship_bug'];
+								if ( '' == $c_rel_type || 0 == $c_rel_bug ) {
+									PRINT lang_get( 'any' );
+								} else {
+								    PRINT relationship_get_description_for_history ($c_rel_type) . ' ' . $c_rel_bug;
+								}
+
+							?>
+			</td>
+
+
+
+
+			<?php 
+				if ( $t_custom_cols > $t_filter_cols ) {
+					echo '<td colspan="' . ($t_custom_cols - $t_filter_cols) . '">&nbsp;</td>';
+				}
+			?>
 		</tr>
 		<?php
 
@@ -2385,6 +2436,18 @@
 		<?php
 	}
 
+	function print_filter_relationship_type(){
+		global $t_filter;
+		$c_reltype_value = $t_filter['relationship_type'];
+		if (!$c_reltype_value) {
+			$c_reltype_value = "any";
+		}
+		relationship_list_box ($c_reltype_value, "relationship_type", true); ?>
+		<input type="text" name="relationship_bug" size="5" maxlength="10" value="<?php echo $t_filter['relationship_bug']?>" />
+		<?php
+
+	}
+
 	function print_filter_custom_field($p_field_id){
 		global $t_filter, $t_accessible_custom_fields_names, $t_accessible_custom_fields_types, $t_accessible_custom_fields_values, $t_accessible_custom_fields_ids, $t_select_modifier;
 
Index: core/relationship_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/relationship_api.php,v
retrieving revision 1.29
diff -u -r1.29 relationship_api.php
--- core/relationship_api.php	18 Dec 2004 09:35:21 -0000	1.29
+++ core/relationship_api.php	14 Feb 2005 19:05:33 -0000
@@ -682,7 +682,17 @@
 
  	# --------------------
  	# print HTML relationship listbox
-	function relationship_list_box( $p_default_rel_type = -1 ) {
+	function relationship_list_box( $p_default_rel_type = -1, $p_select_name = "rel_type", $p_include_any = false) {
+?>
+<select name="<?php echo $p_select_name?>">
+<?php if ($p_include_any) { ?>
+<option value="any" <?php echo ( $p_default_rel_type == "any" ? ' selected' : '' ) ?>><?php echo lang_get( 'any' ) ?></option>
+<option value="any"></option>
+<?php 
+    } 
+    if ($p_default_rel_type == "any") {
+        $p_default_rel_type = -100;
+    }
 ?>
 <select name="rel_type">
 <option value="<?php echo BUG_RELATED ?>"<?php echo ( $p_default_rel_type == BUG_RELATED ? ' selected' : '' ) ?>><?php echo lang_get( 'related_to' ) ?></option>
