From a8d259553d959d365348c068d821bb9d78bd47b6 Mon Sep 17 00:00:00 2001 From: Kirill Astashov Date: Wed, 1 Aug 2012 15:43:33 +0930 Subject: [PATCH] MDL-34669: Fix editor filepicker context bt trying to use page context --- lib/form/editor.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/form/editor.php b/lib/form/editor.php index 32663e83e3b..d922b096f97 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -80,7 +80,12 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']); } if (!$this->_options['context']) { - $this->_options['context'] = context_system::instance(); + // 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);