Merge branch 'MDL-72050-404' of https://github.com/sh-csg/moodle into MOODLE_404_STABLE
This commit is contained in:
@@ -1313,6 +1313,19 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a draft area.
|
||||
*
|
||||
* @param int $draftitemid Id of the draft area to clear.
|
||||
* @return boolean success
|
||||
*/
|
||||
function file_clear_draft_area(int $draftitemid): bool {
|
||||
global $USER;
|
||||
$fs = get_file_storage();
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
return $fs->delete_area_files($usercontext->id, 'user', 'draft', $draftitemid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the draft file area URLs in some content to @@PLUGINFILE@@ tokens
|
||||
* ready to be saved in the database. Normally, this is done automatically by
|
||||
|
||||
@@ -25,6 +25,9 @@ completed modules to the DBMS improving the performance of the method.
|
||||
user has been redirected to the expected location.
|
||||
e.g. `And the url should match "/mod/forum/view\.php\?id=[0-9]+"`
|
||||
|
||||
* A new function `file_clear_draft_area()` has been added to delete the files in a draft area.
|
||||
For more information see [MDL-72050](https://tracker.moodle.org/browse/MDL-72050)
|
||||
|
||||
=== 4.4.5 ===
|
||||
|
||||
* All uses of the following PHPUnit methods have been removed as these methods are deprecated upstream without direct replacement:
|
||||
|
||||
@@ -481,6 +481,7 @@ class qformat_default {
|
||||
$question->questiontext = file_save_draft_area_files($question->questiontextitemid,
|
||||
$this->importcontext->id, 'question', 'questiontext', $question->id,
|
||||
$fileoptions, $question->questiontext);
|
||||
file_clear_draft_area($question->questiontextitemid);
|
||||
} else if (isset($question->questiontextfiles)) {
|
||||
foreach ($question->questiontextfiles as $file) {
|
||||
question_bank::get_qtype($question->qtype)->import_file(
|
||||
@@ -491,6 +492,7 @@ class qformat_default {
|
||||
$question->generalfeedback = file_save_draft_area_files($question->generalfeedbackitemid,
|
||||
$this->importcontext->id, 'question', 'generalfeedback', $question->id,
|
||||
$fileoptions, $question->generalfeedback);
|
||||
file_clear_draft_area($question->generalfeedbackitemid);
|
||||
} else if (isset($question->generalfeedbackfiles)) {
|
||||
foreach ($question->generalfeedbackfiles as $file) {
|
||||
question_bank::get_qtype($question->qtype)->import_file(
|
||||
|
||||
@@ -1446,8 +1446,10 @@ class question_type {
|
||||
protected function import_or_save_files($field, $context, $component, $filearea, $itemid) {
|
||||
if (!empty($field['itemid'])) {
|
||||
// This is the normal case. We are safing the questions editing form.
|
||||
return file_save_draft_area_files($field['itemid'], $context->id, $component,
|
||||
$result = file_save_draft_area_files($field['itemid'], $context->id, $component,
|
||||
$filearea, $itemid, $this->fileoptions, trim($field['text']));
|
||||
file_clear_draft_area($field['itemid']);
|
||||
return $result;
|
||||
|
||||
} else if (!empty($field['files'])) {
|
||||
// This is the case when we are doing an import.
|
||||
|
||||
Reference in New Issue
Block a user