mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-32990 - Repositories - Updating Box.net API calls to use HTTPS
This commit is contained in:
parent
f4a9bf65da
commit
9e9382530f
2 changed files with 14 additions and 10 deletions
|
@ -36,8 +36,10 @@ class boxclient {
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $auth_token = '';
|
public $auth_token = '';
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $_box_api_url = 'http://box.net/api/1.0/rest';
|
private $_box_api_url = 'https://www.box.com/api/1.0/rest';
|
||||||
private $_box_api_upload_url = 'http://upload.box.net/api/1.0/upload';
|
private $_box_api_upload_url = 'http://upload.box.com/api/1.0/upload';
|
||||||
|
private $_box_api_download_url = 'http://www.box.com/api/1.0/download';
|
||||||
|
private $_box_api_auth_url = 'http://www.box.com/api/1.0/auth';
|
||||||
private $_error_code = '';
|
private $_error_code = '';
|
||||||
private $_error_msg = '';
|
private $_error_msg = '';
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
|
@ -67,6 +69,7 @@ class boxclient {
|
||||||
function makeRequest($method, $params = array()) {
|
function makeRequest($method, $params = array()) {
|
||||||
$this->_clearErrors();
|
$this->_clearErrors();
|
||||||
$c = new curl(array('debug'=>$this->debug, 'cache'=>true, 'module_cache'=>'repository'));
|
$c = new curl(array('debug'=>$this->debug, 'cache'=>true, 'module_cache'=>'repository'));
|
||||||
|
$c->setopt(array('CURLOPT_FOLLOWLOCATION'=>1));
|
||||||
try {
|
try {
|
||||||
if ($method == 'upload'){
|
if ($method == 'upload'){
|
||||||
$request = $this->_box_api_upload_url.'/'.
|
$request = $this->_box_api_upload_url.'/'.
|
||||||
|
@ -141,7 +144,7 @@ class boxclient {
|
||||||
'__login'=>1
|
'__login'=>1
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
$ret = $c->post('http://www.box.net/api/1.0/auth/'.$ticket, $param);
|
$ret = $c->post($this->_box_api_auth_url.$ticket, $param);
|
||||||
} catch (moodle_exception $e) {
|
} catch (moodle_exception $e) {
|
||||||
$this->setError(0, 'connection time-out or invalid url');
|
$this->setError(0, 'connection time-out or invalid url');
|
||||||
return false;
|
return false;
|
||||||
|
@ -174,6 +177,7 @@ class boxclient {
|
||||||
$params['onelevel'] = 1;
|
$params['onelevel'] = 1;
|
||||||
$params['params[]'] = 'nozip';
|
$params['params[]'] = 'nozip';
|
||||||
$c = new curl(array('debug'=>$this->debug, 'cache'=>true, 'module_cache'=>'repository'));
|
$c = new curl(array('debug'=>$this->debug, 'cache'=>true, 'module_cache'=>'repository'));
|
||||||
|
$c->setopt(array('CURLOPT_FOLLOWLOCATION'=>1));
|
||||||
try {
|
try {
|
||||||
$args = array();
|
$args = array();
|
||||||
$xml = $c->get($this->_box_api_url, $params);
|
$xml = $c->get($this->_box_api_url, $params);
|
||||||
|
@ -224,7 +228,7 @@ class boxclient {
|
||||||
foreach($o->folder as $z){
|
foreach($o->folder as $z){
|
||||||
$tmp = array('title'=>(string)$z->attributes()->name,
|
$tmp = array('title'=>(string)$z->attributes()->name,
|
||||||
'size'=>0, 'date'=>userdate(time()),
|
'size'=>0, 'date'=>userdate(time()),
|
||||||
'thumbnail'=>'http://www.box.net/img/small_folder_icon.gif',
|
'thumbnail'=>'https://www.box.com/img/small_folder_icon.gif',
|
||||||
'path'=>array('name'=>(string)$z->attributes()->name, 'path'=>(int)$z->attributes()->id));
|
'path'=>array('name'=>(string)$z->attributes()->name, 'path'=>(int)$z->attributes()->id));
|
||||||
$tmp['children'] = array();
|
$tmp['children'] = array();
|
||||||
$this->buildtree($z, $tmp['children']);
|
$this->buildtree($z, $tmp['children']);
|
||||||
|
@ -235,13 +239,13 @@ class boxclient {
|
||||||
foreach($val as $file){
|
foreach($val as $file){
|
||||||
$thumbnail = (string)$file->attributes()->thumbnail;
|
$thumbnail = (string)$file->attributes()->thumbnail;
|
||||||
if (!preg_match('#^(?:http://)?([^/]+)#i', $thumbnail)) {
|
if (!preg_match('#^(?:http://)?([^/]+)#i', $thumbnail)) {
|
||||||
$thumbnail = 'http://www.box.net'.$thumbnail;
|
$thumbnail = 'http://www.box.com'.$thumbnail;
|
||||||
}
|
}
|
||||||
$tmp = array('title'=>(string)$file->attributes()->file_name,
|
$tmp = array('title'=>(string)$file->attributes()->file_name,
|
||||||
'size'=>display_size((int)$file->attributes()->size),
|
'size'=>display_size((int)$file->attributes()->size),
|
||||||
'thumbnail'=>$thumbnail,
|
'thumbnail'=>$thumbnail,
|
||||||
'date'=>userdate((int)$file->attributes()->updated),
|
'date'=>userdate((int)$file->attributes()->updated),
|
||||||
'source'=>'http://box.net/api/1.0/download/'
|
'source'=> $this->_box_api_download_url
|
||||||
.$this->auth_token.'/'.(string)$file->attributes()->id,
|
.$this->auth_token.'/'.(string)$file->attributes()->id,
|
||||||
'url'=>(string)$file->attributes()->shared_link);
|
'url'=>(string)$file->attributes()->shared_link);
|
||||||
$tree[] = $tmp;
|
$tree[] = $tmp;
|
||||||
|
@ -290,7 +294,7 @@ class boxclient {
|
||||||
if (preg_match('#^(?:http://)?([^/]+)#i', $a['attributes']['THUMBNAIL'])) {
|
if (preg_match('#^(?:http://)?([^/]+)#i', $a['attributes']['THUMBNAIL'])) {
|
||||||
@$ret_array['thumbnail'][$i] = $a['attributes']['THUMBNAIL'];
|
@$ret_array['thumbnail'][$i] = $a['attributes']['THUMBNAIL'];
|
||||||
} else {
|
} else {
|
||||||
@$ret_array['thumbnail'][$i] = 'http://www.box.net'.$a['attributes']['THUMBNAIL'];
|
@$ret_array['thumbnail'][$i] = 'http://www.box.com'.$a['attributes']['THUMBNAIL'];
|
||||||
}
|
}
|
||||||
$entry_count++;
|
$entry_count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ class repository_boxnet extends repository {
|
||||||
$list[] = array('title'=>$v,
|
$list[] = array('title'=>$v,
|
||||||
'size'=>$filesizes[$n],
|
'size'=>$filesizes[$n],
|
||||||
'date'=>$filedates[$n],
|
'date'=>$filedates[$n],
|
||||||
'source'=>'http://box.net/api/1.0/download/'
|
'source'=>'https://www.box.com/api/1.0/download/'
|
||||||
.$this->auth_token.'/'.$fileids[$n],
|
.$this->auth_token.'/'.$fileids[$n],
|
||||||
'thumbnail' => $OUTPUT->pix_url(file_extension_icon($v, 90))->out(false));
|
'thumbnail' => $OUTPUT->pix_url(file_extension_icon($v, 90))->out(false));
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ class repository_boxnet extends repository {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$ret['list'] = array();
|
$ret['list'] = array();
|
||||||
$tree = $this->boxclient->getfiletree($path);
|
$tree = $this->boxclient->getfiletree($path);
|
||||||
$ret['manage'] = 'http://www.box.net/files';
|
$ret['manage'] = 'http://www.box.com/files';
|
||||||
$ret['path'] = array(array('name'=>'Root', 'path'=>0));
|
$ret['path'] = array(array('name'=>'Root', 'path'=>0));
|
||||||
if(!empty($tree)) {
|
if(!empty($tree)) {
|
||||||
$ret['list'] = array_filter($tree, array($this, 'filter'));
|
$ret['list'] = array_filter($tree, array($this, 'filter'));
|
||||||
|
@ -176,7 +176,7 @@ class repository_boxnet extends repository {
|
||||||
if ($this->options['ajax']) {
|
if ($this->options['ajax']) {
|
||||||
$popup_btn = new stdClass();
|
$popup_btn = new stdClass();
|
||||||
$popup_btn->type = 'popup';
|
$popup_btn->type = 'popup';
|
||||||
$popup_btn->url = ' https://www.box.net/api/1.0/auth/' . $t['ticket'];
|
$popup_btn->url = ' https://www.box.com/api/1.0/auth/' . $t['ticket'];
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$ret['login'] = array($popup_btn);
|
$ret['login'] = array($popup_btn);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue