You are here

function _node_resource_validate_type in Services 6.3

Same name and namespace in other branches
  1. 7.3 resources/node_resource.inc \_node_resource_validate_type()
2 calls to _node_resource_validate_type()
_node_resource_create in resources/node_resource.inc
Creates a new node based on submitted values.
_node_resource_update in resources/node_resource.inc
Updates a new node based on submitted values.

File

resources/node_resource.inc, line 315
This file will define the resources for dealing directly with nodes

Code

function _node_resource_validate_type($node) {
  if (!isset($node['type'])) {
    return services_error(t('Missing node type'), 406);
  }

  // Wanted to return a graceful error instead of a blank nid, this should
  // allow for that.
  $types = node_get_types();
  $node_type = $node['type'];
  if (!isset($types[$node_type])) {
    return services_error(t('Node type @type does not exist.', array(
      '@type' => $node_type,
    )), 406);
  }
  $allowed_node_types = variable_get('services_allowed_create_content_types', $types);
  if (!isset($allowed_node_types[$node_type])) {
    return services_error(t("This node type @type can't be processed via services", array(
      '@type' => $node_type,
    )), 406);
  }
}