Skip to content

Commit

Permalink
Modified reporter and assign_to option lists.
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@991 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Kenzaburo Ito committed May 20, 2002
1 parent cda25b8 commit 35e3836
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 39 deletions.
63 changes: 62 additions & 1 deletion core_email_API.php
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core_html_API.php
Expand Up @@ -300,7 +300,7 @@ function print_menu() {
PRINT "<a href=\"$g_main_page\">$s_main_link</a> | ";
PRINT "<a href=\"$g_view_all_bug_page\">$s_view_bugs_link</a> | ";
$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 "<a href=\"$t_report_url\">$s_report_bug_link</a> | ";
Expand Down
196 changes: 159 additions & 37 deletions core_print_API.php
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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 "<option value=\"$v_id\" SELECTED>$v_username</option>";
} else {
PRINT "<option value=\"$v_id\">$v_username</option>";
}
} # end for
} # end foreach
}
# --------------------
function print_duplicate_id_option_list() {
Expand Down Expand Up @@ -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
Expand All @@ -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 "<option value=\"$v_id\" SELECTED>$v_username</option>";
} else {
PRINT "<option value=\"$v_id\">$v_username</option>";
}
} # end for
} # end foreach
}
# --------------------
# List projects that the current user has access to
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeLog
Expand Up @@ -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().
Expand Down

0 comments on commit 35e3836

Please sign in to comment.