Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-30245

Core file hook to support extra metadata to be added with each file



    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Won't Do
    • Future Dev
    • None
    • Files API


      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.

      1. A new capability called something like: "moodle/file:extradata" defines the people who need to enter in extra information per file.
      2. New $CFG->extra_file_data="local/cal" ... this defines a plugin that contains 2 new callbacks.
      3. 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:

      1. 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:
      2. 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).


        Issue Links



              ikawhero Shane Elliott
              dougiamas Martin Dougiamas
              Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              5 Vote for this issue
              11 Start watching this issue