From eed57674f99621e5354a13543067e9556eb9c6d0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 24 Jan 2009 05:14:44 +0000 Subject: Add move support. Use the move icon in the quick pane. You can't move an item into its own hierarchy, or into an album where you don't have edit permission. --- core/controllers/move.php | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 core/controllers/move.php (limited to 'core/controllers/move.php') diff --git a/core/controllers/move.php b/core/controllers/move.php new file mode 100644 index 00000000..2171d492 --- /dev/null +++ b/core/controllers/move.php @@ -0,0 +1,64 @@ +source = $source; + $view->tree = $this->_get_tree_html($source, ORM::factory("item", 1)); + print $view; + } + + public function save($source_id) { + access::verify_csrf(); + $source = ORM::factory("item", $source_id); + access::required("edit", $source); + $target = ORM::factory("item", $this->input->post("target_id")); + access::required("edit", $target); + $source->move_to($target); + print json_encode( + array("result" => "success", + "location" => url::site("albums/{$target->id}"))); + } + + public function show_sub_tree($source_id, $target_id) { + $source = ORM::factory("item", $source_id); + $target = ORM::factory("item", $target_id); + access::required("edit", $source); + access::required("view", $target); + + print $this->_get_tree_html($source, $target); + } + + private function _get_tree_html($source, $target) { + $view = new View("move_tree.html"); + $view->source = $source; + $view->parent = $target; + $view->children = ORM::factory("item") + ->viewable() + ->where("type", "album") + ->where("parent_id", $target->id) + ->find_all(); + return $view; + } + +} -- cgit v1.2.3