Skip to content

Commit

Permalink
Merge branch 'Ticket#1504' of git://github.com/Joe7/gallery3
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Jan 11, 2011
2 parents 92db7f4 + 049f2af commit f80b595
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions modules/gallery/controllers/admin_languages.php
Expand Up @@ -74,9 +74,11 @@ public function share() {

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;
}
Expand Down Expand Up @@ -119,7 +121,8 @@ private function _share_translations_form() {
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.
Expand Down
8 changes: 6 additions & 2 deletions modules/gallery/helpers/l10n_client.php
Expand Up @@ -60,10 +60,14 @@ static function validate_api_key($api_key) {
"client_token" => l10n_client::client_token(),
"signature" => $signature,
"uid" => l10n_client::server_uid($api_key)));
if (!isset($response_data) && !isset($response_status)) {
return array(false, false);
}

if (!remote::success($response_status)) {
return false;
return array(true, false);
}
return true;
return array(true, true);
}

/**
Expand Down

0 comments on commit f80b595

Please sign in to comment.