diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-26 00:24:10 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-26 00:24:10 -0800 |
commit | f268128043a56888ef35d07ee5d02012b8349c74 (patch) | |
tree | a29e4c8016b5e42b2dc3d197b5d1476bbedff2ad | |
parent | 5c68519d9233eabe98fce34fc00cdd4595f03ded (diff) |
Add support for adding tags in the item_tags and tag_items
relationship collections.
-rw-r--r-- | modules/tag/helpers/item_tags_rest.php | 13 | ||||
-rw-r--r-- | modules/tag/helpers/tag_items_rest.php | 13 | ||||
-rw-r--r-- | modules/tag/helpers/tags_rest.php | 7 |
3 files changed, 32 insertions, 1 deletions
diff --git a/modules/tag/helpers/item_tags_rest.php b/modules/tag/helpers/item_tags_rest.php index 385d06e8..ce814f77 100644 --- a/modules/tag/helpers/item_tags_rest.php +++ b/modules/tag/helpers/item_tags_rest.php @@ -30,6 +30,19 @@ class item_tags_rest_Core { "members" => $tags); } + static function post($request) { + $tag = rest::resolve($request->params->tag); + $item = rest::resolve($request->params->item); + access::required("view", $item); + + tag::add($item, $tag->name); + return array( + "url" => rest::url("tag_item", $tag, $item), + "members" => array( + rest::url("tag", $tag), + rest::url("item", $item))); + } + static function delete($request) { list ($tag, $item) = rest::resolve($request->url); $tag->remove($item); diff --git a/modules/tag/helpers/tag_items_rest.php b/modules/tag/helpers/tag_items_rest.php index 2a00c565..369a8d83 100644 --- a/modules/tag/helpers/tag_items_rest.php +++ b/modules/tag/helpers/tag_items_rest.php @@ -32,6 +32,19 @@ class tag_items_rest_Core { "members" => $items); } + static function post($request) { + $tag = rest::resolve($request->params->tag); + $item = rest::resolve($request->params->item); + access::required("view", $item); + + tag::add($item, $tag->name); + return array( + "url" => rest::url("tag_item", $tag, $item), + "members" => array( + rest::url("tag", $tag), + rest::url("item", $item))); + } + static function delete($request) { list ($tag, $item) = rest::resolve($request->url); $tag->remove($item); diff --git a/modules/tag/helpers/tags_rest.php b/modules/tag/helpers/tags_rest.php index 57461125..89ff0f21 100644 --- a/modules/tag/helpers/tags_rest.php +++ b/modules/tag/helpers/tags_rest.php @@ -23,7 +23,8 @@ class tags_rest_Core { foreach (ORM::factory("tag")->find_all() as $tag) { $tags[] = rest::url("tag", $tag); } - return array("members" => $tags); + return array("url" => rest::url("tags"), + "members" => $tags); } static function post($request) { @@ -45,4 +46,8 @@ class tags_rest_Core { return array("url" => rest::url("tag", $tag)); } + + static function url() { + return url::abs_site("rest/tags"); + } } |