mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-54869 files: Create new required functions
This was a complex change requiring three new functions: file_merge_files_from_draft_area_into_filearea - To just add files from a draft area into a real one (just adding or updating, not deleting) file_merge_draft_area_into_draft_area - To merge files from two draft areas, used by the latest for creating a draft area with all the original files plus the new ones. file_overwrite_existing_draftfile - Required to update existing files not losing metadata or references. The whole process is the following: User uploads a file (upload.php) Client gets a new draftid A containing the file only (return of upload.php) Client requests to merge that draftid in the user's private files (core_user_add_user_private_files) Server prepares a new UNUSED draftid B from existing area Server merges A into B Server saves the draft B into the final area
This commit is contained in:
parent
d089e4984d
commit
460897052e
3 changed files with 356 additions and 2 deletions
|
@ -159,7 +159,7 @@ foreach ($files as $file) {
|
|||
$file_record->itemid = $itemid;
|
||||
$file_record->license = $CFG->sitedefaultlicense;
|
||||
$file_record->author = fullname($authenticationinfo['user']);
|
||||
$file_record->source = '';
|
||||
$file_record->source = serialize((object)array('source' => $file->filename));
|
||||
|
||||
//Check if the file already exist
|
||||
$existingfile = $fs->file_exists($file_record->contextid, $file_record->component, $file_record->filearea,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue