Skip to content

Commit

Permalink
MDL-27896 context - Fixed editor context to observe filter status
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja committed Aug 12, 2011
1 parent 3a5778e commit b51aac3
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cohort/edit.php
Expand Up @@ -94,12 +94,12 @@
$editoroptions = array('maxfiles'=>0, 'context'=>$context); $editoroptions = array('maxfiles'=>0, 'context'=>$context);
if ($cohort->id) { if ($cohort->id) {
// edit existing // edit existing
$cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions); $cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions, $context);
$strheading = get_string('editcohort', 'cohort'); $strheading = get_string('editcohort', 'cohort');


} else { } else {
// add new // add new
$cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions); $cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions, $context);
$strheading = get_string('addcohort', 'cohort'); $strheading = get_string('addcohort', 'cohort');
} }


Expand Down
2 changes: 2 additions & 0 deletions course/edit.php
Expand Up @@ -77,6 +77,8 @@
} }
} }
$course->allowedmods = $allowedmods; $course->allowedmods = $allowedmods;
//add context for editor
$editoroptions['context'] = $coursecontext;
$course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0); $course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0);


} else { } else {
Expand Down
7 changes: 6 additions & 1 deletion course/editcategory.php
Expand Up @@ -49,7 +49,12 @@


$PAGE->set_pagelayout('admin'); $PAGE->set_pagelayout('admin');


$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>true); $editoroptions = array(
'maxfiles' => EDITOR_UNLIMITED_FILES,
'maxbytes' => $CFG->maxbytes,
'trusttext' => true,
'context' => $editorcontext
);
$category = file_prepare_standard_editor($category, 'description', $editoroptions, $editorcontext, 'coursecat', 'description', 0); $category = file_prepare_standard_editor($category, 'description', $editoroptions, $editorcontext, 'coursecat', 'description', 0);


$mform = new editcategory_form('editcategory.php', compact('category', 'editoroptions')); $mform = new editcategory_form('editcategory.php', compact('category', 'editoroptions'));
Expand Down
8 changes: 7 additions & 1 deletion grade/edit/outcome/edit.php
Expand Up @@ -103,7 +103,13 @@
// default return url // default return url
$gpr = new grade_plugin_return(); $gpr = new grade_plugin_return();
$returnurl = $gpr->get_return_url('index.php?id='.$courseid); $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)) { if (!empty($outcome_rec->id)) {
$outcome_rec = file_prepare_standard_editor($outcome_rec, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', $outcome_rec->id); $outcome_rec = file_prepare_standard_editor($outcome_rec, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', $outcome_rec->id);
Expand Down
8 changes: 7 additions & 1 deletion grade/edit/scale/edit.php
Expand Up @@ -88,7 +88,13 @@
// default return url // default return url
$gpr = new grade_plugin_return(); $gpr = new grade_plugin_return();
$returnurl = $gpr->get_return_url('index.php?id='.$courseid); $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)) { if (!empty($scale_rec->id)) {
$scale_rec = file_prepare_standard_editor($scale_rec, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale_rec->id); $scale_rec = file_prepare_standard_editor($scale_rec, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale_rec->id);
Expand Down
1 change: 1 addition & 0 deletions mod/assignment/lib.php
Expand Up @@ -2372,6 +2372,7 @@ protected function get_editor_options() {
$editoroptions['noclean'] = false; $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['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['maxbytes'] = $this->_customdata->maxbytes;
$editoroptions['context'] = $this->_customdata->context;
return $editoroptions; return $editoroptions;
} }


Expand Down
7 changes: 6 additions & 1 deletion mod/assignment/type/online/assignment.class.php
Expand Up @@ -38,7 +38,12 @@ function view() {


if ($editmode) { if ($editmode) {
// prepare form and process submitted data // 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 = new stdClass();
$data->id = $this->cm->id; $data->id = $this->cm->id;
Expand Down
4 changes: 4 additions & 0 deletions mod/feedback/item/label/lib.php
Expand Up @@ -49,6 +49,10 @@ function build_editform($item, $feedback, $cm) {
//preparing the editor for new file-api //preparing the editor for new file-api
$item->presentationformat = FORMAT_HTML; $item->presentationformat = FORMAT_HTML;
$item->presentationtrust = 1; $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, $item = file_prepare_standard_editor($item,
'presentation', //name of the form element 'presentation', //name of the form element
$this->presentationoptions, $this->presentationoptions,
Expand Down
1 change: 1 addition & 0 deletions mod/lesson/editpage.php
Expand Up @@ -84,6 +84,7 @@
$data = $editpage->properties(); $data = $editpage->properties();
$data->pageid = $editpage->id; $data->pageid = $editpage->id;
$data->id = $cm->id; $data->id = $cm->id;
$editoroptions['context'] = $context;
$data = file_prepare_standard_editor($data, 'contents', $editoroptions, $context, 'mod_lesson', 'page_contents', $editpage->id); $data = file_prepare_standard_editor($data, 'contents', $editoroptions, $context, 'mod_lesson', 'page_contents', $editpage->id);
$mform->set_data($data); $mform->set_data($data);
$PAGE->navbar->add(get_string('edit'), new moodle_url('/mod/lesson/edit.php', array('id'=>$id))); $PAGE->navbar->add(get_string('edit'), new moodle_url('/mod/lesson/edit.php', array('id'=>$id)));
Expand Down
2 changes: 2 additions & 0 deletions mod/wiki/pagelib.php
Expand Up @@ -535,6 +535,8 @@ protected function print_edit($content = null) {
switch ($format) { switch ($format) {
case 'html': case 'html':
$data->newcontentformat = FORMAT_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); $data = file_prepare_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
break; break;
default: default:
Expand Down
9 changes: 8 additions & 1 deletion mod/workshop/exsubmission.php
Expand Up @@ -103,7 +103,14 @@


$maxfiles = $workshop->nattachments; $maxfiles = $workshop->nattachments;
$maxbytes = $workshop->maxbytes; $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); $attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
$example = file_prepare_standard_editor($example, 'content', $contentopts, $workshop->context, $example = file_prepare_standard_editor($example, 'content', $contentopts, $workshop->context,
'mod_workshop', 'submission_content', $example->id); 'mod_workshop', 'submission_content', $example->id);
Expand Down
3 changes: 3 additions & 0 deletions mod/workshop/form/accumulative/lib.php
Expand Up @@ -116,6 +116,9 @@ public function get_edit_strategy_form($actionurl=null) {
$norepeats += self::ADDDIMS; $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 // prepare the embeded files
for ($i = 0; $i < $nodimensions; $i++) { for ($i = 0; $i < $nodimensions; $i++) {
// prepare all editor elements // prepare all editor elements
Expand Down
3 changes: 3 additions & 0 deletions mod/workshop/form/comments/lib.php
Expand Up @@ -116,6 +116,9 @@ public function get_edit_strategy_form($actionurl=null) {
$norepeats += self::ADDDIMS; $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 // prepare the embedded files
for ($i = 0; $i < $nodimensions; $i++) { for ($i = 0; $i < $nodimensions; $i++) {
// prepare all editor elements // prepare all editor elements
Expand Down
3 changes: 3 additions & 0 deletions mod/workshop/form/numerrors/lib.php
Expand Up @@ -120,6 +120,9 @@ public function get_edit_strategy_form($actionurl=null) {
$norepeats += self::ADDDIMS; $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 // prepare the embeded files
for ($i = 0; $i < $nodimensions; $i++) { for ($i = 0; $i < $nodimensions; $i++) {
// prepare all editor elements // prepare all editor elements
Expand Down
3 changes: 3 additions & 0 deletions mod/workshop/form/rubric/lib.php
Expand Up @@ -126,6 +126,9 @@ public function get_edit_strategy_form($actionurl=null) {
$norepeats += self::ADDDIMS; $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 // prepare the embeded files
for ($i = 0; $i < $nodimensions; $i++) { for ($i = 0; $i < $nodimensions; $i++) {
// prepare all editor elements // prepare all editor elements
Expand Down
9 changes: 8 additions & 1 deletion mod/workshop/submission.php
Expand Up @@ -124,7 +124,14 @@


$maxfiles = $workshop->nattachments; $maxfiles = $workshop->nattachments;
$maxbytes = $workshop->maxbytes; $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); $attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
$submission = file_prepare_standard_editor($submission, 'content', $contentopts, $workshop->context, $submission = file_prepare_standard_editor($submission, 'content', $contentopts, $workshop->context,
'mod_workshop', 'submission_content', $submission->id); 'mod_workshop', 'submission_content', $submission->id);
Expand Down
7 changes: 6 additions & 1 deletion tag/edit.php
Expand Up @@ -77,7 +77,12 @@


$errorstring = ''; $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); $tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);


$tagform = new tag_edit_form(null, compact('editoroptions')); $tagform = new tag_edit_form(null, compact('editoroptions'));
Expand Down
9 changes: 8 additions & 1 deletion user/edit.php
Expand Up @@ -143,7 +143,14 @@




// Prepare the editor and create form // 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); $user = file_prepare_standard_editor($user, 'description', $editoroptions, $personalcontext, 'user', 'profile', 0);
$userform = new user_edit_form(null, array('editoroptions'=>$editoroptions)); $userform = new user_edit_form(null, array('editoroptions'=>$editoroptions));
if (empty($user->country)) { if (empty($user->country)) {
Expand Down
9 changes: 8 additions & 1 deletion user/editadvanced.php
Expand Up @@ -113,7 +113,14 @@


if ($user->id !== -1) { if ($user->id !== -1) {
$usercontext = get_context_instance(CONTEXT_USER, $user->id); $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); $user = file_prepare_standard_editor($user, 'description', $editoroptions, $usercontext, 'user', 'profile', 0);
} else { } else {
$usercontext = null; $usercontext = null;
Expand Down

0 comments on commit b51aac3

Please sign in to comment.