summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/item_rest.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-06-15 11:20:04 -0700
committerTim Almdal <tnalmdal@shaw.ca>2010-06-15 11:20:04 -0700
commit603d4640141a43350f50da747d747456b28fdd93 (patch)
tree4b86127981d38765f1e393f3638065f8f1e9be23 /modules/gallery/helpers/item_rest.php
parentc88d17966e64a2fce34f88551c6fbf28f06316f8 (diff)
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.
Diffstat (limited to 'modules/gallery/helpers/item_rest.php')
-rw-r--r--modules/gallery/helpers/item_rest.php18
1 files changed, 8 insertions, 10 deletions
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);