You are here

function realtime_comment_action in Node.js integration 6

Callback to handle comment notifications.

File

nodejs_actions/nodejs_actions.module, line 255

Code

function realtime_comment_action($comment, $context = array()) {
  if (isset($comment->cid)) {
    $cid = $comment->cid;
    $subject = $comment->subject;
    $action = t($context['op']);
  }
  else {
    $cid = $context['cid'];
    $subject = db_result(db_query("SELECT subject FROM {comments} WHERE cid = %d", $cid));
  }
  $link = l($comment->subject, 'node/' . $comment->nid, array(
    'fragment' => 'comment-' . $comment->cid,
  ));
  $body = t('The User !name did %action a comment !link .', array(
    '!name' => $comment->namex,
    '%action' => $action,
    '!link' => $link,
  ));
  nodejs_actions_enqueue_message($subject, $body);
}