mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-06-07 20:19:20 -04:00
Returning 2 flags from l10n_client::validate_api_key(), 1 to reflect if connection was built up properly (just a boolean, not distuingishing between reasons in case of a failure), the other to reflect API validating success status.
Using this presenting a slightly more meaningfull error msg to user in case the connection would fail. Fixes Ticket #1504
This commit is contained in:
@@ -74,9 +74,11 @@ class Admin_Languages_Controller extends Admin_Controller {
|
||||
|
||||
private function _save_api_key($form) {
|
||||
$new_key = $form->sharing->api_key->value;
|
||||
if ($new_key && !l10n_client::validate_api_key($new_key)) {
|
||||
$form->sharing->api_key->add_error("invalid", 1);
|
||||
$valid = false;
|
||||
if ($new_key) {
|
||||
list($connected, $valid) = l10n_client::validate_api_key($new_key);
|
||||
if (!$valid) {
|
||||
$form->sharing->api_key->add_error($connected ? "invalid" : "noconn", 1);
|
||||
}
|
||||
} else {
|
||||
$valid = true;
|
||||
}
|
||||
@@ -119,7 +121,8 @@ class Admin_Languages_Controller extends Admin_Controller {
|
||||
array("server-link" => html::mark_clean(html::anchor($server_link))))
|
||||
: t("API key"))
|
||||
->value($api_key)
|
||||
->error_messages("invalid", t("The API key you provided is invalid."));
|
||||
->error_messages("invalid", t("The API key you provided is invalid."))
|
||||
->error_messages("noconn", t("Could not connect to remote server to validate the API key."));
|
||||
$group->submit("save")->value(t("Save settings"));
|
||||
if ($api_key && $this->_outgoing_translations_count()) {
|
||||
// TODO: UI improvement: hide API key / save button when API key is set.
|
||||
|
||||
Reference in New Issue
Block a user