diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2010-03-13 08:16:37 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2010-03-13 08:39:06 -0800 |
commit | 5467e21e8b9941a2b64aa093c0cf0f591ef5ca82 (patch) | |
tree | 28d2d43ef5ea4cfba2cf177371ce0bf2d8961591 /modules/gallery/helpers/items_rest.php | |
parent | 931453304805b59751c5d3dffef42b8692b6fe65 (diff) |
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'
Diffstat (limited to 'modules/gallery/helpers/items_rest.php')
-rw-r--r-- | modules/gallery/helpers/items_rest.php | 12 |
1 files changed, 11 insertions, 1 deletions
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; + } } |