Merge branch 'wip-MDL-33832-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Dan Poltawski
2012-06-20 16:55:29 +08:00
9 changed files with 17 additions and 17 deletions
+2 -2
View File
@@ -601,7 +601,7 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
}
// 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);
}
@@ -679,7 +679,7 @@ function file_get_submitted_draft_itemid($elname) {
* @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;
+1 -2
View File
@@ -155,9 +155,8 @@ M.form_filemanager.init = function(Y, options) {
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) {
+1 -1
View File
@@ -319,7 +319,7 @@ class repository_boxnet extends repository {
$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;
}
+1 -1
View File
@@ -432,7 +432,7 @@ class repository_dropbox extends repository {
* @return string|null
*/
public function get_file_source_info($filepath) {
return 'Dropbox:' . $filepath;
return 'Dropbox: ' . $filepath;
}
/**
+2 -1
View File
@@ -306,7 +306,8 @@ case 'download':
$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'));
+3
View File
@@ -1233,6 +1233,9 @@ abstract class 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;
}
+4 -8
View File
@@ -241,6 +241,10 @@ switch ($action) {
}
}
// {@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
@@ -266,10 +270,6 @@ switch ($action) {
$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(),
@@ -307,10 +307,6 @@ switch ($action) {
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');
+1 -1
View File
@@ -126,7 +126,7 @@ class repository_s3 extends repository {
* @return string
*/
public function get_file_source_info($filepath) {
return 'Amazon S3:' . $filepath;
return 'Amazon S3: ' . $filepath;
}
/**
+2 -1
View File
@@ -146,7 +146,8 @@ class repository_upload extends repository {
@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);