diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-03-09 07:28:19 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-03-09 07:28:19 +0000 |
commit | e37faa0008df38088a55932786955e68ee1f955f (patch) | |
tree | 78fc0df349fb5a55335c81f2608c202eee9fcd5a /core | |
parent | 622358ebc8eba1cfd17f8e7cbb5c8557fd7c4bee (diff) |
More tasks cleanup.
Don't join through to the users table; that won't work in embedded
mode. Instead, add Tasks_Model::owner() that calls user::lookup() and
refer to the object directly in the view.
Add Admin_Maintenance:remove_finished_tasks() so that we can easily do
old task cleanup.
Hide Running / Finished sections if there aren't any running or
finished tasks.
Diffstat (limited to 'core')
-rw-r--r-- | core/controllers/admin_maintenance.php | 11 | ||||
-rw-r--r-- | core/models/task.php | 6 | ||||
-rw-r--r-- | core/views/admin_maintenance.html.php | 9 |
3 files changed, 19 insertions, 7 deletions
diff --git a/core/controllers/admin_maintenance.php b/core/controllers/admin_maintenance.php index c98251bc..80403906 100644 --- a/core/controllers/admin_maintenance.php +++ b/core/controllers/admin_maintenance.php @@ -42,12 +42,8 @@ class Admin_Maintenance_Controller extends Admin_Controller { $view->content = new View("admin_maintenance.html"); $view->content->task_definitions = task::get_definitions("admin"); $view->content->running_tasks = ORM::factory("task") - ->select("tasks.*", "users.name as user_name") - ->join("users", "tasks.owner_id", "users.id") ->where("done", 0)->orderby("updated", "DESC")->find_all(); $view->content->finished_tasks = ORM::factory("task") - ->select("tasks.*", "users.name as user_name") - ->join("users", "tasks.owner_id", "users.id") ->where("done", 1)->orderby("updated", "DESC")->find_all(); $view->content->csrf = access::csrf_token(); print $view; @@ -119,6 +115,13 @@ class Admin_Maintenance_Controller extends Admin_Controller { url::redirect("admin/maintenance"); } + public function remove_finished_tasks() { + access::verify_csrf(); + Database::instance()->delete("tasks", array("done" => 1)); + message::success(t("All finished tasks removed")); + url::redirect("admin/maintenance"); + } + /** * Run a task. This will trigger the task to do a small amount of work, then it will report * back with status on the task. diff --git a/core/models/task.php b/core/models/task.php index 85713419..0255a6ad 100644 --- a/core/models/task.php +++ b/core/models/task.php @@ -34,7 +34,7 @@ class Task_Model extends ORM { return parent::__get($column); } } - + public function get($key, $default=null) { $context = unserialize($this->context); if (array_key_exists($key, $context)) { @@ -56,4 +56,8 @@ class Task_Model extends ORM { } return parent::save(); } + + public function owner() { + return user::lookup($this->owner_id); + } }
\ No newline at end of file diff --git a/core/views/admin_maintenance.html.php b/core/views/admin_maintenance.html.php index 2570dcee..e3afb9f5 100644 --- a/core/views/admin_maintenance.html.php +++ b/core/views/admin_maintenance.html.php @@ -38,6 +38,7 @@ </table> </div> + <? if ($running_tasks->count()): ?> <div id="gRunningTasks"> <h2> <?= t("Running Tasks") ?> </h2> @@ -86,7 +87,7 @@ <?= $task->status ?> </td> <td> - <?= $task->user_name ?> + <?= $task->owner()->name ?> </td> <td> <? if ($task->state == "stalled"): ?> @@ -102,9 +103,12 @@ <? endforeach ?> </table> </div> + <? endif ?> + <? if ($finished_tasks->count()): ?> <div id="gFinishedTasks"> <h2> <?= t("Finished Tasks") ?> </h2> + <a href="<?= url::site("admin/maintenance/remove_finished_tasks?csrf=$csrf") ?>"><?= t("remove all") ?></a> <table> <tr> @@ -148,7 +152,7 @@ <?= $task->status ?> </td> <td> - <?= $task->user_name ?> + <?= $task->owner()->name ?> </td> <td> <? if ($task->done): ?> @@ -168,4 +172,5 @@ <? endforeach ?> </table> </div> + <? endif ?> </div> |