From b7786fe9a3edca070cac45d0fba221033e0e3ee2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 13 Mar 2010 08:16:37 -0800 Subject: Changes to support updating the child elements within an album. In this change the urls of the children are sent up asan array of post fields children[0].... children[n]. If an existing child is not included it is deleted. Including a url to an child in another album will move the child. Changing the order of the children will respect the order of the children, if the sort column is 'weight' --- modules/gallery/helpers/items_rest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers/items_rest.php') diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 05ca65cf..48839dc9 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -19,10 +19,12 @@ */ class items_rest_Core { static function get($request) { + $parent = rest::resolve($request->url); + access::required("view", $parent); $items = array(); if (isset($request->params->url)) { - foreach($request->params->url as $url) { + foreach ($request->params->url as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { $members = array(); @@ -41,4 +43,12 @@ class items_rest_Core { return $items; } + + static function resolve($id) { + $item = ORM::factory("item", $id); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + return $item; + } } -- cgit v1.2.3