diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2010-01-29 11:39:22 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2010-01-29 11:39:22 -0800 |
commit | e4d9ea3394ee2db82d9dee6c6ed78543fd0f78fb (patch) | |
tree | 85759cfef46cc1df79a1ddf3225dce8809b9121a /modules/akismet/helpers | |
parent | 1bc0d05760df7bff5cee0a330b5b7181b3c49835 (diff) | |
parent | 660130cf1ab9fd6cb051712b57966b191064a6a6 (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
Conflicts:
modules/gallery/views/in_place_edit.html.php
Diffstat (limited to 'modules/akismet/helpers')
-rw-r--r-- | modules/akismet/helpers/akismet.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/modules/akismet/helpers/akismet.php b/modules/akismet/helpers/akismet.php index 46a305b2..b4405de5 100644 --- a/modules/akismet/helpers/akismet.php +++ b/modules/akismet/helpers/akismet.php @@ -23,8 +23,9 @@ class akismet_Core { static function get_configure_form() { $form = new Forge("admin/akismet", "", "post", array("id" => "g-configure-akismet-form")); $group = $form->group("configure_akismet")->label(t("Configure Akismet")); - $group->input("api_key")->label(t("API Key"))->value(module::get_var("akismet", "api_key")); - $group->api_key->error_messages("invalid", t("The API key you provided is invalid.")); + $group->input("api_key")->label(t("API Key"))->value(module::get_var("akismet", "api_key")) + ->callback("akismet::validate_key") + ->error_messages("invalid", t("The API key you provided is invalid.")); $group->submit("")->value(t("Save")); return $form; } @@ -82,10 +83,14 @@ class akismet_Core { * @param string $api_key the API key * @return boolean */ - static function validate_key($api_key) { - $request = self::_build_verify_request($api_key); - $response = self::_http_post($request, "rest.akismet.com"); - return "valid" == $response->body[0]; + static function validate_key($api_key_input) { + if ($api_key_input->value) { + $request = self::_build_verify_request($api_key_input->value); + $response = self::_http_post($request, "rest.akismet.com"); + if ("valid" != $response->body[0]) { + $api_key_input->add_error("invalid", 1); + } + } } |