View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0010504 | mantisbt | attachments | public | 2009-05-19 22:33 | 2016-09-29 03:19 |
Reporter | elvinhau | Assigned To | vboctor | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 1.1.7 | ||||
Summary | 0010504: New feature suggestion: Upload file in 'Add Note' ? | ||||
Description | Dear mantis team, I am using Mantis to coordinate between developer team and support team. When support team report issue, developer team will resolve it and will then add good note to explain the steps to follow to patch/fix the issue. However, uploading file specifically for each 'add note' seems impossible. Current Version: Suggested Feature: Is it possible to consider to have this in your roadmap ? Thanks Elvin | ||||
Tags | patch | ||||
Attached Files | bugnotes-with-attachments.patch (4,821 bytes)
Index: bug_file_upload_inc.php =================================================================== --- bug_file_upload_inc.php (revision 213) +++ bug_file_upload_inc.php (working copy) @@ -69,6 +69,8 @@ } } ?> + <a name="blFileUpload"></a> + Bugnote-ID: <input type="text" name="upload_file_bugnote_id" id="upload_file_bugnote_id" value="0" size="3" /> <input type="submit" class="button" value="<?php echo lang_get( $t_file_upload_max_num == 1 ? 'upload_file_button' : 'upload_files_button' ) ?>" /> Index: bugnote_view_inc.php =================================================================== --- bugnote_view_inc.php (revision 213) +++ bugnote_view_inc.php (working copy) @@ -221,7 +221,14 @@ $note = str_replace(array('<','>'), array('<','>'), $t_bugnote->note); echo string_display_links( $note ); //echo string_display_links( $t_bugnote->note ); + ?> + <br /><hr /> + <?php + print_bug_attachments_list( $tpl_bug_id , $t_bugnote->id ); + ?> + <br />-------> <a href="#blFileUpload" onclick="document.getElementById('upload_file_bugnote_id').value='<?php echo $t_bugnote->id; ?>';">Datei hochladen</a> -------> + </td> </tr> <?php }else{ ?> Index: core/bug_api.php =================================================================== --- core/bug_api.php (revision 213) +++ core/bug_api.php (working copy) @@ -1405,16 +1405,17 @@ * @uses database_api.php * @uses file_api.php */ -function bug_get_attachments( $p_bug_id ) { +function bug_get_attachments( $p_bug_id , $p_bugnote_id = 0 ) { $c_bug_id = db_prepare_int( $p_bug_id ); + $c_bugnote_id = db_prepare_int( $p_bugnote_id ); $t_bug_file_table = db_get_table( 'mantis_bug_file_table' ); $query = "SELECT id, title, diskfile, filename, filesize, file_type, date_added, user_id FROM $t_bug_file_table - WHERE bug_id=" . db_param() . " + WHERE bug_id=" . db_param() . " AND bugnote_id=" . db_param() . " ORDER BY date_added"; - $db_result = db_query_bound( $query, Array( $c_bug_id ) ); + $db_result = db_query_bound( $query, Array( $c_bug_id , $c_bugnote_id ) ); $num_files = db_num_rows( $db_result ); $t_result = array(); Index: core/file_api.php =================================================================== --- core/file_api.php (revision 213) +++ core/file_api.php (working copy) @@ -244,8 +244,8 @@ # type - Can be "image", "text" or empty for other types. # alt - The alternate text to be associated with the icon. # icon - array with icon information, contains 'url' and 'alt' elements. -function file_get_visible_attachments( $p_bug_id ) { - $t_attachment_rows = bug_get_attachments( $p_bug_id ); +function file_get_visible_attachments( $p_bug_id , $p_bugnote_id =0 ) { + $t_attachment_rows = bug_get_attachments( $p_bug_id , $p_bugnote_id ); $t_visible_attachments = array(); $t_attachments_count = count( $t_attachment_rows ); @@ -641,6 +641,8 @@ */ function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null, $p_date_added = 0, $p_skip_bug_update = false ) { + $bugnote_id = gpc_get_int('upload_file_bugnote_id', 0); + file_ensure_uploaded( $p_file ); $t_file_name = $p_file['name']; $t_tmp_file = $p_file['tmp_name']; @@ -729,14 +731,15 @@ $t_id_col = $p_table . "_id"; $query = "INSERT INTO $t_file_table - ( $t_id_col, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id ) + ( $t_id_col, bugnote_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id ) VALUES - ( " . db_param() . ", " . db_param() . ", " . db_param() . ", " + ( " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . " )"; db_query_bound( $query, Array( $t_id, + $bugnote_id, $p_title, $p_desc, $t_unique_name, Index: core/print_api.php =================================================================== --- core/print_api.php (revision 213) +++ core/print_api.php (working copy) @@ -1667,8 +1667,8 @@ # List the attachments belonging to the specified bug. This is used from within # bug_view_inc.php -function print_bug_attachments_list( $p_bug_id ) { - $t_attachments = file_get_visible_attachments( $p_bug_id ); +function print_bug_attachments_list( $p_bug_id , $p_bugnote_id = 0) { + $t_attachments = file_get_visible_attachments( $p_bug_id, $p_bugnote_id ); $t_attachments_count = count( $t_attachments ); $i = 0; bugnotes-with-attachments-V2.patch (6,408 bytes)
Index: bug_api.php =================================================================== --- bug_api.php (revision 217) +++ bug_api.php (revision 218) @@ -1404,16 +1404,17 @@ * @uses database_api.php * @uses file_api.php */ -function bug_get_attachments( $p_bug_id ) { +function bug_get_attachments( $p_bug_id , $p_bugnote_id = 0 ) { $c_bug_id = db_prepare_int( $p_bug_id ); + $c_bugnote_id = db_prepare_int( $p_bugnote_id ); $t_bug_file_table = db_get_table( 'mantis_bug_file_table' ); $query = "SELECT id, title, diskfile, filename, filesize, file_type, date_added, user_id FROM $t_bug_file_table - WHERE bug_id=" . db_param() . " + WHERE bug_id=" . db_param() . " AND bugnote_id=" . db_param() . " ORDER BY date_added"; - $db_result = db_query_bound( $query, Array( $c_bug_id ) ); + $db_result = db_query_bound( $query, Array( $c_bug_id , $c_bugnote_id ) ); $num_files = db_num_rows( $db_result ); $t_result = array(); Index: print_api.php =================================================================== --- print_api.php (revision 217) +++ print_api.php (revision 218) @@ -1667,8 +1667,8 @@ # List the attachments belonging to the specified bug. This is used from within # bug_view_inc.php -function print_bug_attachments_list( $p_bug_id ) { - $t_attachments = file_get_visible_attachments( $p_bug_id ); +function print_bug_attachments_list( $p_bug_id , $p_bugnote_id = 0) { + $t_attachments = file_get_visible_attachments( $p_bug_id, $p_bugnote_id ); $t_attachments_count = count( $t_attachments ); $i = 0; Index: file_api.php =================================================================== --- file_api.php (revision 217) +++ file_api.php (revision 218) @@ -241,14 +241,14 @@ # exists - Applicable for DISK attachments. true: file exists, otherwise false. # can_delete - The logged in user can delete the attachments. # preview - true: the attachment should be previewable, otherwise false. -# type - Can be "image", "text" or empty for other types. -# alt - The alternate text to be associated with the icon. -# icon - array with icon information, contains 'url' and 'alt' elements. -function file_get_visible_attachments( $p_bug_id ) { - $t_attachment_rows = bug_get_attachments( $p_bug_id ); - $t_visible_attachments = array(); - - $t_attachments_count = count( $t_attachment_rows ); +# type - Can be "image", "text" or empty for other types. +# alt - The alternate text to be associated with the icon. +# icon - array with icon information, contains 'url' and 'alt' elements. +function file_get_visible_attachments( $p_bug_id , $p_bugnote_id =0 ) { + $t_attachment_rows = bug_get_attachments( $p_bug_id , $p_bugnote_id ); + $t_visible_attachments = array(); + + $t_attachments_count = count( $t_attachment_rows ); if( $t_attachments_count === 0 ) { return $t_visible_attachments; } @@ -638,13 +638,15 @@ * @param string $p_user_id user id (defaults to current user) * @param int $p_date_added date added * @param bool $p_skip_bug_update skip bug last modification update (useful when importing bug attachments) - */ -function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null, $p_date_added = 0, $p_skip_bug_update = false ) { + */ +function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null, $p_date_added = 0, $p_skip_bug_update = false ) { + + $bugnote_id = gpc_get_int('upload_file_bugnote_id', 0); + + file_ensure_uploaded( $p_file ); + $t_file_name = $p_file['name']; + $t_tmp_file = $p_file['tmp_name']; - file_ensure_uploaded( $p_file ); - $t_file_name = $p_file['name']; - $t_tmp_file = $p_file['tmp_name']; - if( !file_type_check( $t_file_name ) ) { trigger_error( ERROR_FILE_NOT_ALLOWED, ERROR ); } @@ -726,20 +728,21 @@ } $t_file_table = db_get_table( 'mantis_' . $p_table . '_file_table' ); - $t_id_col = $p_table . "_id"; - - $query = "INSERT INTO $t_file_table - ( $t_id_col, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id ) - VALUES - ( " . db_param() . ", " . db_param() . ", " . db_param() . ", " - . db_param() . ", " . db_param() . ", " . db_param() . ", " - . db_param() . ", " . db_param() . ", " . db_param() . ", " - . db_param() . ", " . db_param() . " )"; - db_query_bound( $query, Array( - $t_id, - $p_title, - $p_desc, - $t_unique_name, + $t_id_col = $p_table . "_id"; + + $query = "INSERT INTO $t_file_table + ( $t_id_col, bugnote_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id ) + VALUES + ( " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " + . db_param() . ", " . db_param() . ", " . db_param() . ", " + . db_param() . ", " . db_param() . ", " . db_param() . ", " + . db_param() . ", " . db_param() . " )"; + db_query_bound( $query, Array( + $t_id, + $bugnote_id, + $p_title, + $p_desc, + $t_unique_name, $t_file_name, $t_file_path, $t_file_size, Index: bug_file_upload_inc.php =================================================================== --- bug_file_upload_inc.php (revision 217) +++ bug_file_upload_inc.php (revision 218) @@ -69,6 +69,8 @@ } } ?> + <a name="blFileUpload"></a> + Bugnote-ID: <input type="text" name="upload_file_bugnote_id" id="upload_file_bugnote_id" value="0" size="3" /> <input type="submit" class="button" value="<?php echo lang_get( $t_file_upload_max_num == 1 ? 'upload_file_button' : 'upload_files_button' ) ?>" /> Index: bugnote_view_inc.php =================================================================== --- bugnote_view_inc.php (revision 217) +++ bugnote_view_inc.php (revision 218) @@ -212,7 +212,12 @@ } echo string_display_links( $t_bugnote->note );; - ?> + ++ <br /><hr /> ++ <?php ++ print_bug_attachments_list( $tpl_bug_id , $t_bugnote->id ); ++ ?> ++ <br />-------> <a href="#blFileUpload" onclick="document.getElementById('upload_file_bugnote_id').value='<?php echo $t_bugnote->id; ?>';">Datei hochladen</a> -------> </td> </tr> <?php event_signal( 'EVENT_VIEW_BUGNOTE', array( $f_bug_id, $t_bugnote->id, VS_PRIVATE == $t_bugnote->view_state ) ); ?> | ||||
related to | 0009363 | closed | vboctor | Comments on attachments |
related to | 0017920 | closed | joel | Native markdown support |
related to | 0019589 | closed | vboctor | Support adding a note + attachment in one step |
has duplicate | 0014065 | closed | atrol | Uploading attachments on comment basis? |
has duplicate | 0015364 | closed | atrol | Add Attachments to Notes |
has duplicate | 0011130 | closed | atrol | Add files to notes |
I wonder if this feature would still be useful if we change to a model where we do the following:
The question is whether we want to associate attachments with notes, or have them show in chronological order and provide an easy way to upload, but for example, when the note is deleted, the upload file remains until deleted separately. Also there would be two history entries. |
|
Thank you vboctor. In existing 'Report New Issue', file is uploaded only when 'Submit Report' button is clicked. I like this idea if can apply to 'add note' level individually as well. In my scenario, this is what will happen:
So, the 'add note' communication between the two team should be in chronological order interleave with file attachments (as in your mentioned Point 1 & 2, except having the attachment under the issue). IMHO, if the note is deleted, the file attachment shall also be deleted, as it serves no other purpose. It will be double effort if I want to find out which file is under the note to delete them accordingly. If you mean separating out the 'add note' uploaded file to the main issue, then IMO is not a good idea as it will only add confusion to user with no hint what the file is for initially (at least not until he finished reading the add notes). |
|
I think, it would be a usability improvement, when attachments would always be considered as a part of a note. This would make it easy |
|
Any update on this? |
|
For what it's worth, I don't think attachments should always be part of notes, nor should they be sorted in between notes based on the time they were attached to the defect. We need both note-level attachments, and defect-level attachments. (Being able to enter a link to an attachment based on its attachment ID might come in handy from time to time as well I suppose. For instance, writing the bug description / additional information I sometimes wish I could have the screen capture embedded there.) |
|
I added this feature to add attachments on note level. Because of the amazing structure of mantis I only invested 15 Minuten. Additionally to the patch the follwing query must be executed: |
|
Marking as confirmed since it makes sense to enable scenario. |
|
Theres a lot on interesting ideas here
Presentation could be:
Useful actions:
In my use case, sometimes there's a lot of back and forth attachment and notes. For example, i have an actual issue with 264 notes and 61 attachments, which actually is chaotic. |
|
Schema: Presentation: Access Control Other semantics / actions:
|
|
One of the good things of note attachments is to have the attachment linked with its context (description, author, etc). |
|
In that case, shouldn't the 3 attachments be attached to the bugnote directly ? Adding additional attachments as a 2nd operation would in any case link them to a distinct bugnote / different context... |
|
It can be related to permission to edit own notes. BUT i hate (eg: here) that i cant edit notes for typos. Or adding additional files, in that situation. |
|
This was implemented via 0019589 |
|