Type: New Feature
Affects Version/s: Future Dev
Fix Version/s: DEV backlog
Component/s: Files API
1. Install Moodle using https://github.com/markn86/moodle/tree/MDL-30245_fileupload-wip-files23.
2. Install the local plugin from https://github.com/markn86/moodle-local_extradata.
3. Set $CFG->extrafiledata = 'extradata';
4. Upload a file.
Pull from Repository:
Pull Master Branch:MDL-30245_fileupload
Pull Master Diff URL:
Problem: we need a way for someone to add new fields to the final file picker screen (after author and license) so that extra data can be collected and stored for each file.
- A new capability called something like: "moodle/file:extradata" defines the people who need to enter in extra information per file.
- New $CFG->extra_file_data="local/cal" ... this defines a plugin that contains 2 new callbacks.
- A plugin (eg local/cal) contains a lib.php with:
- local_cal_get_metadata_fields() - returns an array defining some new text/checkbox fields.
- local_cal_process_metadata() - takes some name/value pairs and stores them in a local database table.
If $CFG->extra_file_data is defined and moodle/file:extradata is true, then:
- we call local_cal_get_metadata_fields() function in (repository/filepicker.js? how?) to get the metadata fields to add after the author/license fields in the filepicker form, and:
- we call the local_cal_process_metadata() function in repository/repository_ajax.php with $record and $file as arguments, so that it can take care of recording that information coming in from the form. Note that fileid is not included in $record, as that is internal, so the local/cas plugin needs to match it with actual file data later (using component/itemid/name etc).
This patch would have very minimal impact to Moodle, but allows a plugin to insert functioning fields at the last stage of the filepicker selection process. The new fields can not be mandatory (ie we can not reload the filepicker until they fill all fields, and nor should we).