--- ./mantis-0.18.2/core/print_api.php 2004-02-05 03:17:12.000000000 +0100 +++ ./mantis-0.18.2-BEG/core/print_api.php 2004-04-05 17:44:31.000000000 +0200 @@ -168,14 +168,8 @@ # -------------------- # ugly functions need to be refactored # This populates the reporter option list with the appropriate users - # - # @@@ This function really ought to print out all the users, I think. - # I just encountered a situation where a project used to be public and - # was made private, so now I can't filter on any of the reporters who - # 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 ) { + $t_user_id = auth_get_current_user_id(); $t_users = array(); if ( null === $p_project_id ) { @@ -184,33 +178,40 @@ # if current user is a reporter, and limited reports set to ON. if ( ( ON == config_get( 'limit_reporters' ) ) && ( current_user_get_access_level() <= config_get( 'report_bug_threshold' ) ) ) { - $t_user['id'] = auth_get_current_user_id(); + $t_user['id'] = $t_user_id; $t_user['username'] = user_get_field( $t_user['id'], 'username' ); $t_users[] = $t_user; } else # checking if it's per project or all projects if ( ALL_PROJECTS == $p_project_id ) { - $t_adm = ADMINISTRATOR; - $t_rep = config_get( 'report_bug_threshold' ); $t_pub = VS_PUBLIC; $t_prv = VS_PRIVATE; $t_user_table = config_get( 'mantis_user_table' ); + $t_bug_table = config_get( 'mantis_bug_table' ); $t_project_user_list_table = config_get( 'mantis_project_user_list_table' ); $t_project_table = config_get( 'mantis_project_table' ); - $query = "SELECT DISTINCT u.id, u.username - FROM $t_user_table u, - $t_project_user_list_table l, - $t_project_table p - WHERE ((p.view_state='$t_pub' - AND u.access_level>='$t_rep') OR - (l.access_level>='$t_rep' AND - l.user_id=u.id) OR - u.access_level>='$t_adm') AND - p.id=l.project_id - ORDER BY u.username"; + if ( true == current_user_is_administrator( ) ) { + # all users who reported on any project + $query = "SELECT DISTINCT user.id, user.username + FROM $t_user_table AS user + INNER JOIN $t_bug_table AS bug ON user.id = bug.reporter_id + ORDER BY user.username"; + } + else { + # all users who reported on any public Project + # all users who reported on any project the current user has access to + $query = "SELECT DISTINCT user.id, user.username + FROM $t_user_table AS user + INNER JOIN $t_bug_table AS bug ON user.id = bug.reporter_id + INNER JOIN $t_project_table AS project ON bug.project_id = project.id + LEFT JOIN $t_project_user_list_table AS project_user ON project.id = project_user.project_id + WHERE project.view_state='$t_pub' OR project_user.user_id = '$t_user_id' + ORDER BY user.username"; + } + $result = db_query( $query ); $user_count = db_num_rows( $result ); for ( $i=0 ; $i < $user_count ; $i++ ) { @@ -301,6 +302,7 @@ } # -------------------- function print_assign_to_option_list( $p_user_id='', $p_project_id = null ) { + $t_user_id = auth_get_current_user_id(); $t_users = array(); if ( null === $p_project_id ) { @@ -309,26 +311,32 @@ # checking if it's per project or all projects if ( ALL_PROJECTS == $p_project_id ) { - $t_adm = ADMINISTRATOR; - $t_dev = config_get( 'handle_bug_threshold' ); $t_pub = VS_PUBLIC; $t_prv = VS_PRIVATE; + $t_bug_table = config_get( 'mantis_bug_table' ); $t_user_table = config_get( 'mantis_user_table' ); $t_project_user_list_table = config_get( 'mantis_project_user_list_table' ); $t_project_table = config_get( 'mantis_project_table' ); - $query = "SELECT DISTINCT u.id, u.username - FROM $t_user_table u, - $t_project_user_list_table l, - $t_project_table p - WHERE ((p.view_state='$t_pub' AND - u.access_level>='$t_dev') OR - (l.access_level>='$t_dev' AND - l.user_id=u.id) OR - u.access_level>='$t_adm') AND - p.id = l.project_id - ORDER BY u.username"; + if ( true == current_user_is_administrator( ) ) { + # all users who are assigned to any project + $query = "SELECT DISTINCT user.id, user.username + FROM $t_user_table AS user + INNER JOIN $t_bug_table AS bug ON user.id = bug.handler_id + ORDER BY user.username"; + } + else { + # all users who are assigned to any public project + # all users who are assigned to any project the current user has access to + $query = "SELECT DISTINCT user.id, user.username + FROM $t_user_table AS user + INNER JOIN $t_bug_table AS bug ON user.id = bug.handler_id + INNER JOIN $t_project_table AS project ON bug.project_id = project.id + LEFT JOIN $t_project_user_list_table AS project_user ON project.id = project_user.project_id + WHERE project.view_state='$t_pub' OR project_user.user_id = '$t_user_id' + ORDER BY user.username"; + } $result = db_query( $query ); $user_count = db_num_rows( $result ); for ( $i=0 ; $i < $user_count ; $i++ ) {