Skip to content
Browse files

Patch from ticket 1503, making rest/items behaviour consisten with re…

…st/item behaviour.
  • Loading branch information...
1 parent 414ea72 commit 3f0d54c088b6ba1b28f4ebd0198839c5b782d2f0 @kandsten kandsten committed with bharat Nov 27, 2010
Showing with 5 additions and 3 deletions.
  1. +5 −3 modules/gallery/helpers/items_rest.php
View
8 modules/gallery/helpers/items_rest.php
@@ -45,7 +45,7 @@ static function get($request) {
if (access::can("view", $item)) {
if (isset($types)) {
if (in_array($item->type, $types)) {
- $items[] = items_rest::_format_restful_item($item);
+ $items[] = items_rest::_format_restful_item($item, $types);
}
} else {
$items[] = items_rest::_format_restful_item($item);
@@ -74,14 +74,16 @@ static function resolve($id) {
return $item;
}
- private static function _format_restful_item($item) {
+ private static function _format_restful_item($item, $types = null) {
$item_rest = array("url" => rest::url("item", $item),
"entity" => $item->as_restful_array(),
"relationships" => rest::relationships("item", $item));
if ($item->type == "album") {
$members = array();
foreach ($item->viewable()->children() as $child) {
- $members[] = rest::url("item", $child);
+ if ($types == null || in_array($child->type, $types)) {
+ $members[] = rest::url("item", $child);
+ }
}
$item_rest["members"] = $members;
}

0 comments on commit 3f0d54c

Please sign in to comment.
Something went wrong with that request. Please try again.