Attached files to private notes

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
federico
Posts: 30
Joined: Mar 27, 2019 12:35 pm

Attached files to private notes

Post by federico » Jun 30, 2019 6:14 am

Hello all.

The of mantis behaviour when trying to attach files to a private note is the following (for version 2.20.0)

- If the note is public:
You can mix text and files in the same notes, and both works well without dependencias

- If the note is private: I had to comment bugnote_add_inc.php line 149 to show the upload control, with the following result:
If you send text only => all works fine
If you try to send text and files => you get an application error
If you try to send only files => the operation is performed but the note becomes public and the file results exposed

Is there any workaround to remain the note and the attached files private.

Thank you in advance.

atrol
Site Admin
Posts: 7648
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Attached files to private notes

Post by atrol » Jun 30, 2019 7:01 am

Private attachments are not available in Mantis.
https://mantisbt.org/bugs/view.php?id=9802

Furthemore attachments are not related to notes
https://mantisbt.org/bugs/view.php?id=21733
federico wrote:
Jun 30, 2019 6:14 am
- If the note is private: I had to comment bugnote_add_inc.php line 149 to show the upload control, with the following result:
No good idea as you will encounter https://mantisbt.org/bugs/view.php?id=22817#c56722
Please use Search before posting and read the Manual

federico
Posts: 30
Joined: Mar 27, 2019 12:35 pm

Re: Attached files to private notes

Post by federico » Jul 01, 2019 12:10 am

Thanks atrol.

Does someone knows the reason? I have found this issue a week before the users should start to use mantisbt, and after 1000 working hours checking mantis requirements, configuring it for their needs, and developing a plugin to perform some custom transactions. Too late for me, so I need a solution, or my project with mantis definitively fails, with a very expensive waste of time, and and embarrassing loose of reputation. Both things are critical for many people (including me).

As I realized, it is an old known issue, and I can not figure out why it is not accomplished yet (because I check I am not the only one, and it is relatively strongly demanded), and reading your answer, seems there are not expectations to get it solved.

As well as the common sense does not give clues to explain this default behaviour, I've supposed it is a limitation by design, but I need to know why, to find an approach in order to avoid my work to be lost, and this is one of the more complex functions to trace I have found in mantis. So I really need help.

My objetive would be to make attachments scope and behaviour same as the note they are linked to (private attachment support), and I have a week to achieve.

I have not problems to make the effort, but I do not know if it is the the tip of a bigger iceberg already treated with no success by the mantis development team, and where is exactly the problem.

Any suggestions?

Thank you.

federico
Posts: 30
Joined: Mar 27, 2019 12:35 pm

Re: Attached files to private notes

Post by federico » Jul 02, 2019 12:58 am

Finally it is an issue by design. The note attachments are added as a result of a timestamp comparison, without a real relationship between notes and attachments (as cproensa suggests at https://mantisbt.org/bugs/view.php?id=21733). The approach I am evaluating is the following:

- mantis_project_file_table will act as a business entity as mantis_bugnote_text_table do.
- Create a table in the database called mantis_bugnote_file with two fields: bugnote_id, file_id
- IssueNoteAddCommand:
Modify the validation method to remove security consderations which avoids attachments and text to be added together, and include the simple rule
Modify the add method to insert into bugnote_file in the same file transaction, including the note text.
- bug_activity_api.php: retrieves bugnote attachments joining file and bugnote_file
- bug_note_view_inc.php: remove the attachment activity type (unuseful once the relationship bugnote_file is set). Everything is a bugnote, and a bug note can have or not a text and/or a collection of attachments. Then iterate throgh bugnotes and render the attachments for each case.

- dude: are attachments rendered in other places?

If it works, I will modify the delete attachment command to prevent orphan activities (neither text nor attachments), and the delete bugnote command because files are only used at this point and are not going to be useful in the future. In case someone decides to handle files in other places in the future (is the file_api who should take care of this).

Is there any known inconveniences (in addition to the complexity)?

If it works, how can I protect the fix of future mantis updates?

Thanks

atrol
Site Admin
Posts: 7648
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Attached files to private notes

Post by atrol » Jul 03, 2019 4:22 pm

federico wrote:
Jul 02, 2019 12:58 am
If it works, how can I protect the fix of future mantis updates?
You have to reapply your changes after every upgrade.
This is not that much work if you use a seperate branch in Git for it (rebase your branch on top of new master branch)

It would be even better, if you submit a pull request, as it increases the chances of improvement eventually making it into MantisBT core. All contributions are welcome and greatly appreciated.
Send us a pull request on our Github repository https://github.com/mantisbt/mantisbt
Please make sure that your submissions adhere to our Coding Guidelines http://www.mantisbt.org/wiki/doku.php/m ... guidelines
Please use Search before posting and read the Manual

federico
Posts: 30
Joined: Mar 27, 2019 12:35 pm

Re: Attached files to private notes

Post by federico » Jul 13, 2019 3:04 pm

Thank you.

I am almost finishing the job, and it seems to work by the moment. There are three or four more files to change, but I thing the approach is clean. I can not wait or follow processes because my customer thought it was working fine.

I would share the complete solution in order to its revision for implementation in next releases. I am creating a document with all changes I do. Consider this as a donation and do with it whatever you want (with the oportune mention). I do not know every functional detail of mantis, so I can not be sure if there are more views or reports using files. Please, could someone read the document with the changes and check if I am forggeting something important?

By the way, do you know where is the javascript to display/hide the file upload control when switch beteen public/private notes? It will not be necessary in the future, and now causes a nonsense behaviour, because files or text can be attached to a note indeed together, and the renderization follows the text pattern security.

Post Reply