Changeset 1290
- Timestamp:
- 08/16/08 15:30:44 (4 months ago)
- Files:
-
- forum-last-poster/trunk/forum-last-poster.php (modified) (2 diffs)
- forum-last-poster/trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
forum-last-poster/trunk/forum-last-poster.php
r1204 r1290 2 2 /* 3 3 Plugin Name: Forum Last Poster 4 Description: Adds forum_last_poster, forum_time() and other functions to bbPress to mimic the topic tables' freshness columns. Requires simple template edits.4 Description: Adds `forum_last_poster()`, `forum_time()`, `forum_last_post_link()` and other functions to bbPress to mimic the topic tables' FRESHNESS column. Requires simple template edits. 5 5 Plugin URI: http://bbpress.org/plugins/topic/123 6 6 Author: _ck_ 7 7 Author URI: http://bbShowcase.org 8 Version: 0.0. 28 Version: 0.0.3 9 9 */ 10 10 … … 22 22 23 23 function forum_last_topic_id($id = 0) { 24 global $forums_last_topic_id, $forum, $bbdb ;24 global $forums_last_topic_id, $forum, $bbdb, $bb_topic_cache; 25 25 if (!$id) {$id=$forum->forum_id;} 26 if (!isset($forums_last_topic_id)) { 27 $last_topics = $bbdb->get_results("SELECT t1.forum_id as forum_id, t1.topic_id as topic_id FROM $bbdb->topics AS t1 LEFT JOIN $bbdb->topics AS t2 ON t1.forum_id=t2.forum_id AND t1.topic_time < t2.topic_time WHERE t1.topic_status=0 AND t2.forum_id IS NULL;"); 28 foreach ($last_topics as $forum_last_topic_id) {if ($temp=$forum_last_topic_id->forum_id) {$forums_last_topic_id[$temp]=$forum_last_topic_id->topic_id;}} 29 if (function_exists("post_count_plus")) {bb_cache_last_posts($forums_last_topic_id);} // cache last poster name for links to last post 26 if (!isset($forums_last_topic_id)) { // unfortunately the join method does not handle deleted topics correctly and returns no results for that forum :-( 27 // $last_topics = $bbdb->get_results("SELECT t1.forum_id as forum_id, t1.topic_id as topic_id FROM $bbdb->topics AS t1 LEFT JOIN $bbdb->topics AS t2 ON t1.forum_id=t2.forum_id AND t1.topic_time < t2.topic_time WHERE t1.topic_status=0 AND t2.forum_id IS NULL;"); 28 $last_topics = $bbdb->get_results("SELECT forum_id, topic_id FROM $bbdb->topics WHERE topic_last_post_id IN (SELECT MAX(topic_last_post_id) FROM $bbdb->topics WHERE topic_status=0 GROUP BY forum_id)"); 29 foreach ($last_topics as $forum_last_topic_id) { 30 if ($temp=$forum_last_topic_id->forum_id) { 31 $forums_last_topic_id[$temp]=$forum_last_topic_id->topic_id; 32 if (!isset($bb_topic_cache[$forum_last_topic_id->topic_id])) {$add_cache[]->topic_id=$forum_last_topic_id->topic_id;} 33 } 34 } if (!empty($add_cache)) {bb_cache_post_topics($add_cache);} // cache topics not already in cache 30 35 } return $forums_last_topic_id[$id]; 31 36 } forum-last-poster/trunk/readme.txt
r1204 r1290 7 7 Donate link: http://amazon.com/paypage/P2FBORKDEFQIVM 8 8 9 Adds `forum_last_poster()` `forum_time()` and other functions to bbPress to mimic the topic tables' FRESHNESS column. Requires simple template edits.9 Adds `forum_last_poster()`, `forum_time()`, `forum_last_post_link()` and other functions to bbPress to mimic the topic tables' FRESHNESS column. Requires simple template edits. 10 10 11 11 == Description == 12 12 13 Adds `forum_last_poster()` `forum_time()` and other functions to bbPress to mimic the topic tables' FRESHNESS column. Requires simple template edits.13 Adds `forum_last_poster()`, `forum_time()`, `forum_last_post_link()` and other functions to bbPress to mimic the topic tables' FRESHNESS column. Requires simple template edits. 14 14 15 High performance: requires only a single extra query regardless of the number of forums listed (when topics are on same page).15 High performance: uses only a single extra query regardless of the number of forums listed (when topics are on same page). 16 16 17 17 == Installation == … … 31 31 <?php while ( bb_forum() ) : ?> 32 32 <tr<?php bb_forum_class(); ?>> 33 <td ><?php bb_forum_pad( '<div class="nest">' ); ?><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a><small><?php forum_description(); ?></small><?php bb_forum_pad( '</div>' ); ?></td>33 <td class="num"><?php bb_forum_pad( '<div class="nest">' ); ?><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a><small><?php forum_description(); ?></small><?php bb_forum_pad( '</div>' ); ?></td> 34 34 <td class="num"><?php forum_time(); ?></td> 35 35 <td class="num"><?php forum_topics(); ?></td> … … 73 73 * first public alpha release 74 74 75 = Version 0.0.3 (2008-08-16) = 76 77 * unfortunately the join query does not handle deleted topics correctly and returns no results for that forum, so have to use subquery :-( 78 75 79 == To Do == 76 80
