Merge branch 'MDL-58800-master' of git://github.com/damyon/moodle
This commit is contained in:
@@ -432,11 +432,17 @@ class repository_googledocs extends repository {
|
||||
throw new repository_exception('cannotdownload', 'repository');
|
||||
}
|
||||
|
||||
$client = $this->get_user_oauth_client();
|
||||
$base = 'https://www.googleapis.com/drive/v3';
|
||||
|
||||
$source = json_decode($reference);
|
||||
|
||||
$client = null;
|
||||
if (!empty($source->usesystem)) {
|
||||
$client = \core\oauth2\api::get_system_oauth_client($this->issuer);
|
||||
} else {
|
||||
$client = $this->get_user_oauth_client();
|
||||
}
|
||||
|
||||
$base = 'https://www.googleapis.com/drive/v3';
|
||||
|
||||
$newfilename = false;
|
||||
if ($source->exportformat == 'download') {
|
||||
$params = ['alt' => 'media'];
|
||||
@@ -588,7 +594,7 @@ class repository_googledocs extends repository {
|
||||
$storedfile->get_filepath(),
|
||||
$storedfile->get_filename());
|
||||
|
||||
if (empty($options['offline']) && !empty($info) && $info->is_writable()) {
|
||||
if (empty($options['offline']) && !empty($info) && $info->is_writable() && !empty($source->usesystem)) {
|
||||
// Add the current user as an OAuth writer.
|
||||
$systemauth = \core\oauth2\api::get_system_oauth_client($this->issuer);
|
||||
|
||||
@@ -945,6 +951,7 @@ class repository_googledocs extends repository {
|
||||
// Update the returned reference so that the stored_file in moodle points to the newly copied file.
|
||||
$source->id = $newsource->id;
|
||||
$source->link = isset($newsource->webViewLink) ? $newsource->webViewLink : '';
|
||||
$source->usesystem = true;
|
||||
if (empty($source->link)) {
|
||||
$source->link = isset($newsource->webContentLink) ? $newsource->webContentLink : '';
|
||||
}
|
||||
@@ -967,6 +974,9 @@ class repository_googledocs extends repository {
|
||||
return get_string('unknownsource', 'repository');
|
||||
}
|
||||
$source = json_decode($reference);
|
||||
if (empty($source->usesystem)) {
|
||||
return '';
|
||||
}
|
||||
$systemauth = \core\oauth2\api::get_system_oauth_client($this->issuer);
|
||||
|
||||
if ($systemauth === false) {
|
||||
|
||||
Reference in New Issue
Block a user