}
public function get_name() {
- global $COURSE; //TODO: this is deprecated (skodak)
- return $COURSE->fullname;
+ list($context, $course, $cm) = get_context_info_array($this->context->id);
+ if (!empty($course)) {
+ return get_string('courselegacyfiles') . $course->shortname;
+ } else {
+ return get_string('courselegacyfiles');
+ }
}
public function supported_returntypes() {
$string['remember'] = 'Remember me';
$string['pluginname'] = 'Dropbox';
$string['apikey'] = 'Dropbox API Key';
+$string['sandbox'] = 'Dropbox sandbox';
$string['secret'] = 'Dropbox Secret';
$string['instruction'] = 'You can get your API Key and secret from <a href="http://www.dropbox.com/developers/apps">Dropbox developers</a>';
$string['dropbox:view'] = 'View a Dropbox folder';
} else {
$path = file_correct_filepath($path);
}
- $result = $this->dropbox->get_listing($path, $this->access_key, $this->access_secret);
- $current_path = file_correct_filepath($result->path);
- if (empty($result->path)) {
- $current_path = '/';
- }
$list = array();
$list['list'] = array();
+ $list['manage'] = false;
+ $list['dynload'] = true;
+ $list['nosearch'] = true;
// process breacrumb trail
$list['path'] = array(
- array('name'=>'Dropbox Sandbox', 'path'=>'/')
+ array('name'=>get_string('sandbox', 'repository_dropbox'), 'path'=>'/')
);
+
+ $result = $this->dropbox->get_listing($path, $this->access_key, $this->access_secret);
+ if (!is_object($result) || empty($result)) {
+ return $list;
+ }
+ if (empty($result->path)) {
+ $current_path = '/';
+ } else {
+ $current_path = file_correct_filepath($result->path);
+ }
+
$trail = '';
if (!empty($path)) {
$parts = explode('/', $path);
$list['path'][] = array('name'=>$path, 'path'=>$path);
}
}
- $list['manage'] = false;
- $list['dynload'] = true;
- $list['nosearch'] = true;
$files = $result->contents;
+ if (!is_array($files) || empty($files)) {
+ return $list;
+ }
foreach ($files as $file) {
if ($file->is_dir) {
$list['list'][] = array(