summaryrefslogtreecommitdiff
path: root/modules/organize/helpers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-04-22 16:09:57 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-04-22 16:09:57 +0000
commit475b8fe9ff3f4eee077fd649a1e5aea2568c06b4 (patch)
treea892d62e17c451db626d031e43753be71b364764 /modules/organize/helpers
parentf9ec5d6de466b6a7c9eb4766ca228aff754284f5 (diff)
Dragging from the thumbgrid to an album in the tree now works.
Refactored the javascript to minimize duplication.
Diffstat (limited to 'modules/organize/helpers')
-rw-r--r--modules/organize/helpers/organize_task.php31
1 files changed, 28 insertions, 3 deletions
diff --git a/modules/organize/helpers/organize_task.php b/modules/organize/helpers/organize_task.php
index f923fdc7..a6d89e37 100644
--- a/modules/organize/helpers/organize_task.php
+++ b/modules/organize/helpers/organize_task.php
@@ -27,7 +27,7 @@ class organize_task_Core {
$context = unserialize($task->context);
try {
- $stop = $context["position"] + $context["batch"];
+ $stop = min(count($context["items"]), $context["position"] + $context["batch"]);
for (; $context["position"] < $stop; $context["position"]++ ) {
$id = $context["items"][$context["position"]];
Database::instance()
@@ -35,12 +35,37 @@ class organize_task_Core {
}
$task->state = "success";
} catch(Exception $e) {
- $tast->status = $e->getMessage();
+ $task->status = $e->getMessage();
$task->state = "error";
+ $task->save();
+ throw $e;
}
$task->context = serialize($context);
$total = count($context["items"]);
$task->percent_complete = $context["position"] / (float)$total * 100;
- $task->done = $context["position"] == $total;
+ $task->done = $context["position"] == $total || $task->state == "error";
+ }
+
+ static function move($task) {
+ $context = unserialize($task->context);
+
+ try {
+ $target = ORM::factory("item", $context["target"]);
+ $stop = min(count($context["items"]), $context["position"] + $context["batch"]);
+ for (; $context["position"] < $stop; $context["position"]++ ) {
+ $source = ORM::factory("item", $context["items"][$context["position"]]);
+ core::move_item($source, $target);
+ }
+ $task->state = "success";
+ } catch(Exception $e) {
+ $task->status = $e->getMessage();
+ $task->state = "error";
+ $task->save();
+ throw $e;
+ }
+ $task->context = serialize($context);
+ $total = count($context["items"]);
+ $task->percent_complete = $context["position"] / (float)$total * 100;
+ $task->done = $context["position"] == $total || $task->state == "error";
}
} \ No newline at end of file