Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-27330 repository dropbox plugin

Dropbox changed authorization URL, and added a few error check code
  • Loading branch information...
commit 810aea11df5a9b3714f499de6cc7397373705e33 1 parent b8df941
@dcai dcai authored
Showing with 10 additions and 3 deletions.
  1. +1 −0  lang/en/repository.php
  2. +9 −3 repository/dropbox/lib.php
View
1  lang/en/repository.php
@@ -151,6 +151,7 @@
$string['repositories'] = 'Repositories';
$string['repository'] = 'Repository';
$string['repositorycourse'] = 'Course repositories';
+$string['repositoryerror'] = 'Remote repository returned error: {$a}';
$string['save'] = 'Save';
$string['saveas'] = 'Save as';
$string['saved'] = 'Saved';
View
12 repository/dropbox/lib.php
@@ -66,7 +66,7 @@ public function __construct($repositoryid, $context = SYSCONTEXTID, $options = a
'oauth_consumer_key'=>$this->dropbox_key,
'oauth_consumer_secret'=>$this->dropbox_secret,
'oauth_callback' => $this->callback->out(false),
- 'api_root' => 'http://api.dropbox.com/0/oauth',
+ 'api_root' => 'http://www.dropbox.com/0/oauth',
);
$this->dropbox = new dropbox($args);
@@ -163,10 +163,16 @@ public function get_listing($path = '', $page = '1') {
}
}
- $files = $result->contents;
- if (!is_array($files) || empty($files)) {
+ if (!empty($result->error)) {
+ // reset access key
+ set_user_preference($this->setting.'_access_key', '');
+ set_user_preference($this->setting.'_access_secret', '');
+ throw new repository_exception('repositoryerror', 'repository', '', $result->error);
+ }
+ if (empty($result->contents) or !is_array($result->contents)) {
return $list;
}
+ $files = $result->contents;
foreach ($files as $file) {
if ($file->is_dir) {
$list['list'][] = array(
Please sign in to comment.
Something went wrong with that request. Please try again.