You are here

function _authcache_forum_topic_info in Authenticated User Page Caching (Authcache) 6

Same name and namespace in other branches
  1. 7 ajax/authcache.php \_authcache_forum_topic_info()

Number of new topic replies for user or topic is unread

See also

forum.module

File

ajax/authcache.php, line 175
Authcache Ajax Callback (authcache.php)

Code

function _authcache_forum_topic_info($vars) {
  global $user;
  $info = array();
  drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
  include_once './modules/node/node.module';

  // Need NODE_NEW_LIMIT definition
  include_once './modules/forum/forum.module';
  include_once './modules/comment/comment.module';
  foreach ($vars as $nid => $timestamp) {
    $history = _forum_user_last_visit($nid);
    $new_topics = (int) comment_num_new($nid, $history);
    if ($new_topics) {
      $info[$nid] = format_plural($new_topics, '1 new', '@count new');
    }
    elseif ($timestamp > $history) {

      // unread
      $info[$nid] = 1;
    }
  }
  return $info;
}