Forum OpenACS Development: Attachments package does not work without .LRN

It's my fault, so I should fix it, but there's a philosophical problem.

First, let me explain how it got this way. Here is my commit message from August 11, 2004:

"fix from Sloan: store attachments in user's shared files folder instead of in the community's file-storage, where they often don't have write privs and there's no good place to put them anyway"

Back then, attachments was part of the .LRN bundle and this fix was appropriate, or at least I thought so. No-one has complained up to now, and there aren't any bugs on this in the bug tracker, so I will claim it was a reasonable choice at the time.

However, since then attachments has become a required package for other packages, such as forums, which most definitely need to work outside of .LRN, so my fix is no longer valid.

The question is, where should attached files be stored? I don't consider putting them in the root folder of file storage to be appropriate, as they are then visible to any users who happen to navigate there. I vaguely recall considering using folder_id -100, or something similar, back when I made this change, but someone (Dave?) had a good reason for not doing that.

Suggestions?

Collapse
Posted by Dave Bauer on
Janine

Attachments requires a file-storage package instance to store files in to be associated with it. Forums has always required attachments, but it never set it self up automatically so you have to mount attachments and hook it up to a file-storage instance manually.

Really each user should end up with a folder for this stuff, or attachments should show all file-storage folders a user can see or something similar.

Another option is to not use file-storage at all and just associate an uploaded file directly with the forum post by setting cr_items.parent_id to the message_id.

Sorry this doesn't fix things. I do know that I have a client install that uses attachments with a custom package that shouldn't rely of dotlrn.

Collapse
Posted by Malte Sussdorff on
Hi Janine, quickly rewrite forums. Here is the step by step guide:

1) Take /contacts/www/files.tcl and move it to forums
2) Change files.tcl so it associates the uploaded file with the message_id (e.g. using the parent_id, but I have a slight suspicion that a data link is better, as a message_id can have multiple children)
3) Change the message view to include in the display all uploaded files either using the parent_id or the data link.
4) Change the upload functionality from attachments to files.tcl
5) Pray someone else writes an upgrade
6) Wait for the file-attachment widget

Collapse
Posted by Dave Bauer on
Here is a simpler option or 2)

1) add a "if dotlrn is installed" bit around the part that generates the dotlrn URL, although generally frowned upon

or

2) Add a callback to the attachments package to generate the URL to the correct file storage. Leave it unimplemented in the stock attachments package and if it is unimplemented default to the file storage mapping. In dotlrn add a callback implementation that returns the users personal folder.

In the future then, other code could override the default folder, for example, if users had a dotfolio personal file storage or other non-dotlrn folder to use.

Collapse
Posted by Janine Ohmer on
Thanks, Dave.

I wasn't clear enough in my initial message. I actually was planning on putting the "if dotlrn is installed" bit around the existing code, but I still need somewhere to put the files in the non-dotlrn case. That was what I was asking about.

My particular installation, being fairly stock, has only one file-storage instance. But there could be many of them. Do we want to require the person setting this up to mount a file-storage instance under forums, along with the attachments instance, just for use by attachments? In looking at what the code was before I changed it I think this is what it was doing; it starts from its parent's package_id and looks for a file-storage instance there.

Collapse
Posted by Dave Bauer on
Janine,

There should be a mapping table that maps attachments to file-storage folders "attachments_fs_root_folder_map" that you can use to map an attachments instance to any folder.