comment_unpublish_action

Definition

comment_unpublish_action($comment, $context = array())
drupal/modules/comment/comment.module, line 2100

Description

Drupal action to unpublish a comment.

Parameters

$context Keyed array. Must contain the id of the comment if $comment is not passed.

$comment An optional comment object.

Code

function comment_unpublish_action($comment, $context = array()) {
  if (isset($comment->cid)) {
    $cid = $comment->cid;
    $subject = $comment->subject;
  }
  else {
    $cid = $context['cid'];
    $subject = db_query('SELECT subject FROM {comment} WHERE cid = :cid', array(':cid', $cid))->fetchField();
  }
  db_update('comment')
    ->fields(array('status' => COMMENT_NOT_PUBLISHED,))
    ->condition('cid', $cid)
    ->execute();
  watchdog('action', 'Unpublished comment %subject.', array('%subject' => $subject));
}