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

filemanager context cannot be fully overriden

    XMLWordPrintable

    Details

      Description

      Context

      While implementing an enrol ment plugin for which files need to be uploaded during the enrolment process (aka before the user is enrolled in the course), the following code leads to a throw new require_login_exception('Not enrolled'); exception in lib/moodlelib.php

      $fileattachmentoptions = array(
          'subdirs' => 0,
          'maxfiles' => 5,
          'return_types' => FILE_INTERNAL,
      );
      $mform->addElement('filemanager', 'proof_of_eligibility', "Proof of eligibility", null, $fileattachmentoptions);
      

      The problem is that during enrolment, the filemanager will take the $PAGE context, which is a course_context, which is (rightfully) forbidden for unenrolled users.

      Strategy

      Our strategy to resolve this was to put the files in the requesting user's context, in an enrolment plugin specific filearea. But specifying the context through addElement 's $options doesn't work fully as lib/form/filemanager.php will force the context to be the $PAGE 's in multiple places.

      Proposal

      The attached patch permits the overriding of the filemanager's context through the options. It fixes at least one TODO ?, and only extends the functionality, through fixing an interface which should be working.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            odyx Didier Raboud
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: