summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/items_rest.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-05-10 06:31:38 -0700
committerTim Almdal <tnalmdal@shaw.ca>2010-06-04 14:05:24 -0700
commita600185b605a37ca1b60cb6d9814d5441f54cd88 (patch)
tree2cc56b6de72dfd10e6f3ab034e1e8c8f286b1a22 /modules/gallery/helpers/items_rest.php
parent04b90c3bdef9b2f4daf8bffc1e814b0bac9912f4 (diff)
Allow the use of the type query parameter to filter the results of a rest/gallery/items?urls=... request. This allows the client to pass the entire list of member urls and have the rest server filter the results based on the specified types.
(cherry picked from commit 3fe10b15cf9359b66452c24965df575203e8af8e)
Diffstat (limited to 'modules/gallery/helpers/items_rest.php')
-rw-r--r--modules/gallery/helpers/items_rest.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php
index 4f50e434..32597a65 100644
--- a/modules/gallery/helpers/items_rest.php
+++ b/modules/gallery/helpers/items_rest.php
@@ -19,23 +19,37 @@
*/
class items_rest_Core {
/**
- * To retrieve a collection of items, you can specify the following query parameters to specify the
- * type of the collection. If both are specified, then the url parameter is used and the
- * ancestor_for is ignored.
+ * To retrieve a collection of items, you can specify the following query parameters to specify
+ * the type of the collection. If both are specified, then the url parameter is used and the
+ * ancestor_for is ignored. Specifying the "type" parameter with the urls parameter, will
+ * filter the results based on the specified type. Using the type parameter with the
+ * ancestor_for parameter makes no sense and will be ignored.
*
* urls=url1,url2,url3
* return items that match the specified urls. Typically used to return the member detail
*
* ancestor_for=url
* return the ancestors of the specified item
+ *
+ * type=<comma separate list of photo, movie or album>
+ * limit the type to types in this list. eg, "type=photo,movie"
*/
static function get($request) {
$items = array();
if (isset($request->params->urls)) {
foreach (json_decode($request->params->urls) as $url) {
+ if (isset($request->params->type)) {
+ $types = explode(",", $request->params->type);
+ }
$item = rest::resolve($url);
if (access::can("view", $item)) {
- $items[] = items_rest::format_restful_item($item);
+ if (isset($types)) {
+ if (in_array($item->type, $types)) {
+ $items[] = items_rest::format_restful_item($item);
+ }
+ } else {
+ $items[] = items_rest::format_restful_item($item);
+ }
}
}
} else if (isset($request->params->ancestor_for)) {