diff options
author | Joe7 <jozsef.rnagy@site.hu> | 2011-01-12 00:05:11 +0100 |
---|---|---|
committer | Joe7 <jozsef.rnagy@site.hu> | 2011-01-12 00:05:11 +0100 |
commit | 049f2af1c982bb12fee6e5512e4830f63d06d343 (patch) | |
tree | 88a5fa6e141b92b0ca4f92172e41db3f610b2ec9 /modules/gallery/controllers | |
parent | d74aad072d8ccca70efb1c8b673e8368566a1974 (diff) |
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
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r-- | modules/gallery/controllers/admin_languages.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index 573ededf..e9be2a88 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -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. |