You are here

function comment_delete_move_replies in Comment Delete 6

Same name and namespace in other branches
  1. 7 comment_delete.module \comment_delete_move_replies()

Moves replies of a comment up one level.

1 call to comment_delete_move_replies()
comment_delete_form_submit in ./comment_delete.module
Delete the comment and manage the replies using the appropiate action.

File

./comment_delete.module, line 176

Code

function comment_delete_move_replies($comment, $old_cid = 0) {
  $parent_id = $comment->pid;
  $results = db_query("SELECT * FROM {comments} WHERE pid = %d", $old_cid ? $old_cid : $comment->cid);
  while ($edit = db_fetch_array($results)) {
    $old_cid = $edit['cid'];
    unset($edit['cid']);
    $edit['pid'] = $parent_id;
    $new_cid = comment_save($edit);
    $new_comment = _comment_load($new_cid);
    comment_delete_move_replies($new_comment, $old_cid);
  }
}