function comment_publish_action
7.x comment.module | comment_publish_action($comment, $context = array()) |
6.x comment.module | comment_publish_action($comment, $context = array()) |
Publishes a comment.
Parameters
$comment: An optional comment object.
array $context: Array with components:
- 'cid': Comment ID. Required if $comment is not given.
Related topics
1 call to comment_publish_action()
- CommentActionsTestCase::testCommentPublishUnpublishActions in drupal-7.x/
modules/ comment/ comment.test - Test comment publish and unpublish actions.
1 string reference to 'comment_publish_action'
- comment_action_info in drupal-7.x/
modules/ comment/ comment.module - Implements hook_action_info().
File
- drupal-7.x/
modules/ comment/ comment.module, line 2560 - Enables users to comment on published content.
Code
function comment_publish_action($comment, $context = array()) {
if (isset($comment->subject)) {
$subject = $comment->subject;
$comment->status = COMMENT_PUBLISHED;
}
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_PUBLISHED))
->condition('cid', $cid)
->execute();
}
watchdog('action', 'Published comment %subject.', array('%subject' => $subject));
}