diff --git a/modules/akismet/controllers/admin_akismet.php b/modules/akismet/controllers/admin_akismet.php index ca3a1473..4847db53 100644 --- a/modules/akismet/controllers/admin_akismet.php +++ b/modules/akismet/controllers/admin_akismet.php @@ -25,17 +25,8 @@ class Admin_Akismet_Controller extends Admin_Controller { // @todo move the "post" handler part of this code into a separate function access::verify_csrf(); - $valid = $form->validate(); - - if ($valid) { + if ($form->validate()) { $new_key = $form->configure_akismet->api_key->value; - if ($new_key && !akismet::validate_key($new_key)) { - $form->configure_akismet->api_key->add_error("invalid", 1); - $valid = false; - } - } - - if ($valid) { $old_key = module::get_var("akismet", "api_key"); if ($old_key && !$new_key) { message::success(t("Your Akismet key has been cleared.")); 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); + } + } } diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php index c6994cbe..f7b34e16 100644 --- a/modules/digibug/views/digibug_form.html.php +++ b/modules/digibug/views/digibug_form.html.php @@ -3,7 +3,7 @@
= form::open("http://www.digibug.com/dapi/order.php") ?> = form::hidden($order_parms) ?> - = form::close() ?> + diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php index 67ab3805..04a2e9a5 100644 --- a/modules/gallery/libraries/InPlaceEdit.php +++ b/modules/gallery/libraries/InPlaceEdit.php @@ -70,7 +70,6 @@ class InPlaceEdit_Core { public function render() { $v = new View("in_place_edit.html"); - $v->hidden = array("csrf" => access::csrf_token()); $v->action = url::site($this->action); $v->form = $this->form; $v->errors = $this->errors; diff --git a/modules/gallery/views/in_place_edit.html.php b/modules/gallery/views/in_place_edit.html.php index ad9ea845..05a16ad4 100644 --- a/modules/gallery/views/in_place_edit.html.php +++ b/modules/gallery/views/in_place_edit.html.php @@ -1,5 +1,5 @@ -= form::open($action, array("method" => "post", "id" => "g-in-place-edit-form", "class" => "g-short-form"), $hidden) ?> += form::open($action, array("method" => "post", "id" => "g-in-place-edit-form", "class" => "g-short-form")) ?> = access::csrf_form_field() ?>