summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/admin_maintenance.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/controllers/admin_maintenance.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/controllers/admin_maintenance.php')
-rw-r--r--modules/gallery/controllers/admin_maintenance.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 7c5934a3..a65bd770 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -59,6 +59,8 @@ class Admin_Maintenance_Controller extends Admin_Controller {
$view = new View("admin_maintenance_task.html");
$view->task = $task;
+ $task->log(t("Task %task_name started (task id %task_id)",
+ array("task_name" => $task->name, "task_id" => $task->id)));
log::info("tasks", t("Task %task_name started (task id %task_id)",
array("task_name" => $task->name, "task_id" => $task->id)),
html::anchor("admin/maintenance", t("maintenance")));
@@ -79,6 +81,8 @@ class Admin_Maintenance_Controller extends Admin_Controller {
$view = new View("admin_maintenance_task.html");
$view->task = $task;
+ $task->log(t("Task %task_name resumed (task id %task_id)",
+ array("task_name" => $task->name, "task_id" => $task->id)));
log::info("tasks", t("Task %task_name resumed (task id %task_id)",
array("task_name" => $task->name, "task_id" => $task->id)),
html::anchor("admin/maintenance", t("maintenance")));
@@ -86,6 +90,40 @@ class Admin_Maintenance_Controller extends Admin_Controller {
}
/**
+ * Show the task log
+ * @param string $task_id
+ */
+ public function show_log($task_id) {
+ access::verify_csrf();
+
+ $task = ORM::factory("task", $task_id);
+ if (!$task->loaded) {
+ throw new Exception("@todo MISSING_TASK");
+ }
+ $view = new View("admin_maintenance_show_log.html");
+ $view->task = $task;
+
+ print $view;
+ }
+
+ /**
+ * Save the task log
+ * @param string $task_id
+ */
+ public function save_log($task_id) {
+ access::verify_csrf();
+
+ $task = ORM::factory("task", $task_id);
+ if (!$task->loaded) {
+ throw new Exception("@todo MISSING_TASK");
+ }
+
+ header("Content-Type: application/text");
+ header("Content-Disposition: filename=g2_import.txt");
+ print $task->get_task_log();
+ }
+
+ /**
* Cancel a task.
* @param string $task_id
*/