mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 14:40:06 +01:00
MDL-33513 box.net repository should have filename in source field
This commit is contained in:
parent
8a288971e2
commit
39c60294a6
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user