You are here

function _services_raw_field_access in Services Client 7.2

Same name and namespace in other branches
  1. 7 services_raw/services_raw.inc \_services_raw_field_access()

Determine whether user has access to node resource and raw node_save.

Parameters

$op: Operation

$args: Additional arguments passed to call

1 string reference to '_services_raw_field_access'
_services_raw_services_resources in services_raw/services_raw.inc
Provides API definition of provided services objects and operations.

File

services_raw/services_raw.inc, line 262
Custom services definition and implementation of all callbacks.

Code

function _services_raw_field_access($op = 'view', $args = array()) {
  switch ($args['entity_type']) {
    case 'node':
      module_load_include('inc', 'services', 'resources/node_resource');
      if (function_exists('entity_get_id_by_uuid')) {
        $result = entity_get_id_by_uuid('node', array(
          $args['uuid'],
        ));
        $args[0]['nid'] = reset($result);
      }
      else {
        $args[0]['nid'] = uuid_node_find($args['uuid']);
      }
      return user_access('access raw node_save') && _node_resource_access($op, $args);
    case 'user':
      module_load_include('inc', 'services', 'resources/user_resource');
      if (function_exists('entity_get_id_by_uuid')) {
        $result = entity_get_id_by_uuid('user', $args['uuid']);
        $args[0]['uid'] = reset($result);
      }
      else {
        $args[0]['uid'] = uuid_user_find($args['uuid']);
      }
      return user_access('access raw user_save') && _node_resource_access($op, $args);

    // This could be expanded to allow for other entity types as this module
    // develops to support them. For now we can only dance with nodes and users.
    default:
      return FALSE;
  }
}