Skip to content
Browse files

MDL-33446 Editor form field can filter return types

- Added possibility for editor form field to specify return_types (default FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE)
- For assignment, workshop, quiz essay submissions and form posts do not allow FILE_REFERENCE
- Fixed mod_resource return_types, reset them to default, because filemanager does not know how to work with FILE_EXTERNAL links
  • Loading branch information...
1 parent f8dfdb5 commit c469b3963b809d3a293939ae1667711a87124935 @marinaglancy marinaglancy committed May 31, 2012
View
5 lib/form/editor.php
@@ -52,7 +52,8 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element {
/** @var array options provided to initalize filepicker */
protected $_options = array('subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>0, 'changeformat'=>0,
- 'context'=>null, 'noclean'=>0, 'trusttext'=>0);
+ 'context'=>null, 'noclean'=>0, 'trusttext'=>0, 'return_types'=>7);
+ // $_options['return_types'] = FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE
/** @var array values for editor */
protected $_values = array('text'=>null, 'format'=>null, 'itemid'=>null);
@@ -303,7 +304,7 @@ function toHtml() {
$args = new stdClass();
// need these three to filter repositories list
$args->accepted_types = array('web_image');
- $args->return_types = (FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE);
+ $args->return_types = $this->_options['return_types'];
$args->context = $ctx;
$args->env = 'filepicker';
// advimage plugin
View
3 mod/assign/submission/onlinetext/locallib.php
@@ -106,7 +106,8 @@ private function get_edit_options() {
'noclean' => false,
'maxfiles' => EDITOR_UNLIMITED_FILES,
'maxbytes' => $this->assignment->get_course()->maxbytes,
- 'context' => $this->assignment->get_context()
+ 'context' => $this->assignment->get_context(),
+ 'return_types' => FILE_INTERNAL | FILE_EXTERNAL
);
return $editoroptions;
}
View
3 mod/assignment/type/online/assignment.class.php
@@ -42,7 +42,8 @@ function view() {
'noclean' => false,
'maxfiles' => EDITOR_UNLIMITED_FILES,
'maxbytes' => $this->course->maxbytes,
- 'context' => $this->context
+ 'context' => $this->context,
+ 'return_types' => FILE_INTERNAL | FILE_EXTERNAL
);
$data = new stdClass();
View
3 mod/forum/post_form.php
@@ -45,7 +45,8 @@ function definition() {
$forum->maxbytes = $course->maxbytes;
}
// TODO: add max files and max size support
- $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'trusttext'=>true, 'context'=>$modcontext);
+ $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'trusttext'=>true,
+ 'context'=>$modcontext, 'return_types'=>FILE_INTERNAL | FILE_EXTERNAL);
$mform->addElement('header', 'general', '');//fill in the data depending on page params later using set_data
$mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
View
3 mod/resource/mod_form.php
@@ -61,9 +61,6 @@ function definition() {
$mform->addElement('header', 'contentsection', get_string('contentheader', 'resource'));
$filemanager_options = array();
- // 3 == FILE_EXTERNAL | FILE_INTERNAL | FILE_REFERENCE
- // These two constant names are defined in repository/lib.php
- $filemanager_options['return_types'] = 7;
$filemanager_options['accepted_types'] = '*';
$filemanager_options['maxbytes'] = 0;
$filemanager_options['maxfiles'] = -1;
View
3 mod/workshop/submission.php
@@ -144,7 +144,8 @@
'subdirs' => false,
'maxfiles' => $maxfiles,
'maxbytes' => $maxbytes,
- 'context' => $workshop->context
+ 'context' => $workshop->context,
+ 'return_types' => FILE_INTERNAL | FILE_EXTERNAL
);
$attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'return_types' => FILE_INTERNAL);
View
3 question/type/essay/renderer.php
@@ -109,6 +109,7 @@ public function files_input(question_attempt $qa, $numallowed,
$pickeroptions->itemid = $qa->prepare_response_files_draft_itemid(
'attachments', $options->context->id);
$pickeroptions->context = $options->context;
+ $pickeroptions->return_types = FILE_INTERNAL;
$pickeroptions->itemid = $qa->prepare_response_files_draft_itemid(
'attachments', $options->context->id);
@@ -280,7 +281,7 @@ protected function get_editor_options($context) {
* @return array filepicker options for the editor.
*/
protected function get_filepicker_options($context, $draftitemid) {
- return array();
+ return array('return_types' => FILE_INTERNAL | FILE_EXTERNAL);
}
/**

0 comments on commit c469b39

Please sign in to comment.
Something went wrong with that request. Please try again.