############################################################## ## Mod Title: shows topic of last made post on index ## Mod Version: 1.4.0 ## Author: e-sven http://www.e-sven.net ## Description: -adds lasts post topic to each forum on ## the index page (based on read-access) ## -word censorship is used ## -topic title with more then 27 chars are cut off ## -mouseover info displays the full title ## ## Installation Level: easy ## Installation Time: 2-5 Minutes ## Files To Edit: index.php ## Included Files: index.php (pre-modded) ############################################################## ## History: ## 0.9 not released beta ## 1.0 first working release ## 1.1 optimized db access ## 1.2 made implementation easier ## (only two replaces have to be made) ## 1.2a just a minor bug (thanks to Acid) ## 1.3 empty forums where not displayed correctly ## 1.4 optimized db-query ############################################################## ## Before Adding This MOD To Your Forum, ## You Should Back Up All Files Related To This MOD ############################################################## # #-----[ OPEN ]------------------------------------------------ # index.php # #-----[ ACTION Find ]----------------------------------------- # $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id FROM (( " . FORUMS_TABLE . " f LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id ) LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) ORDER BY f.cat_id, f.forum_order"; break; } if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql); } $forum_data = array(); while( $row = $db->sql_fetchrow($result) ) { $forum_data[] = $row; } if ( !($total_forums = count($forum_data)) ) { message_die(GENERAL_MESSAGE, $lang['No_forums']); } // // Obtain a list of topic ids which contain # #-----[ REPLACE WITH ]---------------------------------------- # $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_title, t.topic_last_post_id " . " FROM ((( " . FORUMS_TABLE . " f " . " LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )" . " LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) " . " LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = p.post_id ) " . " ORDER BY f.cat_id, f.forum_order"; break; } if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql); } $forum_data = array(); $topic_last_ary = array(); $i=0; while( $row = $db->sql_fetchrow($result) ) { if (!in_array($row['topic_last_post_id'], $topic_last_ary) || $row['topic_last_post_id']==0) { $topic_last_ary[i]=$row['topic_last_post_id']; $i++; $forum_data[] = $row; } } unset($topic_last_ary); if ( !($total_forums = count($forum_data)) ) { message_die(GENERAL_MESSAGE, $lang['No_forums']); } // // Filter topic_title not allowed to read // if ( !($userdata['user_level'] == ADMIN && $userdata['session_logged_in']) ) { $auth_read_all = array(); $auth_read_all=auth(AUTH_READ, AUTH_LIST_ALL, $userdata, $forum_data); $auth_data = ''; for($i=0; $i27) { $topic_title = substr($topic_title,0,24) . '...'; } $last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']); $last_post = '' . $topic_title . '
'; $last_post .= $last_post_time . ' ' . $lang['View_latest_post'] . '
' . $lang['by'] . ' '; $last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '' . $forum_data[$j]['username'] . ' '; } # #-----[ SAVE/CLOSE ALL FILES ]---------------------------------- #