summaryrefslogtreecommitdiff
path: root/modules/organize/controllers/organize.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-04-20 18:44:19 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-04-20 18:44:19 +0000
commitad10584dc1ba40aa045ece4db3e09dfc3ec8039c (patch)
tree4dfe6bd847473ba96d314e86c2535e2781a23037 /modules/organize/controllers/organize.php
parente8d99f22a1605c47bf2e83cf02a548c5e5c2c87e (diff)
1) Add rearrange processing as a task
2) Improved drop location determination 3) Add a revert if dropped on an invalid target 4) Add a popup dialog to display ajax errors Still to do progress bar, pause/continue and status messages
Diffstat (limited to 'modules/organize/controllers/organize.php')
-rw-r--r--modules/organize/controllers/organize.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index 8ec3f1cf..ec685353 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -83,4 +83,62 @@ class Organize_Controller extends Controller {
}
return $v->__toString();
}
+
+ function rearrangeStart($id) {
+ access::verify_csrf();
+ $items = $this->input->post("item");
+
+ $task_def = Task_Definition::factory()
+ ->callback("organize_task::rearrange")
+ ->description(t("Rearrange the order of albums and photos"))
+ ->name(t("Rearrange"));
+ $task = task::create($task_def, array("items" => $items, "position" => 0, "batch" =>
+ ceil(count($items) * .1)));
+
+ batch::start();
+ print json_encode(array("result" => "started",
+ "task" => array(
+ "id" => $task->id,
+ "percent_complete" => $task->percent_complete,
+ "status" => $task->status,
+ "done" => $task->done)));
+ }
+
+ function rearrangeRun($id, $task_id) {
+ access::verify_csrf();
+
+ $task = task::run($task_id);
+
+ print json_encode(array("result" => $task->done ? $task->state : "in_progress",
+ "task" => array(
+ "id" => $task->id,
+ "percent_complete" => $task->percent_complete,
+ "status" => $task->status,
+ "done" => $task->done)));
+ }
+
+ function rearrangeFinish($id, $task_id) {
+ access::verify_csrf();
+
+ $task = ORM::factory("task", $task_id);
+
+ if (!$task->done) {
+ message::warning(t("Rearrange album was was cancelled prior to completion"));
+ } else {
+ // @todo set the sort order to weight;
+ }
+
+ batch::stop();
+ print json_encode(array("result" => "success"));
+ }
+
+ function rearrangePause($id, $task_id) {
+ access::verify_csrf();
+
+ $task = ORM::factory("task", $task_id);
+
+ message::warning(t("Rearrange album was cancelled prior to completion"));
+ batch::stop();
+ print json_encode(array("result" => "success"));
+ }
} \ No newline at end of file