Skip to content

Commit

Permalink
Change the item rest update processing to call the itemm::move(source…
Browse files Browse the repository at this point in the history
…, 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.
  • Loading branch information
Tim Almdal committed Jun 15, 2010
1 parent c88d179 commit 603d464
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions modules/gallery/helpers/item_rest.php
Expand Up @@ -99,7 +99,7 @@ static function put($request) {
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) {
Expand All @@ -112,23 +112,21 @@ static function put($request) {
}
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);
Expand Down

0 comments on commit 603d464

Please sign in to comment.