- also supress the error on unserialise (because people already may have broken files.source field)
- also display details about unparseable JSON error
- make source field look the same across repositories
}
// find the file this draft file was created from and count all references in local
// system pointing to that file
- $source = unserialize($file->get_source());
+ $source = @unserialize($file->get_source());
if (isset($source->original)) {
$item->refcount = $fs->search_references_count($source->original);
}
* @return stored_file
*/
function file_restore_source_field_from_draft_file($storedfile) {
- $source = unserialize($storedfile->get_source());
+ $source = @unserialize($storedfile->get_source());
if (!empty($source)) {
if (is_object($source)) {
$restoredsource = $source->source;
try {
data = Y.JSON.parse(o.responseText);
} catch(e) {
- // TODO display error
scope.print_msg(M.str.repository.invalidjson, 'error');
- //scope.display_error(M.str.repository.invalidjson+'<pre>'+stripHTML(o.responseText)+'</pre>', 'invalidjson')
+ Y.error(M.str.repository.invalidjson+":\n"+o.responseText);
return;
}
if (data && data.tree && scope.set_current_tree) {
$fileid = array_pop($array);
$fileinfo = $this->boxclient->get_file_info($fileid);
if (!empty($fileinfo)) {
- return 'Box:' . (string)$fileinfo->file_name;
+ return 'Box: ' . (string)$fileinfo->file_name;
} else {
return $url;
}
* @return string|null
*/
public function get_file_source_info($filepath) {
- return 'Dropbox:' . $filepath;
+ return 'Dropbox: ' . $filepath;
}
/**
$record->userid = $USER->id;
$record->contextid = $user_context->id;
- $record->source = serialize((object)array('source' => $thefile['url']));
+ $sourcefield = $repo->get_file_source_info($thefile['url']);
+ $record->source = repository::build_source_field($sourcefield);
try {
$info = repository::move_to_filepool($thefile['path'], $record);
redirect($home_url, get_string('downloadsucc', 'repository'));
* @return string|null
*/
public function get_file_source_info($url) {
+ if ($this->has_moodle_files()) {
+ return $this->get_reference_details($url, 0);
+ }
return $url;
}
}
}
+ // {@link repository::build_source_field()}
+ $sourcefield = $repo->get_file_source_info($source);
+ $record->source = $repo::build_source_field($sourcefield);
+
if ($usefilereference) {
$reference = $repo->get_file_reference($source);
// get reference life time from repo
$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(),
throw new file_exception('maxbytes');
}
- // {@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)) {
$info['e'] = get_string('error', 'moodle');
* @return string
*/
public function get_file_source_info($filepath) {
- return 'Amazon S3:' . $filepath;
+ return 'Amazon S3: ' . $filepath;
}
/**
@chmod($_FILES[$elname]['tmp_name'], $permissions);
// {@link repository::build_source_field()}
- $record->source = self::build_source_field($_FILES[$elname]['name']);
+ $sourcefield = $this->get_file_source_info($_FILES[$elname]['name']);
+ $record->source = self::build_source_field($sourcefield);
if (empty($saveas_filename)) {
$record->filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);