MDL-58943 nextcloud: translatable exception messages

This commit is contained in:
Jan Dageförde 2018-10-30 23:26:29 +01:00 committed by Damyon Wiese
parent daef88213b
commit 4354a4286a
5 changed files with 14 additions and 13 deletions

View File

@ -271,7 +271,7 @@ class access_controlled_link_manager{
if ($response != 201) {
$this->systemwebdavclient->close();
$details = get_string('contactadminwith', 'repository_nextcloud',
"Folder path $fullpath could not be created in the system account.");
get_string('pathnotcreated', 'repository_nextcloud', $fullpath));
throw new request_exception(array('instance' => $this->repositoryname,
'errormessage' => $details));
}

View File

@ -80,7 +80,7 @@ class issuer_management {
public static function parse_endpoint_url(string $endpointname, \core\oauth2\issuer $issuer): array {
$url = $issuer->get_endpoint_url($endpointname);
if (empty($url)) {
throw new configuration_exception(sprintf('Endpoint %s not defined.', $endpointname));
throw new configuration_exception(get_string('endpointnotdefined', 'repository_nextcloud', $endpointname));
}
return parse_url($url);
}

View File

@ -59,3 +59,7 @@ $string['contactadminwith'] = 'The requested action could not be executed. In ca
$string['cannotconnect'] = 'The user could not be authenticated, please log in and then upload the file.';
$string['filenotaccessed'] = 'The requested file could not be accessed. Please check whether you have chosen a valid file and you are authenticated with the right account.';
$string['couldnotmove'] = 'The requested file could not be moved in the {$a} folder.';
$string['invalidresponse'] = 'Invalid server response.';
$string['noclientconnection'] = 'The OAuth clients could not be connected.';
$string['pathnotcreated'] = 'Folder path {$a} could not be created in the system account.';
$string['endpointnotdefined'] = 'Endpoint {$a} not defined.';

View File

@ -295,15 +295,14 @@ class repository_nextcloud extends repository {
$response = $this->ocsclient->call('create_share', $ocsparams);
$xml = simplexml_load_string($response);
$repositoryname = get_string('pluginname', 'repository_nextcloud');
if ($xml === false ) {
throw new \repository_nextcloud\request_exception(array('instance' => $repositoryname,
'errormessage' => 'Invalid response'));
throw new \repository_nextcloud\request_exception(array('instance' => $this->get_name(),
'errormessage' => get_string('invalidresponse', 'repository_nextcloud')));
}
if ((string)$xml->meta->status !== 'ok') {
throw new \repository_nextcloud\request_exception(array('instance' => $repositoryname, 'errormessage' => sprintf(
throw new \repository_nextcloud\request_exception(array('instance' => $this->get_name(), 'errormessage' => sprintf(
'(%s) %s', $xml->meta->statuscode, $xml->meta->message)));
}
@ -436,7 +435,7 @@ class repository_nextcloud extends repository {
// 1. assure the client and user is logged in.
if (empty($this->client) || $this->get_system_oauth_client() === false || $this->get_system_ocs_client() === null) {
$details = get_string('contactadminwith', 'repository_nextcloud',
'The OAuth client could not be connected.');
get_string('noclientconnection', 'repository_nextcloud'));
throw new \repository_nextcloud\request_exception(array('instance' => $repositoryname, 'errormessage' => $details));
}
@ -481,7 +480,7 @@ class repository_nextcloud extends repository {
$copyresult = $linkmanager->transfer_file_to_path($filetarget, $this->controlledlinkfoldername,
'move', $this->dav);
if (!($copyresult == 201 || $copyresult == 412)) {
throw new \repository_nextcloud\request_exception(array('instance' => $this->repositoryname,
throw new \repository_nextcloud\request_exception(array('instance' => $repositoryname,
'errormessage' => get_string('couldnotmove', 'repository_nextcloud', $this->controlledlinkfoldername)));
}
$shareid = $responsecreateshare['shareid'];
@ -828,9 +827,7 @@ class repository_nextcloud extends repository {
echo $OUTPUT->header();
$repositoryname = get_string('pluginname', 'repository_nextcloud');
$button = new single_button($url, get_string('logintoaccount', 'repository', $repositoryname),
$button = new single_button($url, get_string('logintoaccount', 'repository', $this->get_name()),
'post', true);
$button->add_action(new popup_action('click', $url, 'Login'));
$button->class = 'mdl-align';

View File

@ -449,7 +449,7 @@ XML;
// Method get_link correctly raises an exception that contains error code and message.
$this->expectException(\repository_nextcloud\request_exception::class);
$this->expectExceptionMessage(get_string('request_exception', 'repository_nextcloud', array('instance' => 'Nextcloud',
$this->expectExceptionMessage(get_string('request_exception', 'repository_nextcloud', array('instance' => $this->repo->get_name(),
'errormessage' => sprintf('(%s) %s', '404', 'Msg'))));
$this->repo->get_link($file);
}
@ -792,7 +792,7 @@ XML;
$this->set_private_property('', 'client');
$this->expectException(repository_nextcloud\request_exception::class);
$this->expectExceptionMessage(get_string('contactadminwith', 'repository_nextcloud',
'The OAuth client could not be connected.'));
'The OAuth clients could not be connected.'));
$this->repo->send_file($storedfile, '', '', '');