Forum .LRN Q&A: Hidden .LRN dependencies

Collapse
Posted by Malte Sussdorff on
I wanted to enable attachments to forums on my private site that does not use .LRN. Two things got on my nerves and need to be fixed (besides the fact that it should be possible to enable attachments from the forums administration and not through the site-map, manually mounting the attachment instance).

a) Forums assumes attachments to be mounted under "[path_to_forums]/attach". This is hardcoded => VERY BAD!

b) Who on earth had the splendid idea to make attachments depend on .LRN without stating so in the .info file. After all, you could just attach the file to the forum_posting_id without using a folder, but who am I to argue....

malte@andromeda:/web/cognovis/packages/attachments/www$ grep dotlrn *
attach.tcl: set folder_id [dotlrn_fs::get_user_shared_folder -user_id $user_id]
file-add-2.tcl:set fs_package_id [site_node::get_element -url "[dotlrn::get_url]/file-storage/" -element "package_id"]

I will try to fix this in the near future, but do us a favour and prevent hidden dependencies like this as not all sites use .LRN.

Collapse
Posted by Dave Bauer on
Malte,

There is a reasoning behind using file-storage to manage attachments. Basically it allows one to attach already uploaded file, and attach the same file to multiple objects without uploading more than once.

The dependecy of dotlrn is strange. There is a mapping between attachments using packages and file-storage. That is, your forums package instance with attacments enabled would be mapped to a file storage root folder in the table attachments_fs_root_folder_map.

It should be easy enough to get the folder_id from that package instance in attach.tcl.

In file-add-2.tcl you should be able to do the same thing by finding the direct parent package and getting the related file storage from the same table.

It appears that dotLRN should map the attachments to the root folder it needs in the service contracts that create the forums and attachments in a community. See this commit:
http://cvs.openacs.org/cvs/openacs-4/packages/attachments/www/attach.tcl?r1=1.7.2.2&r2=1.7.2.3

If that is reverted, I think it will behave as you expect.

Adding a UI to enable attachments is a great idea.