added a comment - - edited
Why don't we add a small boolean field to the "file" table called "mainfile" and add some File API call to set the main file for a filearea? Right now this would mostly only be useful for the resource module, but I think it could be very useful for other modules in future. I can imagine students submitting a web site in an assignment, for example (yeah yeah XSS risks etc, that is a problem for the module and permissions). All that can be discussed later, but the File API should support the concept.
I propose we do this:
1) GET JS INTERFACE FIXED FOR TESTERS NOW
- hide the main file element completely
- implement server form validation to auto-select mainfile when there is one, and flag error on form when 2 or more, telling them how to use the context menu to select the main file.
2) IF WE AGREE ON THE MAINFILE FIELD IN FILE TABLE
- add the flag field, and any new API call to set the flag for any file in a given filearea
- add a flag to filemanager element to enable/disable the mainfile selection in the menus (so that it will normally not be seen in generic file areas)
- add upgrade code to make sure mainfile selections in the resource table are copied to the file table
- drop the varchar mainfile field from the resource table
- update the resource code to use the new API for server form validation
3) FIX THE NON-JS INTERFACE
- We need to load the OBJECT in the page by default and hide/replace it with the JS version. It should be possible to make this pretty seamless with some work (Sam is doing a lot of this with the custom menus and docked blocks etc)
- Add [Set as main file] links after every file whenever mainfile selection is enabled AND there is more than one file.
Petr, let me know if you have a strong objection to this new field in the file table. The other option would be a new table like file_mainfile but that seems overkill for such a small boolean value.