From 89d18c0714f5c982ef9e8711a04490bdac8cae2d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 21 Jul 2010 08:46:53 -0700 Subject: Partial fix for #1225 addresses the issues with the user edit forms. --- modules/user/controllers/admin_users.php | 36 ++++++++++++++++---------------- modules/user/controllers/users.php | 27 +++++++++++------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/modules/user/controllers/admin_users.php b/modules/user/controllers/admin_users.php index 2d50de92..64365f2b 100644 --- a/modules/user/controllers/admin_users.php +++ b/modules/user/controllers/admin_users.php @@ -54,14 +54,14 @@ class Admin_Users_Controller extends Admin_Controller { $user->save(); module::event("user_add_form_admin_completed", $user, $form); message::success(t("Created user %user_name", array("user_name" => $user->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)); } } public function add_user_form() { - print json_encode(array("form" => (string) $this->_get_user_add_form_admin())); + json::reply(array("form" => (string) $this->_get_user_add_form_admin())); } public function delete_user($id) { @@ -81,13 +81,13 @@ class Admin_Users_Controller extends Admin_Controller { $name = $user->name; $user->delete(); } else { - print json_encode(array("result" => "error", "form" => (string) $form)); + json::reply(array("result" => "error", "form" => (string) $form)); } $message = t("Deleted user %user_name", array("user_name" => $name)); log::success("user", $message); message::success($message); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } public function delete_user_form($id) { @@ -95,7 +95,7 @@ class Admin_Users_Controller extends Admin_Controller { if (empty($user)) { throw new Kohana_404_Exception(); } - print json_encode(array("form" => (string) $this->_get_user_delete_form_admin($user))); + json::reply(array("form" => (string) $this->_get_user_delete_form_admin($user))); } public function edit_user($id) { @@ -134,9 +134,9 @@ class Admin_Users_Controller extends Admin_Controller { $user->save(); module::event("user_edit_form_admin_completed", $user, $form); message::success(t("Changed user %user_name", array("user_name" => $user->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)); } } @@ -146,7 +146,7 @@ class Admin_Users_Controller extends Admin_Controller { throw new Kohana_404_Exception(); } - print json_encode(array("form" => (string) $this->_get_user_edit_form_admin($user))); + json::reply(array("form" => (string) $this->_get_user_edit_form_admin($user))); } public function add_user_to_group($user_id, $group_id) { @@ -192,14 +192,14 @@ class Admin_Users_Controller extends Admin_Controller { $group->save(); message::success( t("Created group %group_name", array("group_name" => $group->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)); } } public function add_group_form() { - print json_encode(array("form" => (string) $this->_get_group_add_form_admin())); + json::reply(array("form" => (string) $this->_get_group_add_form_admin())); } public function delete_group($id) { @@ -215,13 +215,13 @@ class Admin_Users_Controller extends Admin_Controller { $name = $group->name; $group->delete(); } else { - print json_encode(array("result" => "error", "form" => (string) $form)); + json::reply(array("result" => "error", "form" => (string) $form)); } $message = t("Deleted group %group_name", array("group_name" => $name)); log::success("group", $message); message::success($message); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } public function delete_group_form($id) { @@ -230,7 +230,7 @@ class Admin_Users_Controller extends Admin_Controller { throw new Kohana_404_Exception(); } - print json_encode(array("form" => (string) $this->_get_group_delete_form_admin($group))); + json::reply(array("form" => (string) $this->_get_group_delete_form_admin($group))); } public function edit_group($id) { @@ -258,12 +258,12 @@ class Admin_Users_Controller extends Admin_Controller { $group->save(); message::success( t("Changed group %group_name", array("group_name" => $group->name))); - print json_encode(array("result" => "success")); + json::reply(array("result" => "success")); } else { $group->reload(); message::error( t("Failed to change group %group_name", array("group_name" => $group->name))); - print json_encode(array("result" => "error", "form" => (string) $form)); + json::reply(array("result" => "error", "form" => (string) $form)); } } @@ -273,7 +273,7 @@ class Admin_Users_Controller extends Admin_Controller { throw new Kohana_404_Exception(); } - print json_encode(array("form" => (string) $this->_get_group_edit_form_admin($group))); + json::reply(array("form" => (string) $this->_get_group_edit_form_admin($group))); } /* User Form Definitions */ diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php index 4ddfb47c..e98ab341 100644 --- a/modules/user/controllers/users.php +++ b/modules/user/controllers/users.php @@ -54,11 +54,10 @@ class Users_Controller extends Controller { $user->save(); module::event("user_edit_form_completed", $user, $form); message::success(t("User information updated")); - print json_encode( - array("result" => "success", - "resource" => url::site("users/{$user->id}"))); + json::reply(array("result" => "success", + "resource" => url::site("users/{$user->id}"))); } else { - print json_encode(array("result" => "error", "form" => (string) $form)); + json::reply(array("result" => "error", "form" => (string) $form)); } } @@ -87,14 +86,13 @@ class Users_Controller extends Controller { message::success(t("Password changed")); module::event("user_auth", $user); module::event("user_password_change", $user); - print json_encode( - array("result" => "success", - "resource" => url::site("users/{$user->id}"))); + json::reply(array("result" => "success", + "resource" => url::site("users/{$user->id}"))); } else { log::warning("user", t("Failed password change for %name", array("name" => $user->name))); $name = $user->name; module::event("user_auth_failed", $name); - print json_encode(array("result" => "error", "form" => (string) $form)); + json::reply(array("result" => "error", "form" => (string) $form)); } } @@ -122,14 +120,13 @@ class Users_Controller extends Controller { module::event("user_change_email_form_completed", $user, $form); message::success(t("Email address changed")); module::event("user_auth", $user); - print json_encode( - array("result" => "success", - "resource" => url::site("users/{$user->id}"))); + json::reply(array("result" => "success", + "resource" => url::site("users/{$user->id}"))); } else { log::warning("user", t("Failed email change for %name", array("name" => $user->name))); $name = $user->name; module::event("user_auth_failed", $name); - print json_encode(array("result" => "error", "form" => (string) $form)); + json::reply(array("result" => "error", "form" => (string) $form)); } } @@ -139,7 +136,7 @@ class Users_Controller extends Controller { access::forbidden(); } - print json_encode(array("form" => (string) $this->_get_edit_form($user))); + json::reply(array("form" => (string) $this->_get_edit_form($user))); } public function form_change_password($id) { @@ -148,7 +145,7 @@ class Users_Controller extends Controller { access::forbidden(); } - print json_encode(array("form" => (string) $this->_get_change_password_form($user))); + json::reply(array("form" => (string) $this->_get_change_password_form($user))); } public function form_change_email($id) { @@ -157,7 +154,7 @@ class Users_Controller extends Controller { access::forbidden(); } - print json_encode(array("form" => (string) $this->_get_change_email_form($user))); + json::reply(array("form" => (string) $this->_get_change_email_form($user))); } private function _get_change_password_form($user) { -- cgit v1.2.3