From 78c2c29efbd122a748b1606ef1f4bb9e1e20ae40 Mon Sep 17 00:00:00 2001 From: Chris Fitch Date: Fri, 30 Oct 2009 13:55:00 -0400 Subject: [PATCH] Add config option for filtering on disabled users diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 4a94956..883c7f0 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -2940,6 +2940,13 @@ */ $g_create_short_url = 'http://tinyurl.com/create.php?url=%s'; + /** + * Included disabled users in filters + * + * @global in $g_filter_on_disabled_users + */ + $g_filter_on_disabled_users = OFF; + /************************************* * MantisBT Database Table Variables * *************************************/ diff --git a/core/filter_api.php b/core/filter_api.php index 0d887df..7915820 100644 --- a/core/filter_api.php +++ b/core/filter_api.php @@ -3428,7 +3428,7 @@ function print_filter_reporter_id() { check_selected( $t_filter[FILTER_PROPERTY_REPORTER_ID], META_FILTER_MYSELF ); echo '>[' . lang_get( 'myself' ) . ']'; } - print_reporter_option_list( $t_filter[FILTER_PROPERTY_REPORTER_ID] ); + print_reporter_option_list( $t_filter[FILTER_PROPERTY_REPORTER_ID], null, (ON == config_get('filter_on_disabled_users')) ? true : false ); }?> @@ -3478,7 +3478,7 @@ function print_filter_handler_id() { echo '>[' . lang_get( 'myself' ) . ']'; } - print_assign_to_option_list( $t_filter[FILTER_PROPERTY_HANDLER_ID] ); + print_assign_to_option_list( $t_filter[FILTER_PROPERTY_HANDLER_ID], null, null, (ON == config_get('filter_on_disabled_users')) ? true : false ); }?> [' . lang_get( 'myself' ) . ']'; } - print_note_option_list( $t_filter[FILTER_PROPERTY_NOTE_USER_ID] ); + print_note_option_list( $t_filter[FILTER_PROPERTY_NOTE_USER_ID], null, null, (ON == config_get('filter_on_disabled_users')) ? true : false ); } ?> diff --git a/core/print_api.php b/core/print_api.php index 471a1a6..cbe8d72 100644 --- a/core/print_api.php +++ b/core/print_api.php @@ -210,14 +210,14 @@ function print_captcha_input( $p_field_name ) { # This populates an option list with the appropriate users by access level # # @todo from print_reporter_option_list -function print_user_option_list( $p_user_id, $p_project_id = null, $p_access = ANYBODY ) { +function print_user_option_list( $p_user_id, $p_project_id = null, $p_access = ANYBODY, $p_show_disabled_users = false ) { $t_users = array(); if( null === $p_project_id ) { $p_project_id = helper_get_current_project(); } - $t_users = project_get_all_user_rows( $p_project_id, $p_access ); + $t_users = project_get_all_user_rows( $p_project_id, $p_access, true, $p_show_disabled_users ); # handles ALL_PROJECTS case @@ -260,8 +260,8 @@ function print_user_option_list( $p_user_id, $p_project_id = null, $p_access = A # actually reported the bugs at the time. Maybe we could get all user # who are listed as the reporter in any bug? It would probably be a # faster query actually. -function print_reporter_option_list( $p_user_id, $p_project_id = null ) { - print_user_option_list( $p_user_id, $p_project_id, config_get( 'report_bug_threshold' ) ); +function print_reporter_option_list( $p_user_id, $p_project_id = null, $p_show_disabled_users = false ) { + print_user_option_list( $p_user_id, $p_project_id, config_get( 'report_bug_threshold' ), $p_show_disabled_users ); } /** @@ -441,22 +441,22 @@ function print_news_string_by_news_id( $p_news_id ) { } # -------------------- -function print_assign_to_option_list( $p_user_id = '', $p_project_id = null, $p_threshold = null ) { +function print_assign_to_option_list( $p_user_id = '', $p_project_id = null, $p_threshold = null, $p_show_disabled_users = false ) { if( null === $p_threshold ) { $p_threshold = config_get( 'handle_bug_threshold' ); } - print_user_option_list( $p_user_id, $p_project_id, $p_threshold ); + print_user_option_list( $p_user_id, $p_project_id, $p_threshold, $p_show_disabled_users ); } -function print_note_option_list( $p_user_id = '', $p_project_id = null, $p_threshold = null ) { +function print_note_option_list( $p_user_id = '', $p_project_id = null, $p_threshold = null, $p_show_disabled_users = false ) { if( null === $p_threshold ) { $p_threshold = config_get( 'add_bugnote_threshold' ); } - print_user_option_list( $p_user_id, $p_project_id, $p_threshold ); + print_user_option_list( $p_user_id, $p_project_id, $p_threshold, $p_show_disabled_users ); } /** diff --git a/core/project_api.php b/core/project_api.php index b2aa60f..518ad8d 100644 --- a/core/project_api.php +++ b/core/project_api.php @@ -497,7 +497,7 @@ function project_get_local_user_rows( $p_project_id ) { # higher than the given value. # if the first parameter is given as 'ALL_PROJECTS', return the global access level (without # any reference to the specific project -function project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_level = ANYBODY, $p_include_global_users = true ) { +function project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_level = ANYBODY, $p_include_global_users = true, $p_include_disabled_users = false ) { $c_project_id = db_prepare_int( $p_project_id ); # Optimization when access_level is NOBODY @@ -568,10 +568,14 @@ function project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_leve if( $p_include_global_users ) { $query = "SELECT id, username, realname, access_level FROM $t_user_table - WHERE enabled = " . db_param() . " - AND access_level $t_global_access_clause"; + WHERE access_level $t_global_access_clause"; + if ( !$p_include_disabled_users ) { + $query .= " AND enabled = " . db_param(); + $result = db_query_bound( $query, Array( $t_on ) ); + } else { + $result = db_query_bound( $query ); + } - $result = db_query_bound( $query, Array( $t_on ) ); $t_row_count = db_num_rows( $result ); for( $i = 0;$i < $t_row_count;$i++ ) { $row = db_fetch_array( $result ); @@ -585,10 +589,14 @@ function project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_leve $query = "SELECT u.id, u.username, u.realname, l.access_level FROM $t_project_user_list_table l, $t_user_table u WHERE l.user_id = u.id - AND u.enabled = " . db_param() . " AND l.project_id = " . db_param(); + if ( !$p_include_disabled_users ) { + $query .= " AND u.enabled = " . db_param(); + $result = db_query_bound( $query, Array( $c_project_id, $t_on ) ); + } else { + $result = db_query_bound( $query, Array( $c_project_id ) ); + } - $result = db_query_bound( $query, Array( $t_on, $c_project_id ) ); $t_row_count = db_num_rows( $result ); for( $i = 0;$i < $t_row_count;$i++ ) { $row = db_fetch_array( $result ); -- 1.6.0.4