From 0481e8c5eb6846c9c26d2cc6f7865fe6b52c6a20 Mon Sep 17 00:00:00 2001 From: narcissus Date: Tue, 15 Jun 2004 07:27:16 +0000 Subject: [PATCH] Fix #3937: Custom field filters now only show those values relevant to the selected project. git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2605 f5dc347c-c33d-0410-90a0-b07cc1902cb9 --- core/custom_field_api.php | 17 ++++++++++++----- doc/ChangeLog | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/core/custom_field_api.php b/core/custom_field_api.php index 7316930655..ea5aeb4ade 100644 --- a/core/custom_field_api.php +++ b/core/custom_field_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: custom_field_api.php,v 1.32 2004-04-08 22:44:59 prescience Exp $ + # $Id: custom_field_api.php,v 1.33 2004-06-15 07:27:15 narcissus Exp $ # -------------------------------------------------------- $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; @@ -774,10 +774,12 @@ function custom_field_validate( $p_field_id, $p_value ) { # -------------------- # Get All Possible Values for a Field. - function custom_field_distinct_values( $p_field_id ) { + function custom_field_distinct_values( $p_field_id, $p_project_id = ALL_PROJECTS ) { $c_field_id = db_prepare_int( $p_field_id ); + $c_project_id = db_prepare_int( $p_project_id ); $t_custom_field_string_table = config_get( 'mantis_custom_field_string_table' ); $t_custom_field_table = config_get( 'mantis_custom_field_table' ); + $t_mantis_bug_table = config_get( 'mantis_bug_table' ); $t_return_arr = array(); $query = "SELECT type, possible_values @@ -799,9 +801,14 @@ function custom_field_distinct_values( $p_field_id ) { array_push( $t_return_arr, $t_option ); } } else { - $query2 = "SELECT value FROM $t_custom_field_string_table - WHERE field_id='$c_field_id' - GROUP BY value"; + $t_where = ''; + if ( ALL_PROJECTS != $p_project_id ) { + $t_where = " AND $t_mantis_bug_table.id = $t_custom_field_string_table.bug_id AND + $t_mantis_bug_table.project_id = '$p_project_id'"; + } + $query2 = "SELECT $t_custom_field_string_table.value FROM $t_custom_field_string_table, $t_mantis_bug_table + WHERE $t_custom_field_string_table.field_id='$c_field_id' $t_where + GROUP BY $t_custom_field_string_table.value"; $result2 = db_query( $query2 ); $t_row_count = db_num_rows( $result2 ); if ( 0 == $t_row_count ) { diff --git a/doc/ChangeLog b/doc/ChangeLog index 78f20d97c4..93abe72276 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -60,6 +60,7 @@ Mantis ChangeLog * Fix #3924: Graphs did not show query counts when flag was set. * Fix #3926: "Copy Issue" reset date submitted. * Fix #3928: "Copy Issue" did not copy attachments (plus other values). + * Fix #3937: Custom field filters now only show those values relevant to the selected project. * New Config: set_view_status_threshold (default REPORTER) - threshold needed to set the view status while reporting a bug / bugnote. * New Config: change_view_status_threshold (default UPDATER) - threshold needed to update the view status while updating a bug / bugnote. * New Config: view_handler_threshold (default VIEWER) - threshold needed to view the bug handler (now works for emails only).