function _comment_resource_index in Services 6.3
Same name and namespace in other branches
- 7.3 resources/comment_resource.inc \_comment_resource_index()
Return an array of optionally paged cids baed on a set of criteria.
An example request might look like
http://domain/endpoint/comment?fields=cid,nid¶meters[nid]=7¶mete...
This would return an array of objects with only cid and nid defined, where nid = 7 and uid = 1.
Parameters
$page: Page number of results to return (in pages of 20).
$fields: The fields you want returned.
$parameters: An array containing fields and values used to build a sql WHERE clause indicating items to retrieve.
$page_size: Integer number of items to be returned.
Return value
An array of comment objects.
See also
1 string reference to '_comment_resource_index'
- _comment_resource_definition in resources/
comment_resource.inc - @file Will define the comments resource for dealing with node comments
File
- resources/
comment_resource.inc, line 207 - Will define the comments resource for dealing with node comments
Code
function _comment_resource_index($page, $fields, $parameters, $page_size) {
// Limit to published nodes if user doesn't have 'administer nodes'
// permissions.
if (!user_access('administer comments')) {
$parameters['status'] = COMMENT_PUBLISHED;
}
$query = services_resource_build_index_query('comments', 'c.timestamp DESC', $page, $fields, $parameters, 'c', 'cid', $page_size, 'comment');
// Put together array of matching nodes to return.
$results = array();
while ($comments = db_fetch_object($query)) {
$results[] = $comments;
}
return services_resource_build_index_list($results, 'comments', 'cid');
}