function webform_service_resource_access in Webform Service 7.4
Same name and namespace in other branches
- 6.3 webform_service.module \webform_service_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.
$load_node: Function that loads the node.
Return value
bool
See also
1 string reference to 'webform_service_resource_access'
- _webform_resource_definition in resources/
webform_resource.inc - The webform resource definition.
File
- ./
webform_service.module, line 82
Code
function webform_service_resource_access($op = 'view', $type = '', $args = array()) {
$node = null;
if (empty($args[0])) {
return services_error(t('Must provide a uuid.'), 404);
}
else {
if (is_array($args[0]) || is_object($args[0])) {
$node = (object) $args[0];
}
else {
if (in_array(gettype($args[0]), array(
'string',
'integer',
))) {
$node = webform_service_resource_load($args[0]);
}
}
}
if ($node) {
// Return the node resource access.
$node->type = $type;
module_load_include('inc', 'services', 'resources/node_resource');
return _node_resource_access($op, array(
$node,
));
}
else {
// Return a 404.
return services_error(t('Webform @uuid could not be found', array(
'@uuid' => $args[0],
)), 404);
}
}