From 603d4640141a43350f50da747d747456b28fdd93 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 15 Jun 2010 11:20:04 -0700 Subject: Change the item rest update processing to call the itemm::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Also, only change the weights of the album children if the item sort_column is set to weight. --- modules/gallery/helpers/item_rest.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 763e586f..27542dea 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -99,7 +99,7 @@ class item_rest_Core { if ($entity = $request->params->entity) { // Only change fields from a whitelist. foreach (array("album_cover", "captured", "description", - "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", + "height", "mime_type", "name", "rand_key", "resize_dirty", "resize_height", "resize_width", "slug", "sort_column", "sort_order", "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", "width") as $key) { @@ -112,23 +112,21 @@ class item_rest_Core { } break; - case "parent": - if (property_exists($entity, "parent")) { - $parent = rest::resolve($entity->parent); - access::required("edit", $parent); - $item->parent_id = $parent->id; - } - break; default: if (property_exists($entity, $key)) { $item->$key = $entity->$key; } } } + + $item->save(); + if (property_exists($entity, "parent")) { + $parent = rest::resolve($entity->parent); + item::move($item, $parent); + } } - $item->save(); - if (isset($request->params->members)) { + if (isset($request->params->members) && $item->sort_column == "weight") { $weight = 0; foreach ($request->params->members as $url) { $child = rest::resolve($url); -- cgit v1.2.3