You are here

function _subscriptions_content_format_comments in Subscriptions 6

Same name and namespace in other branches
  1. 5.2 subscriptions_content.module \_subscriptions_content_format_comments()

Given a comment template returns a formatted text of comments for given node.

2 calls to _subscriptions_content_format_comments()
_subscriptions_content_node_mailvars in ./subscriptions_content.module
Fill given array of mailvars with given node values.
_subscriptions_mail_cron in ./subscriptions_mail.cron.inc
Implementation of hook_cron().

File

./subscriptions_content.module, line 692
Subscriptions to content events

Code

function _subscriptions_content_format_comments($node, $comment_template, $separator) {
  $comments = array();
  foreach ($node->_subscriptions_comments as $comment) {
    $mailvars = array(
      '!comment_name' => $comment->uid == 0 ? variable_get('anonymous', '!comment_name') : $comment->name,
      '!comment_uid' => $comment->uid,
      '!comment_title' => trim($comment->subject),
      '!comment_text' => _subscriptions_content_format_text($comment->comment, $comment->format),
      '!comment_cid' => $comment->cid,
      '!comment_nid' => $comment->nid,
      '!comment_url' => url('node/' . $comment->nid, array(
        'fragment' => 'comment-' . $comment->cid,
        'absolute' => TRUE,
      )),
      '!comment_is_new' => (int) $comment->_subscriptions_is_new,
      '!comment_is_published' => (int) ($comment->status == COMMENT_PUBLISHED),
    );
    if (function_exists('realname_make_name')) {
      $mailvars += array(
        '!comment_realname' => realname_make_name($comment),
      );
    }
    $template = module_invoke('subscriptions_mail', 'template_preprocess', $comment_template, $mailvars);
    $comments[] = strtr($template ? $template : $comment_template, $mailvars);
  }
  return implode($separator, $comments);
}