function comment_unpublish_by_keyword_action
7.x comment.module | comment_unpublish_by_keyword_action($comment, $context) |
6.x comment.module | comment_unpublish_by_keyword_action($comment, $context) |
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
2 string references to 'comment_unpublish_by_keyword_action'
- comment_action_info in drupal-6.x/
modules/ comment/ comment.module - Implementation of hook_action_info().
- hook_action_info in documentation-6.x/
developer/ hooks/ core.php - Declare information about one or more Drupal actions.
File
- drupal-6.x/
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;
}
}
}