function _node_resource_retrieve in Services 6.3
Same name and namespace in other branches
- 6.2 services/node_service/node_resource.inc \_node_resource_retrieve()
- 7.3 resources/node_resource.inc \_node_resource_retrieve()
- 7 services/node_service/node_resource.inc \_node_resource_retrieve()
Returns the results of a node_load() for the specified node.
This returned node may optionally take content_permissions settings into account, based on a configuration setting.
Parameters
$nid: NID of the node we want to return.
Return value
Node object or FALSE if not found.
See also
2 string references to '_node_resource_retrieve'
- hook_services_resources in ./
services.services.api.php - Implementation of hook_services_resources(). Defines function signatures for resources available to services.
- _node_resource_definition in resources/
node_resource.inc - @file This file will define the resources for dealing directly with nodes
File
- resources/
node_resource.inc, line 224 - This file will define the resources for dealing directly with nodes
Code
function _node_resource_retrieve($nid) {
global $user;
$node = node_load($nid);
if ($node) {
// Apply field level content permissions
if (module_exists('content') && variable_get('services_use_content_permissions', TRUE)) {
$type_info = content_types($node->type);
foreach ($type_info['fields'] as $field_name => $field_info) {
if (isset($node->{$field_name})) {
$access = module_invoke_all('field_access', 'view', $field_info, $user, $node);
if (in_array(FALSE, $access)) {
unset($node->{$field_name});
}
}
}
}
$node->uri = services_resource_uri(array(
'node',
$node->nid,
));
return $node;
}
return services_error('Node nid ' . $nid . ' not found', 404);
}