summaryrefslogtreecommitdiff
path: root/modules/organize/controllers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-04-23 04:53:48 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-04-23 04:53:48 +0000
commitb1a15f21302c12da480591d4d5d3d4396b78ce90 (patch)
tree90ce21d5b6e88fa12e51da40b484656bd0ed5553 /modules/organize/controllers
parent1173b21f959eb013fc1844c5a1d5f3a071a1d455 (diff)
Implement a cancel button so that if an organize task is paused, it
can be cancelled.
Diffstat (limited to 'modules/organize/controllers')
-rw-r--r--modules/organize/controllers/organize.php25
1 files changed, 11 insertions, 14 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index 129fb8bb..48d2cd2c 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -105,11 +105,9 @@ class Organize_Controller extends Controller {
$task = ORM::factory("task", $task_id);
if ($task->done) {
- switch ($task->context["type"]) {
- case "moveTo":
+ if ($task->context["type"] == "moveTo") {
$task->status = t("Move to '%album' completed", array("album" => $item->title));
- break;
- case "rearrange":
+ } else if ($task->context["type"] == "rearrange") {
try {
$item = ORM::factory("item", $task->context["target"]);
$item->sort_column = "weight";
@@ -119,7 +117,6 @@ class Organize_Controller extends Controller {
$task->state = "error";
$task->status = $e->getMessage();
}
- break;
}
$task->save();
}
@@ -133,16 +130,16 @@ class Organize_Controller extends Controller {
$task = ORM::factory("task", $task_id);
- if ($task->done) {
- switch ($task->context["type"]) {
- case "moveTo":
- message::warning(t("Move to album was cancelled prior to completion"));
- break;
- case "rearrange":
- message::warning(t("Rearrange album was cancelled prior to completion"));
- break;
+ if (!$task->done) {
+ $task->done = 1;
+ $task->state = "cancelled";
+ if ($task->context["type"] == "moveTo") {
+ $task->status = t("Move to album was cancelled prior to completion");
+ } else if ($task->context["type"] == "rearrange") {
+ $task->status = t("Rearrange album was cancelled prior to completion");
}
- }
+ $task->save();
+ }
batch::stop();
print json_encode(array("result" => "success"));