From b0f5d070e7bdc91c9334aec95c2864e0cdcfb830 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Mon, 15 Nov 2010 22:59:06 +0000 Subject: [PATCH] MDL-23978 portfolio: do not cleanup images with portfolio URI scheme The problem was in the order of the content preparing. Now when the filters are always skipped (they have to) we must always run format_text() first. That will prepare nice HTML in which we just rewrite the portfolio URIs. Note that we are still calling clean_text() so that we do not export malicious code for portfolios like File download. In the future, this may be changed, made format specific or even per-export configurable. As a side product of the patch, I have re-enabled online assignment portfolio export and switched $options->para to false consistently. --- mod/assignment/type/online/assignment.class.php | 4 ++-- mod/forum/locallib.php | 6 +++--- mod/glossary/locallib.php | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mod/assignment/type/online/assignment.class.php b/mod/assignment/type/online/assignment.class.php index 5c3b455f677..f4dce79828a 100644 --- a/mod/assignment/type/online/assignment.class.php +++ b/mod/assignment/type/online/assignment.class.php @@ -272,7 +272,7 @@ class assignment_online extends assignment_base { } function portfolio_exportable() { - return false; // not until MDL-22001 is fixed :( + return true; } function portfolio_load_data($caller) { @@ -296,7 +296,7 @@ class assignment_online extends assignment_base { function portfolio_prepare_package($exporter, $user) { $submission = $this->get_submission($user->id); $options = new stdClass(); - $options->para = true; + $options->para = false; $options->filter = false; $html = format_text($submission->data1, $submission->data2, $options); $html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', $this->filearea, $submission->id, $exporter->get('format')); diff --git a/mod/forum/locallib.php b/mod/forum/locallib.php index b3a82171255..e790f13c42e 100644 --- a/mod/forum/locallib.php +++ b/mod/forum/locallib.php @@ -294,11 +294,11 @@ class forum_portfolio_caller extends portfolio_module_caller_base { $viewfullnames = true; // format the post body $options = new stdClass(); - $options->para = true; + $options->para = false; $options->filter = false; $format = $this->get('exporter')->get('format'); - $formattedtext = portfolio_rewrite_pluginfile_urls($post->message, $this->modcontext->id, 'mod_forum', 'post', $post->id, $format); - $formattedtext = format_text($formattedtext, $post->messageformat, $options, $this->get('course')->id); + $formattedtext = format_text($post->message, $post->messageformat, $options, $this->get('course')->id); + $formattedtext = portfolio_rewrite_pluginfile_urls($formattedtext, $this->modcontext->id, 'mod_forum', 'post', $post->id, $format); $output = ''; diff --git a/mod/glossary/locallib.php b/mod/glossary/locallib.php index eadbb0bb793..331375e8038 100644 --- a/mod/glossary/locallib.php +++ b/mod/glossary/locallib.php @@ -386,14 +386,12 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base { $output .= '
' . "\n"; $output .= '
'; - $output .= format_text($OUTPUT->heading('' . $entry->concept . '', 3, 'nolink'), FORMAT_MOODLE, $options); + $output .= format_text($OUTPUT->heading($entry->concept, 3), FORMAT_MOODLE, $options); $output .= '
' . "\n"; + $entry->definition = format_text($entry->definition, $entry->definitionformat, $options); + $output .= portfolio_rewrite_pluginfile_urls($entry->definition, $context->id, 'mod_glossary', 'entry', $entry->id, $format); - $entry->definition = portfolio_rewrite_pluginfile_urls($entry->definition, $context->id, 'mod_glossary', 'entry', $entry->id, $format); - - $options->overflowdiv = true; - $output .= format_text($entry->definition, $entry->definitionformat, $options); if (isset($entry->footer)) { $output .= $entry->footer; }