From a8c232a752f72e4cd6b3e83a115db3c31332014d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 26 Jul 2010 10:58:55 -0700 Subject: [PATCH] Convert the favorites module to the new json::reply helper. **Note** this module doesn't install as it gets a ORM validation error. --- modules/basket/controllers/admin_postage_bands.php | 12 ++++++------ modules/basket/controllers/admin_product_lines.php | 12 ++++++------ modules/basket/controllers/basket.php | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/basket/controllers/admin_postage_bands.php b/modules/basket/controllers/admin_postage_bands.php index 977128e3..26598bd7 100644 --- a/modules/basket/controllers/admin_postage_bands.php +++ b/modules/basket/controllers/admin_postage_bands.php @@ -60,9 +60,9 @@ class Admin_Postage_Bands_Controller extends Controller $postage_band->save(); message::success(t("Created postage band %postage_name", array( "postage_name" => html::clean($postage_band->name)))); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } else { - print json_encode(array("result" => "error", "form" => (string)$form)); + json::reply(array("result" => "error", "form" => (string)$form)); } } @@ -91,13 +91,13 @@ class Admin_Postage_Bands_Controller extends Controller $name = $postage->name; $postage->delete(); } else { - print json_encode(array("result" => "error", "form" => (string)$form)); + json::reply(array("result" => "error", "form" => (string)$form)); } $message = t("Deleted user %postage_band", array("postage_band" => html::clean($name))); log::success("user", $message); message::success($message); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } public function edit_postage_band($id) { @@ -127,9 +127,9 @@ class Admin_Postage_Bands_Controller extends Controller $postage->save(); message::success(t("Changed postage band %postage_name", array("postage_name" => html::clean($postage->name)))); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } else { - print json_encode(array("result" => "error", "form" => (string)$form)); + json::reply(array("result" => "error", "form" => (string)$form)); } } diff --git a/modules/basket/controllers/admin_product_lines.php b/modules/basket/controllers/admin_product_lines.php index fd11928e..197b7291 100644 --- a/modules/basket/controllers/admin_product_lines.php +++ b/modules/basket/controllers/admin_product_lines.php @@ -60,9 +60,9 @@ class Admin_Product_Lines_Controller extends Controller $product->save(); message::success(t("Created product %product_name", array( "product_name" => html::clean($product->name)))); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } else { - print json_encode(array("result" => "error", "form" => (string)$form)); + json::reply(array("result" => "error", "form" => (string)$form)); } } @@ -91,14 +91,14 @@ class Admin_Product_Lines_Controller extends Controller $name = $product->name; $product->delete(); } else { - print json_encode(array("result" => "error", + json::reply(array("result" => "error", "form" => $form->__toString())); } $message = t("Deleted user %product_name", array("product_name" => html::clean($name))); log::success("user", $message); message::success($message); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } public function edit_product($id) { @@ -129,9 +129,9 @@ class Admin_Product_Lines_Controller extends Controller $product->save(); message::success(t("Changed product %product_name", array("product_name" => html::clean($product->name)))); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } else { - print json_encode(array("result" => "error", "form" => (string)$form)); + json::reply(array("result" => "error", "form" => (string)$form)); } } diff --git a/modules/basket/controllers/basket.php b/modules/basket/controllers/basket.php index 1620fcdc..612708c4 100644 --- a/modules/basket/controllers/basket.php +++ b/modules/basket/controllers/basket.php @@ -189,7 +189,7 @@ Items Ordered: $form->add_to_basket->product->value, $form->add_to_basket->quantity->value); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } else {