MDL-72050 filelib: Add function for deleting draftarea

This commit is contained in:
Stefan Hanauska
2025-03-13 08:17:34 +01:00
parent 1e51bc0b9c
commit 09d3d56db5
2 changed files with 20 additions and 0 deletions
+13
View File
@@ -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