diff options
Diffstat (limited to 'modules/tag')
-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"); + } } |