diff options
Diffstat (limited to 'modules/organize')
-rw-r--r-- | modules/organize/controllers/organize.php | 27 | ||||
-rw-r--r-- | modules/organize/js/organize.js | 2 | ||||
-rw-r--r-- | modules/organize/views/organize_tree.html.php | 2 |
3 files changed, 20 insertions, 11 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 08c80de3..201ced30 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -48,7 +48,7 @@ class Organize_Controller extends Controller { access::required("view", $target_album); access::required("add", $target_album); - foreach ($this->input->post("source_ids") as $source_id) { + foreach (Input::instance()->post("source_ids") as $source_id) { $source = ORM::factory("item", $source_id); if (!$source->contains($target_album)) { access::required("edit", $source); @@ -69,13 +69,17 @@ class Organize_Controller extends Controller { access::required("view", $album); access::required("edit", $album); - $source_ids = $this->input->post("source_ids", array()); + $source_ids = Input::instance()->post("source_ids", array()); if ($album->sort_column != "weight") { $i = 0; foreach ($album->children() as $child) { // Do this directly in the database to avoid sending notifications - Database::Instance()->update("items", array("weight" => ++$i), array("id" => $child->id)); + db::build() + ->update("items") + ->set("weight", ++$i) + ->where("id", "=", $child->id) + ->execute(); } $album->sort_column = "weight"; $album->sort_order = "ASC"; @@ -91,15 +95,20 @@ class Organize_Controller extends Controller { // Make a hole $count = count($source_ids); - Database::Instance()->query( - "UPDATE {items} " . - "SET `weight` = `weight` + $count " . - "WHERE `weight` >= $target_weight AND `parent_id` = {$album->id}"); + db::build() + ->update("items") + ->set("weight", new Database_Expression("`weight` + $count")) + ->where("weight", ">=", $target_weight) + ->where("parent_id", "=", $album->id) + ->execute(); // Insert source items into the hole foreach ($source_ids as $source_id) { - Database::Instance()->update( - "items", array("weight" => $target_weight++), array("id" => $source_id)); + db::build() + ->update("items") + ->set("weight", $target_weight++) + ->where("id", "=", $source_id) + ->execute(); } module::event("album_rearrange", $album); diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 3dbf9a55..556aa7e7 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -149,7 +149,7 @@ window.location.reload(); }); - $("#g-dialog #g-organize-close").click(function(event) { + $("#g-organize-close").click(function(event) { $("#g-dialog").dialog("close"); }); diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php index 50c8c351..513c0625 100644 --- a/modules/organize/views/organize_tree.html.php +++ b/modules/organize/views/organize_tree.html.php @@ -8,7 +8,7 @@ <?= html::clean($album->title) ?> </span> <ul> - <? foreach ($album->children(null, 0, array("type" => "album")) as $child): ?> + <? foreach ($album->children(null, null, array(array("type", "=", "album"))) as $child): ?> <? if ($selected && $child->contains($selected)): ?> <?= View::factory("organize_tree.html", array("selected" => $selected, "album" => $child)); ?> <? else: ?> |