MDL-33513 box.net repository should have filename in source field

This commit is contained in:
Dongsheng Cai 2012-06-11 17:41:32 +10:00
parent 8a288971e2
commit 39c60294a6
2 changed files with 32 additions and 1 deletions

View File

@ -188,6 +188,30 @@ class boxclient {
return $ret;
}
/**
* Get box.net file info
*
* @param string $fileid
* @param array $params
* @return array|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

@ -300,7 +300,14 @@ class repository_boxnet extends repository {
* @return string|null
*/
public function get_file_source_info($url) {
return $url;
$array = explode('/', $url);
$fileid = array_pop($array);
$fileinfo = $this->boxclient->get_file_info($fileid);
if (!empty($fileinfo)) {
return 'boxnet:' . (string)$fileinfo->file_name;
} else {
return $url;
}
}
/**