From 35e3836646041d4b5aafcc3becda4267ec46a485 Mon Sep 17 00:00:00 2001 From: Kenzaburo Ito Date: Mon, 20 May 2002 01:31:17 +0000 Subject: [PATCH] Modified reporter and assign_to option lists. git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@991 f5dc347c-c33d-0410-90a0-b07cc1902cb9 --- core_email_API.php | 63 ++++++++++++++- core_html_API.php | 2 +- core_print_API.php | 196 ++++++++++++++++++++++++++++++++++++--------- doc/ChangeLog | 1 + 4 files changed, 223 insertions(+), 39 deletions(-) diff --git a/core_email_API.php b/core_email_API.php index f8827c5f3a..4170f6c545 100644 --- a/core_email_API.php +++ b/core_email_API.php @@ -98,6 +98,66 @@ function build_bcc_list( $p_bug_id, $p_notify_type ) { $t_adm = ADMINISTRATOR; $t_public = PUBLIC; + #@@@@@@@ + $temp_arr = array(); + # grab the administrators + $query = "SELECT id, email + FROM $g_mantis_user_table + ORDER BY username"; + $result = db_query( $query ); + $user_count = db_num_rows( $result ); + for ($i=0;$i<$user_count;$i++) { + $row = db_fetch_array( $result ); + extract( $row, EXTR_PREFIX_ALL, "v" ); + $temp_arr[$v_email] = array( $v_email, $v_id ); + } + + foreach ( $temp_arr as $key => $val ) { + $v_id = $val[1]; + $v_email = $val[0]; + + # always add all administrators + $t_access_level = get_user_field( $v_id, "access_level" ); + if ( ADMINISTRATOR == $t_access_level ) { + $send_arr[] = $v_email; + continue; + } + + # see if users belong + $t_project_view_state = get_project_field( $g_project_cookie_val, "view_state" ); + if ( PUBLIC == $t_project_view_state ) { + $query = "SELECT l.access_level + FROM $g_mantis_project_user_list_table l, + $g_mantis_project_table p + WHERE l.project_id='$t_project_id' AND + p.id=l.project_id AND + l.user_id='$v_id'"; + $result = db_query( $query ); + $count = db_num_rows( $result ); + if ( $count > 0 ){ + $t_access_level = db_result( $result ); + } + if ( $t_access_level >= DEVELOPER ) { + $send_arr[] = $v_email; + } + + } else { + $query = "SELECT COUNT(*) + FROM $g_mantis_project_user_list_table l, + $g_mantis_project_table p + WHERE l.project_id='$t_project_id' AND + p.id=l.project_id AND + l.user_id='$v_id' AND + l.access_level>='$t_dev'"; + $result = db_query( $query ); + $count = db_result( $result, 0, 0 ); + if ( $count > 0 ) { + $send_arr[] = $v_email; + continue; + } + } + } + /*#@@@@@@@@@@@@ # grab all the ADMINISTRATORS $query = "SELECT DISTINCT id, email FROM $g_mantis_user_table @@ -151,7 +211,7 @@ function build_bcc_list( $p_bug_id, $p_notify_type ) { if ( ON == $t_notify ) { $send_arr[] = $row["email"]; } - } # end DEVELOPERS + } # end DEVELOPERS*/ } # end NEW bug developer section # grab all users MONITORING bug @@ -179,6 +239,7 @@ function build_bcc_list( $p_bug_id, $p_notify_type ) { foreach ( $send_arr as $send_val ) { $t_bcc .= $send_val.", "; } + # chop off the last comma and add a \n if ( strlen( $t_bcc ) > 5 ) { return substr( $t_bcc, 0, strlen( $t_bcc )-2).(($g_use_bcc) ? "\n" : ""); ## win-bcc-bug diff --git a/core_html_API.php b/core_html_API.php index 4c4a720865..79c85c36f5 100644 --- a/core_html_API.php +++ b/core_html_API.php @@ -300,7 +300,7 @@ function print_menu() { PRINT "$s_main_link | "; PRINT "$s_view_bugs_link | "; $t_project_status = get_project_field( $g_project_cookie_val, "status" ); - if (( access_level_check_greater_or_equal( REPORTER ) )&&( 70 != $t_project_status )) { + if ( access_level_check_greater_or_equal( REPORTER ) ) { if ( "0000000" != $g_project_cookie_val ) { $t_report_url = get_report_redirect_url( 1 ); PRINT "$s_report_bug_link | "; diff --git a/core_print_API.php b/core_print_API.php index cd968e67df..37ad320a47 100644 --- a/core_print_API.php +++ b/core_print_API.php @@ -106,6 +106,21 @@ function print_duplicate_id( $p_duplicate_id ) { # Option List Printing API ########################################################################### # -------------------- + # sorts the array by the first element of the array element + # @@@ might not be used + function cmp( $p_var1, $p_var2 ) { + if ( $p_var1[0][0] == $p_var2[0][0] ) { + return 0; + } + if ( $p_var1[0][0] < $p_var2[0][0] ) { + return -1; + } else { + return 1; + } + } + # -------------------- + # ugly functions need to be refactored + # This populates the reporter option list with the appropriate users function print_reporter_option_list( $p_user_id ) { global $g_mantis_user_table, $g_mantis_project_user_list_table, $g_mantis_project_table, $g_project_cookie_val; @@ -114,6 +129,7 @@ function print_reporter_option_list( $p_user_id ) { $t_rep = REPORTER; $t_pub = PUBLIC; $t_prv = PRIVATE; + $user_arr = array(); # checking if it's per project or all projects # 0 is all projects @@ -128,31 +144,84 @@ function print_reporter_option_list( $p_user_id ) { l.user_id=u.id) OR u.access_level>='$t_adm' ORDER BY u.username"; + $result = db_query( $query ); + $user_count = db_num_rows( $result ); + for ($i=0;$i<$user_count;$i++) { + $row = db_fetch_array( $result ); + extract( $row, EXTR_PREFIX_ALL, "v" ); + $user_arr[$v_username] = array( $v_username, $v_id ); + } } else { - $query = "SELECT DISTINCT u.id, u.username, u.email - FROM $g_mantis_user_table u, - $g_mantis_project_user_list_table l, - $g_mantis_project_table p - WHERE (p.view_state='$t_pub' AND - u.access_level>='$t_rep' AND - p.id='$g_project_cookie_val') OR - (l.access_level>='$t_rep' AND - l.user_id=u.id AND - l.project_id='$g_project_cookie_val') OR - u.access_level>='$t_adm' - ORDER BY u.username"; + $temp_arr = array(); + # grab the administrators + $query = "SELECT id, username + FROM $g_mantis_user_table + ORDER BY username"; + $result = db_query( $query ); + $user_count = db_num_rows( $result ); + for ($i=0;$i<$user_count;$i++) { + $row = db_fetch_array( $result ); + extract( $row, EXTR_PREFIX_ALL, "v" ); + $temp_arr[$v_username] = array( $v_username, $v_id ); + } + + foreach ( $temp_arr as $key => $val ) { + $v_id = $val[1]; + $v_username = $val[0]; + + # always add all administrators + $t_access_level = get_user_field( $v_id, "access_level" ); + if ( ADMINISTRATOR == $t_access_level ) { + $user_arr[$v_username] = array( $v_username, $v_id ); + continue; + } + + # see if users belong + $t_project_view_state = get_project_field( $g_project_cookie_val, "view_state" ); + if ( PUBLIC == $t_project_view_state ) { + $query = "SELECT l.access_level + FROM $g_mantis_project_user_list_table l, + $g_mantis_project_table p + WHERE l.project_id='$g_project_cookie_val' AND + p.id=l.project_id AND + l.user_id='$v_id'"; + $result = db_query( $query ); + $count = db_num_rows( $result ); + if ( $count > 0 ){ + $t_access_level = db_result( $result ); + } + if ( $t_access_level >= REPORTER ) { + $user_arr[$v_username] = array( $v_username, $v_id ); + } + + } else { + $query = "SELECT COUNT(*) + FROM $g_mantis_project_user_list_table l, + $g_mantis_project_table p + WHERE l.project_id='$g_project_cookie_val' AND + p.id=l.project_id AND + l.user_id='$v_id' AND + l.access_level>='$t_rep'"; + $result = db_query( $query ); + $count = db_result( $result, 0, 0 ); + if ( $count > 0 ) { + $user_arr[$v_username] = array( $v_username, $v_id ); + continue; + } + } + } } - $result = db_query( $query ); - $user_count = db_num_rows( $result ); - for ($i=0;$i<$user_count;$i++) { - $row = db_fetch_array( $result ); - extract( $row, EXTR_PREFIX_ALL, "v" ); + + asort( $user_arr ); + foreach ( $user_arr as $key => $val ) { + $v_id = $val[1]; + $v_username = $val[0]; if ( $v_id == $p_user_id ) { PRINT ""; } else { PRINT ""; } - } # end for + } # end foreach } # -------------------- function print_duplicate_id_option_list() { @@ -225,6 +294,7 @@ function print_assign_to_option_list( $p_id="" ) { $t_dev = DEVELOPER; $t_pub = PUBLIC; $t_prv = PRIVATE; + $user_arr = array(); # checking if it's per project or all projects # 0 is all projects @@ -239,32 +309,84 @@ function print_assign_to_option_list( $p_id="" ) { l.user_id=u.id) OR u.access_level>='$t_adm' ORDER BY u.username"; + $result = db_query( $query ); + $user_count = db_num_rows( $result ); + for ($i=0;$i<$user_count;$i++) { + $row = db_fetch_array( $result ); + extract( $row, EXTR_PREFIX_ALL, "v" ); + $user_arr[$v_username] = array( $v_username, $v_id ); + } } else { - $query = "SELECT DISTINCT u.id, u.username, u.email - FROM $g_mantis_user_table u, - $g_mantis_project_user_list_table l, - $g_mantis_project_table p - WHERE (p.view_state='$t_pub' AND - u.access_level>='$t_dev' AND - p.id='$g_project_cookie_val') OR - (l.access_level>='$t_dev' AND - l.user_id=u.id AND - l.project_id='$g_project_cookie_val') OR - u.access_level>='$t_adm' - ORDER BY u.username"; + $temp_arr = array(); + # grab the administrators + $query = "SELECT id, username + FROM $g_mantis_user_table + ORDER BY username"; + $result = db_query( $query ); + $user_count = db_num_rows( $result ); + for ($i=0;$i<$user_count;$i++) { + $row = db_fetch_array( $result ); + extract( $row, EXTR_PREFIX_ALL, "v" ); + $temp_arr[$v_username] = array( $v_username, $v_id ); + } + + foreach ( $temp_arr as $key => $val ) { + $v_id = $val[1]; + $v_username = $val[0]; + + # always add all administrators + $t_access_level = get_user_field( $v_id, "access_level" ); + if ( ADMINISTRATOR == $t_access_level ) { + $user_arr[$v_username] = array( $v_username, $v_id ); + continue; + } + + # see if users belong + $t_project_view_state = get_project_field( $g_project_cookie_val, "view_state" ); + if ( PUBLIC == $t_project_view_state ) { + $query = "SELECT l.access_level + FROM $g_mantis_project_user_list_table l, + $g_mantis_project_table p + WHERE l.project_id='$g_project_cookie_val' AND + p.id=l.project_id AND + l.user_id='$v_id'"; + $result = db_query( $query ); + $count = db_num_rows( $result ); + if ( $count > 0 ){ + $t_access_level = db_result( $result ); + } + if ( $t_access_level >= DEVELOPER ) { + $user_arr[$v_username] = array( $v_username, $v_id ); + } + + } else { + $query = "SELECT COUNT(*) + FROM $g_mantis_project_user_list_table l, + $g_mantis_project_table p + WHERE l.project_id='$g_project_cookie_val' AND + p.id=l.project_id AND + l.user_id='$v_id' AND + l.access_level>='$t_dev'"; + $result = db_query( $query ); + $count = db_result( $result, 0, 0 ); + if ( $count > 0 ) { + $user_arr[$v_username] = array( $v_username, $v_id ); + continue; + } + } + } } - $result = db_query( $query ); - $user_count = db_num_rows( $result ); - for ($i=0;$i<$user_count;$i++) { - $row = db_fetch_array( $result ); - extract( $row, EXTR_PREFIX_ALL, "v" ); - if ( $v_id == $p_id ) { + asort( $user_arr ); + foreach ( $user_arr as $key => $val ) { + $v_id = $val[1]; + $v_username = $val[0]; + if ( $v_id == $p_user_id ) { PRINT ""; } else { PRINT ""; } - } # end for + } # end foreach } # -------------------- # List projects that the current user has access to diff --git a/doc/ChangeLog b/doc/ChangeLog index 6db295b1e0..b1048e2055 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -15,6 +15,7 @@ Mantis * Modified core_API.php to always turn magic_quotes_runtime OFF. * Modified disk uploads to use the file_download.php script. * Modified bugnote last_modified query slightly. + * Modified reporter and assign_to option lists. * Updated PHP and MySQL requirements. * Updated Norwegian, Russian, Danish and Dutch translations. * Added die to print_header_redirect().