diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-03-05 06:28:23 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-03-05 06:28:23 +0000 |
commit | 898ac3ac359258ccb0958f5be420d17a9a264fec (patch) | |
tree | 464f3a90654406c28093f58b592d3f01e83bc217 | |
parent | 08d2fcb1f7ae0ced528c0a7230c433480d64167c (diff) |
A little task restructuring
-rw-r--r-- | core/controllers/admin_maintenance.php | 10 | ||||
-rw-r--r-- | core/helpers/task.php | 18 |
2 files changed, 9 insertions, 19 deletions
diff --git a/core/controllers/admin_maintenance.php b/core/controllers/admin_maintenance.php index 6f553161..315e2d63 100644 --- a/core/controllers/admin_maintenance.php +++ b/core/controllers/admin_maintenance.php @@ -40,7 +40,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { $view = new Admin_View("admin.html"); $view->content = new View("admin_maintenance.html"); - $view->content->task_definitions = task::get_task_definitions(); + $view->content->task_definitions = task::get_definitions(array("admin", "both")); $view->content->running_tasks = ORM::factory("task") ->select("tasks.*", "users.name as user_name") ->join("users", "tasks.owner_id", "users.id") @@ -145,9 +145,13 @@ class Admin_Maintenance_Controller extends Admin_Controller { message::success(t("Task failed")); break; } - print task::success($task, url::site("admin/maintenance")); + print json_encode(array("result" => "success", + "task" => $task->as_array(), + "location" => url::site("admin/maintenance"))); + } else { - print task::in_progress($task); + print json_encode(array("result" => "in_progress", + "task" => $task->as_array())); } } } diff --git a/core/helpers/task.php b/core/helpers/task.php index 816a5288..d5cc7c4e 100644 --- a/core/helpers/task.php +++ b/core/helpers/task.php @@ -21,7 +21,7 @@ class task_Core { /** * Get all available tasks */ - static function get_task_definitions($type=array("admin", "both")) { + static function get_definitions($type) { $tasks = array(); foreach (module::installed() as $module_name => $module_info) { $class_name = "{$module_name}_task"; @@ -38,7 +38,7 @@ class task_Core { } static function create($task_callback) { - $task_definitions = self::get_task_definitions(array("admin", "general", "both")); + $task_definitions = self::get_definitions(array("admin", "general", "both")); $task = ORM::factory("task"); $task->callback = $task_callback; @@ -84,18 +84,4 @@ class task_Core { return $task; } - - static function success($task, $location=null) { - $result = array("result" => "success", "task" => $task->as_array()); - if (!empty($location)) { - $result["location"] = $location; - } - return json_encode($result); - } - - static function in_progress($task) { - return json_encode( - array("result" => "in_progress", - "task" => $task->as_array())); - } }
\ No newline at end of file |