MDL-58765 repository: controlled links fix
If a file is selected as a controlled link, only copy it to the system account the first time the form is saved.
This commit is contained in:
@@ -871,6 +871,12 @@ class repository_googledocs extends repository {
|
||||
// finally update the reference to contain the share link if it was not
|
||||
// already there (and point to new file id if we copied).
|
||||
|
||||
// Get the details from the reference.
|
||||
$source = json_decode($reference);
|
||||
if (!empty($source->usesystem)) {
|
||||
// If we already copied this file to the system account - we are done.
|
||||
return $reference;
|
||||
}
|
||||
|
||||
// Check this issuer is enabled.
|
||||
if ($this->disabled) {
|
||||
@@ -894,8 +900,6 @@ class repository_googledocs extends repository {
|
||||
throw new repository_exception('errorwhilecommunicatingwith', 'repository', '', $details);
|
||||
}
|
||||
|
||||
// Get the details from the reference.
|
||||
$source = json_decode($reference);
|
||||
$userservice = new repository_googledocs\rest($userauth);
|
||||
$systemservice = new repository_googledocs\rest($systemauth);
|
||||
|
||||
|
||||
@@ -814,6 +814,11 @@ class repository_onedrive extends repository {
|
||||
// then set the permissions so anyone with the share link can view,
|
||||
// finally update the reference to contain the share link if it was not
|
||||
// already there (and point to new file id if we copied).
|
||||
$source = json_decode($reference);
|
||||
if (!empty($source->usesystem)) {
|
||||
// If we already copied this file to the system account - we are done.
|
||||
return $reference;
|
||||
}
|
||||
|
||||
// Get a system and a user oauth client.
|
||||
$systemauth = \core\oauth2\api::get_system_oauth_client($this->issuer);
|
||||
@@ -823,8 +828,6 @@ class repository_onedrive extends repository {
|
||||
throw new repository_exception('errorwhilecommunicatingwith', 'repository', '', $details);
|
||||
}
|
||||
|
||||
$source = json_decode($reference);
|
||||
|
||||
$userauth = $this->get_user_oauth_client();
|
||||
if ($userauth === false) {
|
||||
$details = 'Cannot connect as current user';
|
||||
|
||||
Reference in New Issue
Block a user