From 7a1bd41d507e08789f97320bdea418ff371399c9 Mon Sep 17 00:00:00 2001 From: Lorenz Schori Date: Mon, 21 Jan 2013 17:40:57 +0100 Subject: [PATCH 6/6] Fix forums for drupal 7 --- ajax/authcache.php | 2 ++ authcache.js | 33 +++++++++++++++------------------ authcache.module | 6 +++--- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/ajax/authcache.php b/ajax/authcache.php index 42b98dd..546bddf 100644 --- a/ajax/authcache.php +++ b/ajax/authcache.php @@ -165,6 +165,7 @@ function _authcache_forum_topic_new($vars) { drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); include_once './includes/common.inc'; + include_once './includes/path.inc'; include_once './modules/field/field.module'; include_once './modules/node/node.module'; // Need NODE_NEW_LIMIT definition include_once './modules/forum/forum.module'; @@ -189,6 +190,7 @@ function _authcache_forum_topic_info($vars) { drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); include_once './includes/common.inc'; + include_once './includes/path.inc'; include_once './modules/field/field.module'; include_once './modules/node/node.module'; // Need NODE_NEW_LIMIT definition include_once './modules/forum/forum.module'; diff --git a/authcache.js b/authcache.js index 8b55825..35b7de1 100644 --- a/authcache.js +++ b/authcache.js @@ -83,26 +83,23 @@ Authcache.init.preprocess = function() { Authcache.ajaxRequest(ajaxJson); } - if (Authcache.isEnabled) { - - // Forums "new" markers - if (Authcache.info.cache_uid && Authcache.ajax.q.substring(0,5) == "forum") { - - // Check for new topics - jQuery(".authcache-topic-new").each(function(i, elSpan) { - if (Authcache.ajax["forum_topic_new[]"] == null) Authcache.ajax["forum_topic_new[]"] = new Array(); - id = elSpan.getAttribute("data-forum-id"); - Authcache.ajax["forum_topic_new[]"].push(id); - }); + // Forums "new" markers + if (jQuery.cookie('drupal_uid') && Authcache.ajax.q.substring(0,5) == "forum") { + + // Check for new topics + jQuery(".authcache-topic-new").each(function(i, elSpan) { + if (Authcache.ajax["forum_topic_new[]"] == null) Authcache.ajax["forum_topic_new[]"] = new Array(); + id = elSpan.getAttribute("data-forum-id"); + Authcache.ajax["forum_topic_new[]"].push(id); + }); - // Get number of new comments or if topic node is unread - jQuery(".authcache-topic-info").each(function(i, elSpan) { - timestamp = elSpan.getAttribute("data-timestamp"); - nid = elSpan.getAttribute("data-nid"); + // Get number of new comments or if topic node is unread + jQuery(".authcache-topic-info").each(function(i, elSpan) { + timestamp = elSpan.getAttribute("data-timestamp"); + nid = elSpan.getAttribute("data-nid"); - Authcache.ajax["forum_topic_info["+nid+"]"] = new Array(timestamp); - }); - } + Authcache.ajax["forum_topic_info["+nid+"]"] = new Array(timestamp); + }); } // Show "edit" comment links for user diff --git a/authcache.module b/authcache.module index 81b0bde..e316cd4 100644 --- a/authcache.module +++ b/authcache.module @@ -676,11 +676,11 @@ function authcache_preprocess_forum_topic_list(&$variables) { $icon . ''; - $variables['topics'][$id]->title .= ''; + $variables['topics'][$id]->title .= ''; // "New" reply count will be handle via Ajax - if ($topic->num_comments) { - $variables['topics'][$id]->num_comments .= ''; + if ($topic->comment_count) { + $variables['topics'][$id]->comment_count .= ''; $variables['topics'][$id]->new_text = ''; $variables['topics'][$id]->new_url = ''; } -- 1.7.10.4