You are here

public function MigrateDestinationComment::rollback in Migrate 6.2

Delete a comment

Parameters

$cid: Array of comment ID fieldss to be deleted.

File

plugins/destinations/comment.inc, line 101
Support for comment destinations.

Class

MigrateDestinationComment
Destination class implementing migration into comments.

Code

public function rollback(array $cid) {
  $path = drupal_get_path('module', 'comment') . '/comment.admin.inc';
  include_once $path;

  // Backdoor deletion - query stolen from comment_delete()
  $form = array();
  $form_state = array();
  $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid
       FROM {comments} c
       LEFT JOIN {users} u ON u.uid = c.uid
       WHERE c.cid = %d', reset($cid)));

  // May have been deleted as the child of a comment previously deleted
  if ($comment) {
    $this
      ->prepareRollback($cid);
    $form['#comment'] = $comment;
    comment_confirm_delete_submit($form, $form_state);
    $this
      ->completeRollback($cid);
  }
}