MDL-28094 keep subdirs in content upgraded from 1.x
This commit is contained in:
+2
-1
@@ -162,7 +162,8 @@ if (!empty($entry->id)) {
|
||||
}
|
||||
|
||||
require_once('edit_form.php');
|
||||
$summaryoptions = array('subdirs'=>false, 'maxfiles'=> 99, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>true, 'context'=>$sitecontext);
|
||||
$summaryoptions = array('maxfiles'=> 99, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>true, 'context'=>$sitecontext,
|
||||
'subdirs'=>file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id));
|
||||
$attachmentoptions = array('subdirs'=>false, 'maxfiles'=> 99, 'maxbytes'=>$CFG->maxbytes);
|
||||
|
||||
$blogeditform = new blog_edit_form(null, compact('entry', 'summaryoptions', 'attachmentoptions', 'sitecontext', 'courseid', 'modid'));
|
||||
|
||||
@@ -70,6 +70,7 @@ $overviewfilesoptions = course_overviewfiles_options($course);
|
||||
if (!empty($course)) {
|
||||
//add context for editor
|
||||
$editoroptions['context'] = $coursecontext;
|
||||
$editoroptions['subdirs'] = file_area_contains_subdirs($coursecontext, 'course', 'summary', 0);
|
||||
$course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0);
|
||||
if ($overviewfilesoptions) {
|
||||
file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, $coursecontext, 'course', 'overviewfiles', 0);
|
||||
@@ -84,6 +85,7 @@ if (!empty($course)) {
|
||||
} else {
|
||||
//editor should respect category context if course context is not set.
|
||||
$editoroptions['context'] = $catcontext;
|
||||
$editoroptions['subdirs'] = 0;
|
||||
$course = file_prepare_standard_editor($course, 'summary', $editoroptions, null, 'course', 'summary', null);
|
||||
if ($overviewfilesoptions) {
|
||||
file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, null, 'course', 'overviewfiles', 0);
|
||||
|
||||
@@ -77,7 +77,8 @@ $editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => true,
|
||||
'context' => $editorcontext
|
||||
'context' => $editorcontext,
|
||||
'subdirs' => file_area_contains_subdirs($editorcontext, 'coursecat', 'description', $itemid),
|
||||
);
|
||||
$category = file_prepare_standard_editor($category, 'description', $editoroptions, $editorcontext, 'coursecat', 'description', $itemid);
|
||||
|
||||
|
||||
@@ -111,8 +111,10 @@ $editoroptions = array(
|
||||
);
|
||||
|
||||
if (!empty($outcome_rec->id)) {
|
||||
$editoroptions['subdirs'] = file_area_contains_subdirs($systemcontext, 'grade', 'outcome', $outcome_rec->id);
|
||||
$outcome_rec = file_prepare_standard_editor($outcome_rec, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', $outcome_rec->id);
|
||||
} else {
|
||||
$editoroptions['subdirs'] = false;
|
||||
$outcome_rec = file_prepare_standard_editor($outcome_rec, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', null);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,8 +104,10 @@ $editoroptions = array(
|
||||
);
|
||||
|
||||
if (!empty($scale_rec->id)) {
|
||||
$editoroptions['subdirs'] = file_area_contains_subdirs($systemcontext, 'grade', 'scale', $scale_rec->id);
|
||||
$scale_rec = file_prepare_standard_editor($scale_rec, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale_rec->id);
|
||||
} else {
|
||||
$editoroptions['subdirs'] = false;
|
||||
$scale_rec = file_prepare_standard_editor($scale_rec, 'description', $editoroptions, $systemcontext, 'grade', 'scale', null);
|
||||
}
|
||||
$mform = new edit_scale_form(null, compact('gpr', 'editoroptions'));
|
||||
|
||||
@@ -79,8 +79,10 @@ $returnurl = $CFG->wwwroot.'/group/index.php?id='.$course->id.'&group='.$id;
|
||||
// Prepare the description editor: We do support files for group descriptions
|
||||
$editoroptions = array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$course->maxbytes, 'trust'=>false, 'context'=>$context, 'noclean'=>true);
|
||||
if (!empty($group->id)) {
|
||||
$editoroptions['subdirs'] = file_area_contains_subdirs($context, 'group', 'description', $group->id);
|
||||
$group = file_prepare_standard_editor($group, 'description', $editoroptions, $context, 'group', 'description', $group->id);
|
||||
} else {
|
||||
$editoroptions['subdirs'] = false;
|
||||
$group = file_prepare_standard_editor($group, 'description', $editoroptions, $context, 'group', 'description', null);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,11 @@ class mod_forum_post_form extends moodleform {
|
||||
/**
|
||||
* Returns the options array to use in forum text editor
|
||||
*
|
||||
* @param context_module $context
|
||||
* @param int $postid post id, use null when adding new post
|
||||
* @return array
|
||||
*/
|
||||
public static function editor_options() {
|
||||
public static function editor_options(context_module $context, $postid) {
|
||||
global $COURSE, $PAGE, $CFG;
|
||||
// TODO: add max files and max size support
|
||||
$maxbytes = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $COURSE->maxbytes);
|
||||
@@ -67,7 +69,8 @@ class mod_forum_post_form extends moodleform {
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $maxbytes,
|
||||
'trusttext'=> true,
|
||||
'return_types'=> FILE_INTERNAL | FILE_EXTERNAL
|
||||
'return_types'=> FILE_INTERNAL | FILE_EXTERNAL,
|
||||
'subdirs' => file_area_contains_subdirs($context, 'mod_forum', 'post', $postid)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -106,7 +109,7 @@ class mod_forum_post_form extends moodleform {
|
||||
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
|
||||
$mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$mform->addElement('editor', 'message', get_string('message', 'forum'), null, self::editor_options());
|
||||
$mform->addElement('editor', 'message', get_string('message', 'forum'), null, self::editor_options($modcontext, (empty($post->id) ? null : $post->id)));
|
||||
$mform->setType('message', PARAM_RAW);
|
||||
$mform->addRule('message', get_string('required'), 'required', null, 'client');
|
||||
|
||||
|
||||
+3
-3
@@ -4370,7 +4370,7 @@ function forum_add_new_post($post, $mform, &$message) {
|
||||
|
||||
$post->id = $DB->insert_record("forum_posts", $post);
|
||||
$post->message = file_save_draft_area_files($post->itemid, $context->id, 'mod_forum', 'post', $post->id,
|
||||
mod_forum_post_form::editor_options(), $post->message);
|
||||
mod_forum_post_form::editor_options($context, null), $post->message);
|
||||
$DB->set_field('forum_posts', 'message', $post->message, array('id'=>$post->id));
|
||||
forum_add_attachment($post, $forum, $cm, $mform, $message);
|
||||
|
||||
@@ -4420,7 +4420,7 @@ function forum_update_post($post, $mform, &$message) {
|
||||
$discussion->timeend = $post->timeend;
|
||||
}
|
||||
$post->message = file_save_draft_area_files($post->itemid, $context->id, 'mod_forum', 'post', $post->id,
|
||||
mod_forum_post_form::editor_options(), $post->message);
|
||||
mod_forum_post_form::editor_options($context, $post->id), $post->message);
|
||||
$DB->set_field('forum_posts', 'message', $post->message, array('id'=>$post->id));
|
||||
|
||||
$DB->update_record('forum_discussions', $discussion);
|
||||
@@ -4484,7 +4484,7 @@ function forum_add_discussion($discussion, $mform=null, $unused=null, $userid=nu
|
||||
if (!empty($cm->id) && !empty($discussion->itemid)) { // In "single simple discussions" this may not exist yet
|
||||
$context = context_module::instance($cm->id);
|
||||
$text = file_save_draft_area_files($discussion->itemid, $context->id, 'mod_forum', 'post', $post->id,
|
||||
mod_forum_post_form::editor_options(), $post->message);
|
||||
mod_forum_post_form::editor_options($context, null), $post->message);
|
||||
$DB->set_field('forum_posts', 'message', $text, array('id'=>$post->id));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -557,8 +557,9 @@ if (forum_is_subscribed($USER->id, $forum->id)) {
|
||||
$subscribe = !empty($USER->autosubscribe);
|
||||
}
|
||||
|
||||
$postid = empty($post->id) ? null : $post->id;
|
||||
$draftid_editor = file_get_submitted_draft_itemid('message');
|
||||
$currenttext = file_prepare_draft_area($draftid_editor, $modcontext->id, 'mod_forum', 'post', empty($post->id) ? null : $post->id, mod_forum_post_form::editor_options(), $post->message);
|
||||
$currenttext = file_prepare_draft_area($draftid_editor, $modcontext->id, 'mod_forum', 'post', $postid, mod_forum_post_form::editor_options($modcontext, $postid), $post->message);
|
||||
$mform_post->set_data(array( 'attachments'=>$draftitemid,
|
||||
'general'=>$heading,
|
||||
'subject'=>$post->subject,
|
||||
|
||||
@@ -66,7 +66,8 @@ if ($id) { // if entry is specified
|
||||
$maxfiles = 99; // TODO: add some setting
|
||||
$maxbytes = $course->maxbytes; // TODO: add some setting
|
||||
|
||||
$definitionoptions = array('trusttext'=>true, 'subdirs'=>false, 'maxfiles'=>$maxfiles, 'maxbytes'=>$maxbytes, 'context'=>$context);
|
||||
$definitionoptions = array('trusttext'=>true, 'maxfiles'=>$maxfiles, 'maxbytes'=>$maxbytes, 'context'=>$context,
|
||||
'subdirs'=>file_area_contains_subdirs($context, 'mod_glossary', 'entry', $entry->id));
|
||||
$attachmentoptions = array('subdirs'=>false, 'maxfiles'=>$maxfiles, 'maxbytes'=>$maxbytes);
|
||||
|
||||
$entry = file_prepare_standard_editor($entry, 'definition', $definitionoptions, $context, 'mod_glossary', 'entry', $entry->id);
|
||||
|
||||
+2
-1
@@ -76,7 +76,8 @@ $editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => false,
|
||||
'context' => $systemcontext
|
||||
'context' => $systemcontext,
|
||||
'subdirs' => file_area_contains_subdirs($systemcontext, 'tag', 'description', $tag->id),
|
||||
);
|
||||
$tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user