You are here

function _node_resource_index in Services 6.2

Same name and namespace in other branches
  1. 6.3 resources/node_resource.inc \_node_resource_index()
  2. 7.3 resources/node_resource.inc \_node_resource_index()
  3. 7 services/node_service/node_resource.inc \_node_resource_index()
1 string reference to '_node_resource_index'
node_resource_service_resource in services/node_service/node_resource.module

File

services/node_service/node_resource.inc, line 99
CRUD resource functionality for nodes.

Code

function _node_resource_index($page = 0, $fields = array(), $parameters = array()) {
  if (module_exists('query_builder')) {
    $builder = new QueryBuilder();
    $parameters = (array) $parameters;
    if (isset($parameters['__describe'])) {
      return $builder
        ->describe();
    }
    if (is_string($fields) && !empty($fields)) {
      $fields = preg_split('/,\\s?/', $fields);
    }
    if (!user_access('administer nodes') || !isset($parameters['status'])) {
      $parameters['status'] = 1;
    }
    list($sql, $params) = $builder
      ->query($fields, $parameters);
  }
  else {
    $sql = "SELECT * FROM {node} WHERE status=1 ORDER BY sticky DESC, created DESC";
  }
  $res = db_query_range($sql, $params, $page * 20, 20);
  $events = array();
  while ($event = db_fetch_object($res)) {
    $event->uri = services_resource_uri(array(
      'node',
      $event->nid,
    ));
    $events[] = $event;
  }
  return $events;
}