in locallib.php [85:106]
private function copy_area_files(file_storage $fs, $fromcontextid, $fromcomponent, $fromfilearea, $fromitemid, $tocontextid,
$tocomponent, $tofilearea, $toitemid) {
$newfilerecord = new stdClass();
$newfilerecord->contextid = $tocontextid;
$newfilerecord->component = $tocomponent;
$newfilerecord->filearea = $tofilearea;
$newfilerecord->itemid = $toitemid;
if ($files = $fs->get_area_files($fromcontextid, $fromcomponent, $fromfilearea, $fromitemid)) {
foreach ($files as $file) {
if ($file->is_directory() and $file->get_filepath() === '/') {
// We need a way to mark the age of each draft area.
// By not copying the root dir we force it to be created
// automatically with current timestamp.
continue;
}
$newfile = $fs->create_file_from_storedfile($newfilerecord, $file);
}
}
return true;
}