summaryrefslogtreecommitdiff
path: root/modules/gallery/models/task.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-07-05 17:38:49 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-07-05 17:38:49 -0700
commit04f02b49c5d524345bc916aad6e247c714177662 (patch)
tree2410e3ca63a67511c8dbdfd3a8f20a174492a9e5 /modules/gallery/models/task.php
parentfcb031c2b60ac9e1888592296cba25791e77b446 (diff)
Add task logging functionality. When a task runs, it creates a log that is
stored in the persistant cache for 30 days. On the admin_maintenance page there is a new link for completed tasks "browse log". Clicking this will open a dialog box that has the the contents of the log displayed. The user can then view the log and close the dialog, or press the save button to download the log to their local machine.
Diffstat (limited to 'modules/gallery/models/task.php')
-rw-r--r--modules/gallery/models/task.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/gallery/models/task.php b/modules/gallery/models/task.php
index 9e3ae5c6..2e77a7a6 100644
--- a/modules/gallery/models/task.php
+++ b/modules/gallery/models/task.php
@@ -40,7 +40,31 @@ class Task_Model extends ORM {
return parent::save();
}
+ public function delete() {
+ Cache::instance()->delete($this->_cache_key());
+ return parent::save();
+ }
+
public function owner() {
return user::lookup($this->owner_id);
}
+
+ public function log($msg) {
+ $key = $this->_cache_key();
+ $log = Cache::instance()->get($key);
+
+ // Save for 30 days.
+ $log .= !empty($log) ? "\n" : "";
+ Cache::instance()->set($key, "$log{$msg}",
+ array("task", "log", "import"), 2592000);
+ }
+
+ public function get_task_log() {
+ $log_data = Cache::instance()->get($this->_cache_key());
+ return $log_data !== null ? $log_data : false;
+ }
+
+ private function _cache_key() {
+ return md5("$this->id; $this->name; $this->callback");
+ }
} \ No newline at end of file