function _comment_resource_update in Services 7.3
Same name and namespace in other branches
- 6.3 resources/comment_resource.inc \_comment_resource_update()
 
Updates a comment and returns the cid.
Parameters
$cid: Unique identifier for this comment.
$comment: An object as would be returned from comment_load().
Return value
Unique identifier for the comment (cid) or FALSE if there was a problem.
1 string reference to '_comment_resource_update'
- _comment_resource_definition in resources/
comment_resource.inc  
File
- resources/
comment_resource.inc, line 264  
Code
function _comment_resource_update($cid, $comment) {
  // Adds backwards compatability with regression fixed in #1083242
  $comment = _services_arg_value($comment, 'data');
  $comment['cid'] = $cid;
  $old_comment = comment_load($cid);
  if (empty($old_comment)) {
    return services_error(t('Comment @cid not found', array(
      '@cid' => $cid,
    )), 404);
  }
  // Setup form_state.
  $form_state = array();
  $form_state['values'] = $comment;
  $form_state['values']['op'] = variable_get('services_comment_save_button_resource_update', t('Save'));
  $form_state['comment'] = $old_comment;
  $form_state['programmed_bypass_access_check'] = FALSE;
  drupal_form_submit('comment_form', $form_state, $old_comment);
  if ($errors = form_get_errors()) {
    return services_error(implode(" ", $errors), 406, array(
      'form_errors' => $errors,
    ));
  }
  return $cid;
}