You are here

function comment_unpublish_by_keyword_action in Drupal 6

Same name and namespace in other branches
  1. 7 modules/comment/comment.module \comment_unpublish_by_keyword_action()

Action to unpublish a comment if it contains a certain string.

Parameters

$comment: A comment object.

$context: An array providing more information about the context of the call to this action. Unused here, since this action currently only supports the insert and update ops of the comment hook, both of which provide a complete $comment object.

See also

comment_unpublish_by_keyword_action_form()

comment_unpublish_by_keyword_action_submit()

Related topics

File

modules/comment/comment.module, line 2121
Enables users to comment on published content.

Code

function comment_unpublish_by_keyword_action($comment, $context) {
  foreach ($context['keywords'] as $keyword) {
    if (strpos($comment->comment, $keyword) !== FALSE || strpos($comment->subject, $keyword) !== FALSE) {
      db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $comment->cid);
      watchdog('action', 'Unpublished comment %subject.', array(
        '%subject' => $comment->subject,
      ));
      break;
    }
  }
}