View Issue Details

IDProjectCategoryView StatusLast Update
0010504mantisbtattachmentspublic2016-09-29 03:19
Reporterelvinhau Assigned Tovboctor  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version1.1.7 
Summary0010504: 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:
Can only upload file at master level of the issue (for file related to issue question). But not at Add note level (for file related to resolving/solved).

Suggested Feature:
'Add note' to have individual file attachment for it. Sometimes, image explained everything than having to word it down.

Is it possible to consider to have this in your roadmap ? Thanks

Elvin

Tagspatch
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('&lt;','&gt;'), $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 ) ); ?>
Patched MantisBT 10504.png (32,449 bytes)   
Patched MantisBT 10504.png (32,449 bytes)   

Relationships

related to 0009363 closedvboctor Comments on attachments 
related to 0017920 closedjoel Native markdown support 
related to 0019589 closedvboctor Support adding a note + attachment in one step 
has duplicate 0014065 closedatrol Uploading attachments on comment basis? 
has duplicate 0015364 closedatrol Add Attachments to Notes 
has duplicate 0011130 closedatrol Add files to notes 

Activities

vboctor

vboctor

2009-05-20 02:37

manager   ~0021852

I wonder if this feature would still be useful if we change to a model where we do the following:

  1. Interleave the file attachments with the notes based on their submit time.
  2. Allow the user to upload an attachment while submitting a note. The attachment would be displayed after the note but would still belong to the main issue.

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.

elvinhau

elvinhau

2009-05-20 05:51

reporter   ~0021862

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:

  • Reporter A report an issue (attached a screenshot)
  • Developer B resolve the issue, add note on how to apply the patch to it (attach a patch file)
  • Reporter A add a note the patch create another problem (attach another screenshot under the note). [Note: not under the issue]
  • Developer B resolve again, add note and attach another patch file to it.
  • Reporter A now happy and close the issue.

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).

polzin

polzin

2010-03-17 09:33

reporter   ~0024778

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
a) to comment on the content of attachments
b) add image attachments as explanations to bug notes
c) make attachments private (0009802)
d) reduce the user-interface complexity: instead of two different types to submit an addition note/attachment that are treated and sorted differently, there is only one type, a note with a possible attachment.

polzin

polzin

2010-07-30 04:15

reporter   ~0026174

Any update on this?

srouleau

srouleau

2010-08-29 12:34

reporter   ~0026508

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.)

mmmichael

mmmichael

2014-06-14 13:28

reporter   ~0040807

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:
ALTER TABLE mantis_bug_file_table ADD bugnote_id INT( 5 ) NOT NULL AFTER bug_id ,
ADD INDEX ( bugnote_id ) ;

vboctor

vboctor

2015-02-14 13:40

manager   ~0048828

Marking as confirmed since it makes sense to enable scenario.

cproensa

cproensa

2015-09-18 14:53

developer   ~0051504

Theres a lot on interesting ideas here
Now that in 1.3 its possible to add a file along bugnote, the next step would be to store bugnote id along the attachment
some options:

  • alter bug_file table to add bugnote_id
  • create bugnote_file table
  • normalize attachment model, with unique file table, and relation tables: bug-file, bugnote-file, adn whatever: project-file, avatar-file....

Presentation could be:

  • bug main area shows all attachments (with additional legend with useful info, like "added by", "on note XXX")
  • bugnote with linked attachment, also show the attachment as part of note info.

Useful actions:

  • deleting bugnote also deletes attachment
  • private bugnotes makes attachments private
  • possibility to add files to (own) note after bugnote creation, separated from bugnote edit premission

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.

vboctor

vboctor

2015-09-21 22:59

manager   ~0051512

Schema:
I would prefer just adding bugnote_id to bug_file table with default value 0 which indicates that the attachment is associated with the bug. If the bugnote_id is set to a non-zero value, then that would capture the fact that it is a note attachment and links to the corresponding note.

Presentation:
Attachments associated with notes should be presented as part of the note, similar to time tracking information that is part of each note. The attachment visibility depends on note visibility, etc. The issue level attachment should continue to be treated as per the current approach. We can revisit later whether such attachments should be interleaved with comments.

Access Control
The attachment visibility on the issue page and the attachment download page should revise the access check based on whether the attachment is associated with a private or public note.

Other semantics / actions:

  • Note attachments are part of the note in terms of creation, deletion, and visibility. I don't think we need to worry about updating a note to add a file to it. But we can consider this.
  • We don't need to support adding a note attachment with an empty note. That is supported for time tracking, but I don't think we need to support it for attachments. In such case, just add an issue attachment.
cproensa

cproensa

2015-09-22 04:57

developer   ~0051521

We don't need to support adding a note attachment with an empty note. That is supported for time tracking, but I don't think we need to support it for attachments. In such case, just add an issue attachment.

One of the good things of note attachments is to have the attachment linked with its context (description, author, etc).
The situation would be: the user writes a note and needs to upload 3 files in that action. Allowing to add succesive attachments to the bugnote, makes easy to show the files as clearly attached to the note. As opposed to an issue attachment, which even if you show inline in the timelined bugnotes, cant be associated to the actual context

dregad

dregad

2015-09-23 06:01

developer   ~0051522

Allowing to add succesive attachments to the bugnote, makes easy to show the files as clearly attached to the note.

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...

cproensa

cproensa

2015-09-24 15:25

developer   ~0051526

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.
Also, you cant always add more that one attachment in one go (if not configured so)

vboctor

vboctor

2016-09-29 03:19

manager   ~0054087

This was implemented via 0019589