You are here

function views_service_get_view in Services 5

Get a view from the database.

1 string reference to 'views_service_get_view'
views_service_service in services/views_service/views_service.module
Implementation of hook_service().

File

services/views_service/views_service.module, line 105
The module which exposes services related to views module

Code

function views_service_get_view($view_name, $fields = array(), $args = array(), $limit = 0, $page = 0, $offset = 0, $filters = NULL) {
  $view = views_get_view($view_name);
  if (is_null($view)) {
    return services_error('View does not exist.');
  }

  // Check access
  if (!views_access($view)) {
    return services_error('You do not have access to this view.');
  }
  $result = views_build_view('result', $view, $args, FALSE, $limit, $page, $offset, $filters);
  while ($node = db_fetch_object($result['result'])) {
    $nodes[] = services_node_load(node_load(array(
      'nid' => $node->nid,
    )), $fields);
  }
  return $nodes;
}