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

@ -188,6 +188,29 @@ class boxclient {
return $ret;
}
/**
* Get box.net file info
*
* @param string $fileid
* @return string|null
*/
function get_file_info($fileid) {
$this->_clearErrors();
$params = array();
$params['action'] = 'get_file_info';
$params['file_id'] = $fileid;
$params['auth_token'] = $this->auth_token;
$params['api_key'] = $this->api_key;
$http = new curl(array('debug'=>$this->debug, 'cache'=>true, 'module_cache'=>'repository'));
$xml = $http->get($this->_box_api_url, $params);
$o = simplexml_load_string(trim($xml));
if ($o->status == 's_get_file_info') {
return $o->info;
} else {
return null;
}
}
/**
* @param array $sax
* @param array $tree Passed by reference

View file

@ -770,6 +770,7 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
$newhashes = array();
foreach ($draftfiles as $file) {
$newhash = $fs->get_pathname_hash($contextid, $component, $filearea, $itemid, $file->get_filepath(), $file->get_filename());
file_restore_source_field_from_draft_file($file);
$newhashes[$newhash] = $file;
}
$filecount = 0;
@ -790,7 +791,6 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
continue;
}
file_restore_source_field_from_draft_file($newfile);
// Replaced file content
if ($oldfile->get_contenthash() != $newfile->get_contenthash()) {
$oldfile->replace_content_with($newfile);