You are here

function advanced_forum_first_new_post_link in Advanced Forum 5

Same name and namespace in other branches
  1. 6.2 advanced_forum.module \advanced_forum_first_new_post_link()
  2. 6 advanced_forum.module \advanced_forum_first_new_post_link()
  3. 7.2 advanced_forum.module \advanced_forum_first_new_post_link()

Returns a link directly to the first new post in a topic.

Parameters

$node: Node object

$comment_count: Number of comments on passed node.

Return value

Link to the first unread comment with text as "42 new".

1 call to advanced_forum_first_new_post_link()
advanced_forum_preprocess_advanced_forum_topic_header in ./advanced_forum.module
Preprocesses template variables for the topic header template.

File

./advanced_forum.module, line 1481
Enables the look and feel of other popular forum software.

Code

function advanced_forum_first_new_post_link($node, $comment_count) {
  $nid = $node->nid;
  $current_page = $_GET['page'];
  $number_new_comments = comment_num_new($nid);
  if ($number_new_comments > 0) {

    // Note that we are linking to the cid anchor rather than "new" because
    // the new links will be gone if we go to another page.
    $page_of_first_new = comment_new_page_count($comment_count, $number_new_comments, $node);
    $cid_of_first_new = advanced_forum_first_new_comment($nid);
    return l($number_new_comments . ' ' . t('new'), "node/{$nid}", NULL, $page_of_first_new, "comment-{$cid_of_first_new}");
  }
}