diff a/lib/form/url.php b/lib/form/url.php --- a/lib/form/url.php +++ b/lib/form/url.php @@ class MoodleQuickForm_url extends HTML_QuickForm_text{ $args = new stdClass(); $args->accepted_types = '*'; $args->return_types = FILE_EXTERNAL; - $args->context = $PAGE->context; + + // MDL-30869 + $newcontext = new stdClass(); + $newcontext->id = $context->id; + $newcontext->contextlevel = $context->contextlevel; + $newcontext->protected = $context->instanceid; + $newcontext->path = $context->path; + $newcontext->depth = $context->depth; + $args->context = $newcontext; + $args->client_id = $client_id; $args->env = 'url'; $fp = new file_picker($args); $options = $fp->options; // print out file picker $str .= $OUTPUT->render($fp); $module = array('name'=>'form_url', 'fullpath'=>'/lib/form/url.js', 'requires'=>array('core_filepicker')); $PAGE->requires->js_init_call('M.form_url.init', array($options), true, $module); $PAGE->requires->js_function_call('show_item', array('filepicker-button-'.$client_id)); return $str;