function _node_resource_access in Services 7.3
Same name and namespace in other branches
- 6.3 resources/node_resource.inc \_node_resource_access()
- 6.2 services/node_service/node_resource.module \_node_resource_access()
- 7 services/node_service/node_resource.module \_node_resource_access()
Determine whether the current user can access a node resource.
Parameters
$op: One of view, update, create, delete per node_access().
$args: Resource arguments passed through from the original request.
Return value
bool
See also
3 string references to '_node_resource_access'
- hook_services_resources in docs/
services.services.api.php - Defines function signatures for resources available to services.
- ServicesRESTServerTests::getTestResource in servers/
rest_server/ tests/ ServicesRESTServerTests.test - _node_resource_definition in resources/
node_resource.inc
File
- resources/
node_resource.inc, line 521
Code
function _node_resource_access($op = 'view', $args = array()) {
// Adds backwards compatability with regression fixed in #1083242
if (isset($args[0])) {
$args[0] = _services_access_value($args[0], 'node');
}
// Make sure we have an object or this all fails, some servers can
// mess up the types.
if (is_array($args[0])) {
$args[0] = (object) $args[0];
}
elseif (!is_array($args[0]) && !is_object($args[0])) {
//This is to determine if it is just a string happens on node/%NID
$args[0] = (object) array(
'nid' => $args[0],
);
}
if ($op != 'create' && !empty($args)) {
$node = node_load($args[0]->nid);
}
elseif ($op == 'create') {
if (isset($args[0]->type)) {
$node = $args[0]->type;
return node_access($op, $node);
}
else {
return services_error(t('Node type is required'), 406);
}
}
if (isset($node->nid) && $node->nid) {
return node_access($op, $node);
}
else {
return services_error(t('Node @nid could not be found', array(
'@nid' => $args[0]->nid,
)), 404);
}
}