Merge branch 'wip-mdl-27896' of git://github.com/rajeshtaneja/moodle
This commit is contained in:
+2
-2
@@ -98,12 +98,12 @@ if ($delete and $cohort->id) {
|
||||
$editoroptions = array('maxfiles'=>0, 'context'=>$context);
|
||||
if ($cohort->id) {
|
||||
// edit existing
|
||||
$cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions);
|
||||
$cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions, $context);
|
||||
$strheading = get_string('editcohort', 'cohort');
|
||||
|
||||
} else {
|
||||
// add new
|
||||
$cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions);
|
||||
$cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions, $context);
|
||||
$strheading = get_string('addcohort', 'cohort');
|
||||
}
|
||||
|
||||
|
||||
@@ -77,9 +77,13 @@ if (!empty($course)) {
|
||||
}
|
||||
}
|
||||
$course->allowedmods = $allowedmods;
|
||||
//add context for editor
|
||||
$editoroptions['context'] = $coursecontext;
|
||||
$course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0);
|
||||
|
||||
} else {
|
||||
//editor should respect category context if course context is not set.
|
||||
$editoroptions['context'] = $catcontext;
|
||||
$course = file_prepare_standard_editor($course, 'summary', $editoroptions, null, 'course', 'summary', null);
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -13,6 +13,8 @@ require_once('editcategory_form.php');
|
||||
require_login();
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
$itemid = 0; //initalise itemid, as all files in category description has item id 0
|
||||
|
||||
if ($id) {
|
||||
if (!$category = $DB->get_record('course_categories', array('id' => $id))) {
|
||||
print_error('unknowcategory');
|
||||
@@ -42,15 +44,21 @@ if ($id) {
|
||||
$category->parent = $parent;
|
||||
require_capability('moodle/category:manage', $context);
|
||||
$strtitle = get_string("addnewcategory");
|
||||
$editorcontext = null;
|
||||
$editorcontext = $context;
|
||||
$itemid = null; //set this explicitly, so files for parent category should not get loaded in draft area.
|
||||
$title = "$SITE->shortname: ".get_string('addnewcategory');
|
||||
$fullname = $SITE->fullname;
|
||||
}
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>true);
|
||||
$category = file_prepare_standard_editor($category, 'description', $editoroptions, $editorcontext, 'coursecat', 'description', 0);
|
||||
$editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => true,
|
||||
'context' => $editorcontext
|
||||
);
|
||||
$category = file_prepare_standard_editor($category, 'description', $editoroptions, $editorcontext, 'coursecat', 'description', $itemid);
|
||||
|
||||
$mform = new editcategory_form('editcategory.php', compact('category', 'editoroptions'));
|
||||
$mform->set_data($category);
|
||||
|
||||
@@ -103,7 +103,13 @@ if (!$courseid) {
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url('index.php?id='.$courseid);
|
||||
$editoroptions = array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
|
||||
$editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => false,
|
||||
'noclean' => true,
|
||||
'context' => $systemcontext
|
||||
);
|
||||
|
||||
if (!empty($outcome_rec->id)) {
|
||||
$outcome_rec = file_prepare_standard_editor($outcome_rec, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', $outcome_rec->id);
|
||||
|
||||
@@ -88,7 +88,13 @@ if (!$courseid) {
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url('index.php?id='.$courseid);
|
||||
$editoroptions = array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
|
||||
$editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => false,
|
||||
'noclean' => true,
|
||||
'context' => $systemcontext
|
||||
);
|
||||
|
||||
if (!empty($scale_rec->id)) {
|
||||
$scale_rec = file_prepare_standard_editor($scale_rec, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale_rec->id);
|
||||
|
||||
@@ -111,6 +111,20 @@ function file_prepare_standard_editor($data, $field, array $options, $context=nu
|
||||
$options['noclean'] = false;
|
||||
}
|
||||
|
||||
//sanity check for passed context. This function doesn't expect $option['context'] to be set
|
||||
//But this function is called before creating editor hence, this is one of the best places to check
|
||||
//if context is used properly. This check notify developer that they missed passing context to editor.
|
||||
if (isset($context) && !isset($options['context'])) {
|
||||
//if $context is not null then make sure $option['context'] is also set.
|
||||
debugging('Context for editor is not set in editoroptions. Hence editor will not respect editor filters', DEBUG_DEVELOPER);
|
||||
} else if (isset($options['context']) && isset($context)) {
|
||||
//If both are passed then they should be equal.
|
||||
if ($options['context']->id != $context->id) {
|
||||
$exceptionmsg = 'Editor context ['.$options['context']->id.'] is not equal to passed context ['.$context->id.']';
|
||||
throw new coding_exception($exceptionmsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($itemid) or is_null($context)) {
|
||||
$contextid = null;
|
||||
$itemid = null;
|
||||
|
||||
@@ -2372,6 +2372,7 @@ class mod_assignment_grading_form extends moodleform {
|
||||
$editoroptions['noclean'] = false;
|
||||
$editoroptions['maxfiles'] = 0; //TODO: no files for now, we need to first implement assignment_feedback area, integration with gradebook, files support in quickgrading, etc. (skodak)
|
||||
$editoroptions['maxbytes'] = $this->_customdata->maxbytes;
|
||||
$editoroptions['context'] = $this->_customdata->context;
|
||||
return $editoroptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,12 @@ class assignment_online extends assignment_base {
|
||||
|
||||
if ($editmode) {
|
||||
// prepare form and process submitted data
|
||||
$editoroptions = array('noclean'=>false, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$this->course->maxbytes);
|
||||
$editoroptions = array(
|
||||
'noclean' => false,
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $this->course->maxbytes,
|
||||
'context' => $this->context
|
||||
);
|
||||
|
||||
$data = new stdClass();
|
||||
$data->id = $this->cm->id;
|
||||
|
||||
@@ -49,6 +49,10 @@ class feedback_item_label extends feedback_item_base {
|
||||
//preparing the editor for new file-api
|
||||
$item->presentationformat = FORMAT_HTML;
|
||||
$item->presentationtrust = 1;
|
||||
|
||||
// Append editor context to presentation options, giving preference to existing context.
|
||||
$this->presentationoptions = array_merge(array('context' => $this->context), $this->presentationoptions);
|
||||
|
||||
$item = file_prepare_standard_editor($item,
|
||||
'presentation', //name of the form element
|
||||
$this->presentationoptions,
|
||||
|
||||
@@ -84,6 +84,7 @@ if ($edit) {
|
||||
$data = $editpage->properties();
|
||||
$data->pageid = $editpage->id;
|
||||
$data->id = $cm->id;
|
||||
$editoroptions['context'] = $context;
|
||||
$data = file_prepare_standard_editor($data, 'contents', $editoroptions, $context, 'mod_lesson', 'page_contents', $editpage->id);
|
||||
$mform->set_data($data);
|
||||
$PAGE->navbar->add(get_string('edit'), new moodle_url('/mod/lesson/edit.php', array('id'=>$id)));
|
||||
|
||||
@@ -535,6 +535,8 @@ class page_wiki_edit extends page_wiki {
|
||||
switch ($format) {
|
||||
case 'html':
|
||||
$data->newcontentformat = FORMAT_HTML;
|
||||
// Append editor context to editor options, giving preference to existing context.
|
||||
page_wiki_edit::$attachmentoptions = array_merge(array('context' => $this->modcontext), page_wiki_edit::$attachmentoptions);
|
||||
$data = file_prepare_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -103,7 +103,14 @@ if ($edit and $canmanage) {
|
||||
|
||||
$maxfiles = $workshop->nattachments;
|
||||
$maxbytes = $workshop->maxbytes;
|
||||
$contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
|
||||
$contentopts = array(
|
||||
'trusttext' => true,
|
||||
'subdirs' => false,
|
||||
'maxfiles' => $maxfiles,
|
||||
'maxbytes' => $maxbytes,
|
||||
'context' => $workshop->context
|
||||
);
|
||||
|
||||
$attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
|
||||
$example = file_prepare_standard_editor($example, 'content', $contentopts, $workshop->context,
|
||||
'mod_workshop', 'submission_content', $example->id);
|
||||
|
||||
@@ -116,6 +116,9 @@ class workshop_accumulative_strategy implements workshop_strategy {
|
||||
$norepeats += self::ADDDIMS;
|
||||
}
|
||||
|
||||
// Append editor context to editor options, giving preference to existing context.
|
||||
$this->descriptionopts = array_merge(array('context' => $PAGE->context), $this->descriptionopts);
|
||||
|
||||
// prepare the embeded files
|
||||
for ($i = 0; $i < $nodimensions; $i++) {
|
||||
// prepare all editor elements
|
||||
|
||||
@@ -116,6 +116,9 @@ class workshop_comments_strategy implements workshop_strategy {
|
||||
$norepeats += self::ADDDIMS;
|
||||
}
|
||||
|
||||
// Append editor context to editor options, giving preference to existing context.
|
||||
$this->descriptionopts = array_merge(array('context' => $PAGE->context), $this->descriptionopts);
|
||||
|
||||
// prepare the embedded files
|
||||
for ($i = 0; $i < $nodimensions; $i++) {
|
||||
// prepare all editor elements
|
||||
|
||||
@@ -120,6 +120,9 @@ class workshop_numerrors_strategy implements workshop_strategy {
|
||||
$norepeats += self::ADDDIMS;
|
||||
}
|
||||
|
||||
// Append editor context to editor options, giving preference to existing context.
|
||||
$this->descriptionopts = array_merge(array('context' => $PAGE->context), $this->descriptionopts);
|
||||
|
||||
// prepare the embeded files
|
||||
for ($i = 0; $i < $nodimensions; $i++) {
|
||||
// prepare all editor elements
|
||||
|
||||
@@ -126,6 +126,9 @@ class workshop_rubric_strategy implements workshop_strategy {
|
||||
$norepeats += self::ADDDIMS;
|
||||
}
|
||||
|
||||
// Append editor context to editor options, giving preference to existing context.
|
||||
$this->descriptionopts = array_merge(array('context' => $this->workshop->context), $this->descriptionopts);
|
||||
|
||||
// prepare the embeded files
|
||||
for ($i = 0; $i < $nodimensions; $i++) {
|
||||
// prepare all editor elements
|
||||
|
||||
@@ -124,7 +124,14 @@ if ($edit) {
|
||||
|
||||
$maxfiles = $workshop->nattachments;
|
||||
$maxbytes = $workshop->maxbytes;
|
||||
$contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
|
||||
$contentopts = array(
|
||||
'trusttext' => true,
|
||||
'subdirs' => false,
|
||||
'maxfiles' => $maxfiles,
|
||||
'maxbytes' => $maxbytes,
|
||||
'context' => $workshop->context
|
||||
);
|
||||
|
||||
$attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
|
||||
$submission = file_prepare_standard_editor($submission, 'content', $contentopts, $workshop->context,
|
||||
'mod_workshop', 'submission_content', $submission->id);
|
||||
|
||||
+6
-1
@@ -77,7 +77,12 @@ if (can_use_html_editor()) {
|
||||
|
||||
$errorstring = '';
|
||||
|
||||
$editoroptions = array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false);
|
||||
$editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => false,
|
||||
'context' => $systemcontext
|
||||
);
|
||||
$tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
|
||||
|
||||
$tagform = new tag_edit_form(null, compact('editoroptions'));
|
||||
|
||||
+8
-1
@@ -143,7 +143,14 @@ profile_load_data($user);
|
||||
|
||||
|
||||
// Prepare the editor and create form
|
||||
$editoroptions = array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'forcehttps'=>false);
|
||||
$editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => false,
|
||||
'forcehttps' => false,
|
||||
'context' => $personalcontext
|
||||
);
|
||||
|
||||
$user = file_prepare_standard_editor($user, 'description', $editoroptions, $personalcontext, 'user', 'profile', 0);
|
||||
$userform = new user_edit_form(null, array('editoroptions'=>$editoroptions));
|
||||
if (empty($user->country)) {
|
||||
|
||||
+15
-2
@@ -113,12 +113,25 @@ if (!empty($CFG->usetags)) {
|
||||
|
||||
if ($user->id !== -1) {
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
|
||||
$editoroptions = array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'forcehttps'=>false);
|
||||
$editoroptions = array(
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
'trusttext' => false,
|
||||
'forcehttps' => false,
|
||||
'context' => $usercontext
|
||||
);
|
||||
|
||||
$user = file_prepare_standard_editor($user, 'description', $editoroptions, $usercontext, 'user', 'profile', 0);
|
||||
} else {
|
||||
$usercontext = null;
|
||||
// This is a new user, we don't want to add files here
|
||||
$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false);
|
||||
$editoroptions = array(
|
||||
'maxfiles'=>0,
|
||||
'maxbytes'=>0,
|
||||
'trusttext'=>false,
|
||||
'forcehttps'=>false,
|
||||
'context' => $coursecontext
|
||||
);
|
||||
}
|
||||
|
||||
//create form
|
||||
|
||||
Reference in New Issue
Block a user