Merge branch 'dev_MDL-33513_files_source' of git://github.com/danpoltawski/moodle

This commit is contained in:
Dan Poltawski 2012-06-14 11:12:21 +08:00
commit cd925ac79b
13 changed files with 180 additions and 32 deletions

View file

@ -265,6 +265,11 @@ switch ($action) {
$event['existingfile']->filename = $saveas_filename;
$event['existingfile']->url = moodle_url::make_draftfile_url($itemid, $saveas_path, $saveas_filename)->out();;
} else {
// {@link repository::build_source_field()}
$sourcefield = $repo->get_file_source_info($source);
$record->source = $repo::build_source_field($sourcefield);
$storedfile = $fs->create_file_from_reference($record, $repo_id, $reference);
$event = array(
'url'=>moodle_url::make_draftfile_url($storedfile->get_itemid(), $storedfile->get_filepath(), $storedfile->get_filename())->out(),
@ -302,14 +307,9 @@ switch ($action) {
throw new file_exception('maxbytes');
}
// {@link file_restore_source_field_from_draft_file()}
$sourcefield = '';
if (!empty($downloadedfile['url'])) {
$source = new stdClass;
$source->source = $downloadedfile['url'];
$sourcefield = serialize($source);
}
$record->source = $sourcefield;
// {@link repository::build_source_field()}
$sourcefield = $repo->get_file_source_info($source);
$record->source = $repo::build_source_field($sourcefield);
$info = repository::move_to_filepool($downloadedfile['path'], $record);
if (empty($info)) {