You are here

function advanced_forum_first_new_post_link in Advanced Forum 6.2

Same name and namespace in other branches
  1. 5 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 post.

1 call to advanced_forum_first_new_post_link()
advanced_forum_preprocess_advanced_forum_topic_header in includes/theme.inc
Preprocesses template variables for the topic header template.

File

./advanced_forum.module, line 894
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 = isset($_GET['page']) ? $_GET['page'] : 0;
  $number_new_comments = advanced_forum_reply_num_new($nid);
  if ($number_new_comments > 0) {
    $page_of_first_new = advanced_forum_page_first_new($comment_count, $number_new_comments, $node);

    // 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.
    $cid_of_first_new = advanced_forum_first_new_comment($nid);
    $number_new = t("(!new new)", array(
      '!new' => $number_new_comments,
    ));
    $options = array(
      'html' => TRUE,
      'query' => $page_of_first_new,
      'fragment' => "comment-{$cid_of_first_new}",
    );
    return theme('advanced_forum_l', t('First unread'), "node/{$nid}", $options, 'large');
  }
}