diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-03-05 06:38:11 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-03-05 06:38:11 +0000 |
commit | 23937ff1355f3f47f5b42dc3718db1615809371b (patch) | |
tree | 8702b9645ef24e9d789edb83eb67354e84041729 | |
parent | 898ac3ac359258ccb0958f5be420d17a9a264fec (diff) |
Avoid using default task types. Require task::get_definitions() to
specify a single type and ask for it appropriately in
admin_maintenance. Specify a type for every existing task.
-rw-r--r-- | core/controllers/admin_maintenance.php | 2 | ||||
-rw-r--r-- | core/helpers/core_task.php | 1 | ||||
-rw-r--r-- | core/helpers/task.php | 6 | ||||
-rw-r--r-- | core/libraries/Task_Definition.php | 2 | ||||
-rw-r--r-- | modules/exif/helpers/exif_task.php | 1 | ||||
-rw-r--r-- | modules/search/helpers/search_task.php | 1 |
6 files changed, 8 insertions, 5 deletions
diff --git a/core/controllers/admin_maintenance.php b/core/controllers/admin_maintenance.php index 315e2d63..c98251bc 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_definitions(array("admin", "both")); + $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") diff --git a/core/helpers/core_task.php b/core/helpers/core_task.php index 008c593f..785bf874 100644 --- a/core/helpers/core_task.php +++ b/core/helpers/core_task.php @@ -23,6 +23,7 @@ class core_task_Core { return array(Task_Definition::factory() ->callback("core_task::rebuild_dirty_images") ->name(t("Rebuild Images")) + ->type("admin") ->description($dirty_count ? t2("You have one out of date photo", "You have %count out of date photos", diff --git a/core/helpers/task.php b/core/helpers/task.php index d5cc7c4e..9a38c0de 100644 --- a/core/helpers/task.php +++ b/core/helpers/task.php @@ -27,7 +27,7 @@ class task_Core { $class_name = "{$module_name}_task"; if (method_exists($class_name, "available_tasks")) { foreach (call_user_func(array($class_name, "available_tasks")) as $task) { - if (in_array($task->type, $type)) { + if ($task->type == $type) { $tasks[$task->callback] = $task; } } @@ -37,8 +37,8 @@ class task_Core { return $tasks; } - static function create($task_callback) { - $task_definitions = self::get_definitions(array("admin", "general", "both")); + static function create($type, $task_callback) { + $task_definitions = self::get_definitions($type); $task = ORM::factory("task"); $task->callback = $task_callback; diff --git a/core/libraries/Task_Definition.php b/core/libraries/Task_Definition.php index 1f1e3287..3ee4a772 100644 --- a/core/libraries/Task_Definition.php +++ b/core/libraries/Task_Definition.php @@ -23,7 +23,7 @@ class Task_Definition_Core { public $description; public $name; public $severity; - public $type = "admin"; // admin, general, both + public $type; static function factory() { return new Task_Definition(); diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index 8e715b52..879462a6 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -38,6 +38,7 @@ class exif_task_Core { return array(Task_Definition::factory() ->callback("exif_task::extract_exif") ->name(t("Extract EXIF data")) + ->type("admin") ->description($remaining ? t("%percent% of your photos need to be scanned for EXIF data", array("percent" => $percent)) diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 7aba640e..bc950624 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -36,6 +36,7 @@ class search_task_Core { return array(Task_Definition::factory() ->callback("search_task::update_index") ->name(t("Update Search Index")) + ->type("admin") ->description($remaining ? t("Search index is %percent% up-to-date", array("percent" => $percent)) |