You are here

function node_service_save in Services 5

Same name and namespace in other branches
  1. 6 services/node_service/node_service.inc \node_service_save()
  2. 6.2 services/node_service/node_service.inc \node_service_save()
  3. 7 services/node_service/node_service.inc \node_service_save()
1 string reference to 'node_service_save'
node_service_service in services/node_service/node_service.module
Implementation of hook_service().

File

services/node_service/node_service.module, line 134
The module which exposes services related to nodes

Code

function node_service_save($edit) {
  if ($edit['nid']) {
    $node = node_load($edit['nid']);
    if ($node->nid) {
      $ret = drupal_execute($node->type . '_node_form', $edit, $node);
      $nid = $node->nid;
    }
  }
  else {
    $ret = drupal_execute($edit['type'] . '_node_form', $edit, $edit);
    $nid = (int) substr($ret, strpos($ret, '/') + 1);
  }
  if ($errors = form_get_errors()) {
    return services_error(implode("\n", $errors));
  }
  return $nid;
}