--- core/bug_api.php Fri Feb 13 10:33:21 2009 +++ core/bug_api.php Wed May 27 14:27:42 2009 @@ -646,7 +646,7 @@ } $query = "INSERT INTO $t_mantis_bug_file_table - ( bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content ) + ( bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, patch, obsolete, user_id ) VALUES ( '$t_new_bug_id', '" . db_prepare_string( $t_bug_file['title'] ) . "', '" . db_prepare_string( $t_bug_file['description'] ) . "', @@ -656,7 +656,10 @@ '" . db_prepare_int( $t_bug_file['filesize'] ) . "', '" . db_prepare_string( $t_bug_file['file_type'] ) . "', '" . db_prepare_string( $t_bug_file['date_added'] ) . "', - '" . db_prepare_string( $t_bug_file['content'] ) . "');"; + '" . db_prepare_string( $t_bug_file['content'] ) . "', + '" . db_prepare_string( $t_bug_file['patch'] ) . "', + '" . db_prepare_string( $t_bug_file['obsolete'] ) . "', + '" . db_prepare_string( $t_bug_file['user_id'] ) . "');"; db_query( $query ); } } @@ -1132,7 +1135,7 @@ $t_bug_file_table = config_get( 'mantis_bug_file_table' ); - $query = "SELECT id, title, diskfile, filename, filesize, file_type, date_added + $query = "SELECT id, title, diskfile, filename, filesize, file_type, date_added, patch, obsolete, user_id, description FROM $t_bug_file_table WHERE bug_id='$c_bug_id' ORDER BY date_added"; --- bug_file_add.php Fri Feb 13 10:33:25 2009 +++ bug_file_add.php Wed May 27 13:42:33 2009 @@ -33,6 +33,15 @@ $f_bug_id = gpc_get_int( 'bug_id', -1 ); $f_file = gpc_get_file( 'file', -1 ); + $f_action = gpc_get_int( 'action', -1 ); + $f_field = gpc_get_string( 'field', ''); + $f_file_id = gpc_get_int( 'file_id', -1 ); + $f_description = gpc_get( 'description', '' ); + $f_patch = gpc_get_bool( 'patch', 0 ); + $f_obsolete = gpc_get_bool( 'obsolete', 0 ); + + $t_user_id = auth_get_current_user_id(); + if ( $f_bug_id == -1 && $f_file == -1 ) { # _POST/_FILES does not seem to get populated if you exceed size limit so check if bug_id is -1 @@ -45,6 +54,7 @@ access_ensure_bug_level( config_get( 'upload_bug_file_threshold' ), $f_bug_id ); + if ( $f_action == -1 || $f_file_id == -1 ) { $t_bug = bug_get( $f_bug_id, true ); if( $t_bug->project_id != helper_get_current_project() ) { # in case the current project is not the same project of the bug we are viewing... @@ -53,8 +63,11 @@ } $f_file_error = ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0; - file_add( $f_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'bug', $f_file_error ); - + file_add( $f_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], + 'bug', $f_file_error, '', $f_description, $f_patch, $f_obsolete, $t_user_id ); + } else { + file_mark( $f_file_id, $f_field, $f_action, $f_bug_id ); + } # Determine which view page to redirect back to. $t_redirect_url = string_get_bug_view_url( $f_bug_id ); --- bug_file_upload_inc.php Fri Feb 13 10:33:24 2009 +++ bug_file_upload_inc.php Wed May 27 16:14:19 2009 @@ -49,6 +49,34 @@ echo lang_get( 'upload_file' ) ?> + + +reporter_id == auth_get_current_user_id() ) || access_has_bug_level( config_get( 'view_attachments_threshold' ), $f_bug_id ); + + if ( $t_show_attachments ) { +?> + + + + + + + + +
@@ -59,6 +87,22 @@ + + + + + + + + + + + + + + + + --- bug_report.php Thu Mar 19 16:09:58 2009 +++ bug_report.php Wed May 27 14:18:15 2009 @@ -54,7 +54,9 @@ $t_bug_data->additional_information = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) ); $f_file = gpc_get_file( 'file', null ); #@@@ (thraxisp) Note that this always returns a structure - # size = 0, if no file + + $f_file_description = gpc_get_string( 'file_description', '' ); + $f_file_patch = gpc_get_bool( 'patch', 0 ); # size = 0, if no file $f_report_stay = gpc_get_bool( 'report_stay', false ); $t_bug_data->project_id = gpc_get_int( 'project_id' ); # Patch to keep the original reporter @@ -166,7 +168,9 @@ # Handle the file upload if ( !is_blank( $f_file['tmp_name'] ) && ( 0 < $f_file['size'] ) ) { $f_file_error = ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0; - file_add( $t_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'bug', $f_file_error ); + file_add( $t_bug_id, $f_file['tmp_name'], $f_file['name'], + $f_file['type'], 'bug', $f_file_error, + '', $f_file_description, $f_file_patch, 0, $t_bug_data->reporter_id); } # Handle custom field submission --- bug_report_advanced_page.php Wed Jan 07 20:01:38 2009 +++ bug_report_advanced_page.php Wed May 27 13:42:33 2009 @@ -517,6 +517,23 @@ name="file" type="file" size="60" /> +> + + + + + + + +> + + + + + + + + --- bug_report_page.php Tue Jan 06 14:29:51 2009 +++ bug_report_page.php Wed May 27 13:42:33 2009 @@ -427,6 +427,23 @@ name="file" type="file" size="60" /> +> + + + + + + + +> + + + + + + + + --- bug_view_advanced_page.php Fri Feb 13 10:33:24 2009 +++ bug_view_advanced_page.php Wed May 27 13:42:33 2009 @@ -538,7 +538,7 @@ - + --- bug_view_page.php Fri Feb 13 10:33:25 2009 +++ bug_view_page.php Wed May 27 13:42:33 2009 @@ -446,7 +446,7 @@ - + --- config_defaults_inc.php Thu Jan 22 16:05:38 2009 +++ config_defaults_inc.php Wed May 27 13:42:33 2009 @@ -848,6 +848,15 @@ # absolute path to the default upload folder. Requires trailing / or \ $g_absolute_path_default_upload_folder = ''; + + + # access level needed to mark file obsolete + # reporter can always mark file as an obsolete (aka request for remove) + $g_allow_mark_obsolete_threshold = DEVELOPER; + + # access level needed to mark file patch + # reporter can always mark file as a patch + $g_allow_mark_patch_threshold = DEVELOPER; ############################ # Mantis HTML Settings --- config_inc.php Fri Feb 13 10:33:24 2009 +++ config_inc.php Tue May 26 16:04:38 2009 @@ -29,9 +29,9 @@ # set these values to match your setup $g_hostname = "localhost"; $g_db_type = 'mysql'; - $g_database_name = "mantis"; - $g_db_username = "mantis"; - $g_db_password = "mantis"; + $g_database_name = "mantis111"; + $g_db_username = "mantis111"; + $g_db_password = "mantis111"; # --- email variables ------------- $g_administrator_email = 'mantis@cscanada.ca'; @@ -44,7 +44,7 @@ # Patch to allow real name in FROM field in email notification # Mantis Issue 7546 # start - $g_from_name = 'CS Canada Mantis Bug Tracker'; + $g_from_name = 'PC 10 Mantis v1.1.1 branch Test Setup'; # end @@ -83,9 +83,9 @@ # --- Configuration : Display -------- #This is the browser window title ( tag). - $g_window_title = "CS Canada Issues Tracker"; + $g_window_title = "PC 10 Mantis v1.1.1 branch Test Setup"; #This is a heading that is displayed in the viewing area of the page. - $g_page_title = "CS Canada"; + $g_page_title = "PC 10 Mantis v1.1.1 branch"; #This option is used as a default value for user preferences. #This field indicates whether users should get the simple bug report page, #or the advanced bug report page, or both. Possible values are: --- core/file_api.php Fri Feb 13 10:33:21 2009 +++ core/file_api.php Wed May 27 17:26:06 2009 @@ -129,15 +129,24 @@ # -------------------- # Check if the current user can delete attachments from the specified bug. - function file_can_delete_bug_attachments( $p_bug_id ) { + function file_can_delete_bug_attachments( $p_bug_id, $p_file_id = 0 ) { if ( bug_is_readonly( $p_bug_id ) ) { return false; } $t_reported_by_me = bug_is_user_reporter( $p_bug_id, auth_get_current_user_id() ); $t_can_download = access_has_bug_level( config_get( 'delete_attachments_threshold' ), $p_bug_id ); + + if ( $p_file_id > 0 ) { + $t_owned_by_me = file_is_user_owner( $p_file_id, auth_get_current_user_id() ); + } # @@@ Fix this to be readable + if ( $p_file_id > 0 ) { + $t_can_download = $t_can_download || ( $t_owned_by_me && config_get( 'allow_delete_own_attachments' ) ); + } else { + # left due to compatibility reasons. should be removed. $t_can_download = $t_can_download || ( $t_reported_by_me && config_get( 'allow_delete_own_attachments' ) ); + } return $t_can_download; } @@ -154,18 +163,32 @@ } $t_can_download = file_can_download_bug_attachments( $p_bug_id ); - $t_can_delete = file_can_delete_bug_attachments( $p_bug_id ); $t_preview_text_ext = config_get( 'preview_text_extensions' ); $t_preview_image_ext = config_get( 'preview_image_extensions' ); + PRINT "<table width=\"100%\">\n"; + PRINT " <tr class=\"row-category\">\n"; + PRINT " <td>".lang_get( 'attachments')."</td>\n"; + PRINT " <td>".lang_get( 'file_type')."</td>\n"; + PRINT " <td>".lang_get( 'file_created')."</td>\n"; + PRINT " <td>".lang_get( 'file_size')."</td>\n"; + PRINT " <td>".lang_get( 'file_action')."</td>\n"; + PRINT "</tr>\n"; + $t_current_background = helper_alternate_class(); + $image_previewed = false; for ( $i = 0 ; $i < $num_files ; $i++ ) { + print "\n<tr ".$t_current_background.">\n"; $row = $t_attachment_rows[$i]; extract( $row, EXTR_PREFIX_ALL, 'v' ); $t_file_display_name = string_display_line( file_get_display_name( $v_filename ) ); $t_filesize = number_format( $v_filesize ); $t_date_added = date( config_get( 'normal_date_format' ), db_unixtimestamp( $v_date_added ) ); + $t_can_delete = file_can_delete_bug_attachments( $p_bug_id, $v_id ); + $t_description = string_display_line ( $v_description ); + $t_can_mark_delete = file_can_mark_obsolete( $p_bug_id, $v_id ); + $t_can_mark_patch = file_can_mark_patch( $p_bug_id, $v_id ); if ( $image_previewed ) { $image_previewed = false; @@ -187,22 +210,64 @@ $t_exists = config_get( 'file_upload_method' ) != DISK || file_exists( $v_diskfile ); if ( !$t_exists ) { + print "\n<td colspan=\"5\">\n"; print_file_icon ( $t_file_display_name ); PRINT ' <span class="strike">' . $t_file_display_name . '</span> (attachment missing)'; + print "\n</td>\n"; } else { + print "\n<td>\n"; + if ( $v_patch ) + print "<B>P</B>"; PRINT $t_href_start; print_file_icon ( $t_file_display_name ); - PRINT $t_href_end . ' ' . $t_href_start . $t_file_display_name . - $t_href_end . "$t_href_clicket ($t_filesize bytes) <span class=\"italic\">$t_date_added</span>"; + PRINT $t_href_end . ' '; + if ( $v_obsolete ) { + if ( $t_can_delete || $t_can_mark_delete) { + PRINT $t_href_start . "<span class=\"strike\">" . $t_file_display_name . "</span>" . $t_href_end . $t_href_clicket; + } else { + PRINT "<span class=\"strike\">".$t_file_display_name."</span>"; + } + } else { + PRINT $t_href_start . $t_file_display_name . $t_href_end . $t_href_clicket; + } + print "</td>"; + print "<td>"; + if ( $t_can_mark_patch && !$v_patch ) { + print " [<a class=\"small\" href=\"bug_file_add.php?field=patch&file_id=$v_id&action=1&bug_id=$p_bug_id\">" . lang_get( 'file_patch' ) .'</a>]'; + } else if ( $t_can_mark_patch && $v_patch ) { + print " [<a class=\"small\" href=\"bug_file_add.php?field=patch&file_id=$v_id&action=0&bug_id=$p_bug_id\">" . lang_get( 'file_unpatch' ) .'</a>]'; + } else if ( !$t_can_mark_patch && $v_patch ) { + print lang_get( 'file_is_patch' ); + } else { + print $v_file_type; + } + print "</td>"; + print "<td>".$t_date_added."</td>"; + print "<td>".$t_filesize." bytes</td>"; + + print "<td>"; + # if can change patch status + # if can set to delete if ( $t_can_delete ) { PRINT " [<a class=\"small\" href=\"bug_file_delete.php?file_id=$v_id\">" . lang_get('delete_link') . '</a>]'; } + if ( $t_can_mark_delete && !$v_obsolete ) { + PRINT " [<a class=\"small\" href=\"bug_file_add.php?field=obsolete&file_id=$v_id&action=1&bug_id=$p_bug_id\">" . lang_get( 'file_obsolete' ) . '</a>]'; + } + if ( $t_can_mark_delete && $v_obsolete ) { + PRINT " [<a class=\"small\" href=\"bug_file_add.php?field=obsolete&file_id=$v_id&action=0&bug_id=$p_bug_id\">" . lang_get( 'file_unobsolete' ) . '</a>]'; + } if ( ( FTP == config_get( 'file_upload_method' ) ) && file_exists ( $v_diskfile ) ) { PRINT ' (' . lang_get( 'cached' ) . ')'; } + print "\n</td>\n</tr>\n"; + if ( strlen( $v_description ) > 0 ) { + print "<tr ".$t_current_background."><td colspan=\"5\">"; + print $v_description . "</td></tr>"; + } if ( $t_can_download && ( $v_filesize <= config_get( 'preview_attachments_inline_max_size' ) ) && ( $v_filesize != 0 ) && @@ -222,6 +287,7 @@ PRINT " <span id=\"hideSection_$c_id\">[<a class=\"small\" href='#' id='attmlink_".$c_id."' onclick='swap_content(\"hideSection_".$c_id."\");swap_content(\"showSection_".$c_id."\");return false;'>". lang_get( 'show_content' ) ."</a>]</span>"; PRINT " <span style='display:none' id=\"showSection_$c_id\">[<a class=\"small\" href='#' id='attmlink_".$c_id."' onclick='swap_content(\"hideSection_".$c_id."\");swap_content(\"showSection_".$c_id."\");return false;'>". lang_get( 'hide_content' ) ."</a>]"; + print "\n<tr ".$t_current_background.">\n<td colspan=\"5\">\n"; PRINT "<pre>"; switch ( config_get( 'file_upload_method' ) ) { case DISK: @@ -250,6 +316,7 @@ echo htmlspecialchars($v_content); PRINT "</pre></span>\n"; + print "</td></tr>"; } @@ -258,6 +325,7 @@ ( $v_filesize != 0 ) && ( in_array( strtolower( file_get_extension( $t_file_display_name ) ), $t_preview_image_ext, true ) ) ) { + print "<tr ".$t_current_background."><td colspan=\"5\">"; $t_preview_style = 'border: 0;'; $t_max_width = config_get( 'preview_max_width' ); if ( $t_max_width > 0 ) { @@ -274,13 +342,12 @@ PRINT "\n<br />$t_href_start<img alt=\"$t_title\" $t_preview_style src=\"file_download.php?file_id=$v_id&type=bug\" />$t_href_end"; $image_previewed = true; + print "</td></tr>"; } } - if ( $i != ( $num_files - 1 ) ) { - PRINT "<br />\n"; - } } + print "</table>"; } # -------------------- # delete all files that are associated with the given bug @@ -610,12 +678,20 @@ $t_bug_id = 0; } + if ( $p_user_id == -1 ) + { + $p_user_id = auth_get_current_user_id(); + } # prepare variables for insertion $c_bug_id = db_prepare_int( $p_bug_id ); $c_project_id = db_prepare_int( $t_project_id ); $c_file_type = db_prepare_string( $p_file_type ); $c_title = db_prepare_string( $p_title ); $c_desc = db_prepare_string( $p_desc ); + $c_patch = db_prepare_bool( $p_patch ); + $c_obsolete = db_prepare_bool( $p_obsolete ); + $c_user_id = db_prepare_int( $p_user_id ); + if( $t_project_id == ALL_PROJECTS ) { $t_file_path = config_get( 'absolute_path_default_upload_folder' ); @@ -679,9 +755,9 @@ $c_id = ( 'bug' == $p_table ) ? $c_bug_id : $c_project_id; $query = "INSERT INTO $t_file_table - (" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content) + (" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, patch, obsolete, user_id) VALUES - ($c_id, '$c_title', '$c_desc', '$c_disk_file_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', " . db_now() .", $c_content)"; + ($c_id, '$c_title', '$c_desc', '$c_disk_file_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', " . db_now() .", $c_content, $c_patch, $c_obsolete, $c_user_id)"; db_query( $query ); if ( 'bug' == $p_table ) { @@ -794,5 +870,61 @@ } else { return ''; } + } + # -------------------- + # Check if the current user can mark attachment as a patch. + function file_can_mark_patch( $p_bug_id, $p_file_id ) { + if ( bug_is_readonly( $p_bug_id ) ) { + return false; + } + + $t_submitted_by_me = file_is_user_owner( $p_file_id, auth_get_current_user_id() ); + $t_can_mark = access_has_bug_level( config_get( 'allow_mark_patch_threshold' ), $p_bug_id ); + $t_can_download = $t_can_mark || $t_submitted_by_me; + + return $t_can_download; + } + + # -------------------- + # Check if the current user can mark attachment as a obsolete. + function file_can_mark_obsolete( $p_bug_id, $p_file_id ) { + if ( bug_is_readonly( $p_bug_id ) ) { + return false; + } + + $t_submitted_by_me = file_is_user_owner( $p_file_id, auth_get_current_user_id() ); + $t_can_mark = access_has_bug_level( config_get( 'allow_mark_obsolete_threshold' ), $p_bug_id ); + $t_can_download = $t_can_mark || $t_submitted_by_me; + + return $t_can_download; + } + + # -------------------- + # Marks/unmarks file as a patch/obsolete + function file_mark( $p_file_id, $p_field, $p_action, $p_bug_id ) { + if ( bug_is_readonly( $p_bug_id ) ) { + return false; + } + $t_bug_file_table = config_get( 'mantis_bug_file_table' ); + $query = "UPDATE $t_bug_file_table + SET $p_field = $p_action + WHERE id = $p_file_id"; + db_query( $query ); + } + + function file_is_user_owner( $p_file_id, $p_user_id ) { + if ( $p_user_id == file_get_field( $p_file_id, 'user_id' ) ) { + return true; + } + return false; + } + + # abandon files on user deletion + function file_user_abandon( $p_user_id ) { + $t_bug_file_table = config_get ( 'mantis_bug_file_table' ); + $query = "UPDATE $t_bug_file_table + SET user_id = 0 + WHERE id = $p_user_id"; + db_query( $query ); } ?> --- admin/schema.php Fri Feb 13 10:33:15 2009 +++ admin/schema.php Wed May 27 14:41:02 2009 @@ -361,4 +361,12 @@ ", Array( 'mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS' ) ) ); $upgrade[] = Array('CreateIndexSQL', Array( 'idx_typeowner', config_get( 'mantis_tokens_table' ), 'type, owner' ) ); +# mantisbt 0007835 +$upgrade[] = Array( 'AddColumnSQL', Array( config_get( 'mantis_bug_file_table' ), " + user_id I UNSIGNED NOTNULL DEFAULT '0', + patch L NOTNULL DEFAULT \"'0'\", + obsolete L NOTNULL DEFAULT \"'0'\" ") ); ?> --- lang/strings_english.txt Fri Feb 13 10:33:13 2009 +++ lang/strings_english.txt Wed May 27 15:39:29 2009 @@ -1577,4 +1577,17 @@ $s_graph_page = 'Graph Bug History'; $s_graph_bug_page_link = 'Graph'; +# print_api.php +$s_file_comment = 'File description'; +$s_file_remarks = 'Remarks'; +$s_file_patch = 'Mark patch'; +$s_file_unpatch = 'Unmark patch'; +$s_file_obsolete = 'Obsolete'; +$s_file_unobsolete = 'Not obsolete'; +$s_file_type = 'Type'; +$s_file_created = 'Created'; +$s_file_size = 'Size'; +$s_file_status = 'Status'; +$s_file_action = 'Action'; +$s_file_is_patch = 'patch'; ?> --- core/user_api.php Fri Feb 13 10:33:21 2009 +++ core/user_api.php Wed May 27 13:42:33 2009 @@ -25,6 +25,7 @@ require_once( $t_core_dir . 'email_api.php' ); require_once( $t_core_dir . 'ldap_api.php' ); + require_once( $t_core_dir . 'file_api.php' ); ### User API ### @@ -524,6 +525,9 @@ } user_clear_cache( $p_user_id ); + + # abandon user file + file_user_abandon( $p_user_id ); # Remove account $query = "DELETE FROM $t_user_table