function _node_resource_update in Services 6.2
Same name and namespace in other branches
- 6.3 resources/node_resource.inc \_node_resource_update()
- 7.3 resources/node_resource.inc \_node_resource_update()
- 7 services/node_service/node_resource.inc \_node_resource_update()
1 string reference to '_node_resource_update'
- node_resource_service_resource in services/
node_service/ node_resource.module
File
- services/
node_service/ node_resource.inc, line 65 - CRUD resource functionality for nodes.
Code
function _node_resource_update($nid, $node) {
$node = (object) $node;
$node->nid = $nid;
$old_node = node_load($node->nid);
if ($old_node->nid) {
// Load the required includes for drupal_execute
module_load_include('inc', 'node', 'node.pages');
// Setup form_state.
$values = (array) $node;
$form_state = array();
$form_state['values'] = $values;
$form_state['values']['op'] = t('Save');
$form_state['node'] = (array) $old_node;
drupal_execute($old_node->type . '_node_form', $form_state, $old_node);
if ($errors = form_get_errors()) {
return services_error(implode("\n", $errors), 406);
}
}
else {
return services_error(t('Node not found'), 404);
}
return $node->nid;
}