summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-03-10 13:53:59 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-03-10 13:53:59 +0000
commit5342578e6d24c59db74747024e1bdc5bcf41ae2d (patch)
tree9e1ebb53da133be2bc84b4a845c8d98960e21279 /core
parent9d4769da87b38374cfca095df4d17e11c183c312 (diff)
Minor change to the task api with the addition of two optional
parameters. The first allows the specification of a task name. Non-maintenance tasks are not defined as part of availabl_tasks so we can't get the name from the task definitions. The 2nd allows the specification of a context when the task is completed.
Diffstat (limited to 'core')
-rw-r--r--core/helpers/task.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/helpers/task.php b/core/helpers/task.php
index d9eeecfa..75151796 100644
--- a/core/helpers/task.php
+++ b/core/helpers/task.php
@@ -35,17 +35,23 @@ class task_Core {
return $tasks;
}
- static function create($task_callback) {
- $task_definitions = self::get_definitions();
-
+ static function create($task_callback, $task_name=null, $context=array()) {
$task = ORM::factory("task");
$task->callback = $task_callback;
- $task->name = $task_definitions[$task_callback]->name;
+ if (empty($task_name)) {
+ $task_definitions = self::get_definitions();
+ $task->name = $task_definitions[$task_callback]->name;
+ } else {
+ $task->name = $task_name;
+ }
+ if (empty($task->name)) {
+ $task_name = $task_callback;
+ }
$task->percent_complete = 0;
$task->status = "";
$task->state = "started";
$task->owner_id = user::active()->id;
- $task->context = serialize(array());
+ $task->context = serialize($context);
$task->save();
return $task;