Browse files

MDL-34669: Fix editor filepicker context bt trying to use page context

  • Loading branch information...
1 parent f2ddce9 commit 1d8cd19d7219b9a2e9e35a718dbf5fc21dbb7039 @kastashov kastashov committed with marinaglancy Aug 6, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/form/editor.php
View
7 lib/form/editor.php
@@ -32,7 +32,12 @@ function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attribut
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
}
if (!$this->_options['context']) {
- $this->_options['context'] = get_context_instance(CONTEXT_SYSTEM);
+ // trying to set context to the current page context to make legacy files show in filepicker (e.g. forum post)
+ if (!empty($PAGE->context->id)) {
+ $this->_options['context'] = $PAGE->context;
+ } else {
+ $this->_options['context'] = context_system::instance();
+ }
}
$this->_options['trusted'] = trusttext_trusted($this->_options['context']);
parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes);

0 comments on commit 1d8cd19

Please sign in to comment.