2.0, ); } /** * Implementation of hook_services_resources(). */ function services_views_services_resources() { $resources['views'] = array(); $resources['views']['retrieve'] = array( 'help' => 'Retrieves a view.', 'file' => array( 'type' => 'inc', 'module' => 'services_views', 'name' => 'services_views.resource', ), 'callback' => 'services_views_retrieve', 'access callback' => 'services_views_access', 'access arguments' => array('view'), 'access arguments append' => TRUE, 'args' => array( 'view_name' => array( 'name' => 'view_name', 'type' => 'string', 'description' => 'The name of the view to get.', 'source' => array('path' => '0'), 'optional' => FALSE, ), 'display_id' => array( 'name' => 'display_id', 'type' => 'string', 'description' => 'The display ID of the view to get.', 'source' => array('param' => 'display_id'), 'optional' => TRUE, 'default value' => 'default', ), 'args' => array( 'name' => 'args', 'type' => 'array', 'description' => 'A list of arguments to pass to the view.', 'source' => array('param' => 'args'), 'optional' => TRUE, 'default value' => array(), ), 'offset' => array( 'name' => 'offset', 'type' => 'int', 'description' => 'The number of the entry for the page begin with.', 'source' => array('param' => 'offset'), 'optional' => TRUE, 'default value' => 0, ), 'limit' => array( 'name' => 'limit', 'type' => 'int', 'description' => 'The total number of entries to list.', 'source' => array('param' => 'limit'), 'optional' => TRUE, 'default value' => 10, ), 'theme_output' => array( 'name' => 'theme_output', 'type' => 'bool', 'description' => 'Whether to return the raw data results or style the results.', 'source' => array('param' => 'theme_output'), 'optional' => TRUE, 'default value' => FALSE, ), 'filters' => array( 'name' => 'filters', 'type' => 'array', 'description' => 'A list of filters to pass to the view. These are defined by the exposed filters on your view. Example call: /views/your_view?filters[nid]=12345', 'source' => array('param' => 'filters'), 'optional' => TRUE, 'default value' => array(), ), ), ); return $resources; } /** * Check the access permission to a given views. * * @param $op * String. The operation that's going to be performed. * @param $args * Array. The arguments that will be passed to the callback. * @return * Boolean. TRUE if the user is allowed to load the given view. */ function services_views_access($op = 'view', $args = array()) { //watchdog('services_views_access', 'Argumentos @detail.', array('@detail' => print_r($args, 1)), WATCHDOG_ERROR); //return TRUE; switch ($op) { case 'view': $view = views_get_view($args[0]); if (empty($view)) { return services_error(t('View @view1 1could not be found', array('@view' => $args[0])), 404); } $args[1] = !(isset($args[1]) || $args[1]) ? 'default' : $args[1]; if (!isset($view->display[$args[1]])) { return services_error(t('Display @display on view @view could not be found', array( '@display' => $args[1], '@view' => $args[0], )), 404); } return $view->access($args[1]); } }