diff --git a/forum.module b/forum.module index 06ec84c..a9803a5 100644 --- a/forum.module +++ b/forum.module @@ -806,7 +806,7 @@ function forum_forum_load($tid = NULL) { ->fetchObject(); // Merge in the "Last Post" information. - $last_post = new stdClass(); + $last_post = new Node(); if (!empty($topic->last_comment_timestamp)) { $last_post->created = $topic->last_comment_timestamp; $last_post->name = $topic->last_comment_name; @@ -878,7 +878,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { ); $order = _forum_get_topic_order($sortby); - for ($i = 0; $i < count($forum_topic_list_header); $i++) { + for ($i = 1; $i < count($forum_topic_list_header); $i++) { if ($forum_topic_list_header[$i]['field'] == $order['field']) { $forum_topic_list_header[$i]['sort'] = $order['sort']; } @@ -927,7 +927,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { ->orderByHeader($forum_topic_list_header) ->condition('n.nid', $nids); - $result = $query->execute(); + $result = $query->execute()->fetchAllAssoc('nid', PDO::FETCH_ASSOC); } else { $result = array(); @@ -935,7 +935,9 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $topics = array(); $first_new_found = FALSE; - foreach ($result as $topic) { + foreach ($result as $topic_result) { + $topic = new Node($topic_result); + if ($user->uid) { // A forum is new if the topic is new, or if there are new comments since // the user's last visit. @@ -962,12 +964,13 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { } if ($topic->comment_count > 0) { - $last_reply = new stdClass(); + $last_reply = new Node(); $last_reply->created = $topic->last_comment_timestamp; $last_reply->name = $topic->last_comment_name; $last_reply->uid = $topic->last_comment_uid; $topic->last_reply = $last_reply; } + $topics[] = $topic; } @@ -1160,7 +1163,10 @@ function template_preprocess_forum_topic_list(&$variables) { $variables['topics'][$id]->new_url = ''; if ($topic->new_replies) { $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new', '@count new'); - $variables['topics'][$id]->new_url = url("node/$topic->nid", array('query' => comment_new_page_count($topic->comment_count, $topic->new_replies, $topic), 'fragment' => 'new')); + + $count = comment_new_page_count($topic->comment_count, $topic->new_replies, $topic); + $options = array('query' => $count, 'fragment' => 'new'); + $variables['topics'][$id]->new_url = url("node/$topic->nid", $options); } }