##############################################################
## MOD Title: Newest Post On Index
## MOD Author: Nightrider < phpbb@4fxearth.net > (Blake) http://4fxearth.net/phpBB2
## MOD Description: Adds the newest overall post to the Welcome Info section on the Index page...
## MOD Version: 1.0.0
##
## Installation Level: Easy
## Installation Time: < 5 Minutes
##
## Files To Edit: 3
##		index.php
##		language/lang_english/lang_main.php
##		templates/subSilver/index_body.tpl
## Included Files: 0
##		
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##
##############################################################
## Author Notes: None
##############################################################
## MOD History:
##	Creation date: 03/25/07
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
include($phpbb_root_path . 'common.'.$phpEx);
#
#-----[ AFTER, ADD ]--------------------------------------
#
$newest_post = '';
#
#-----[ FIND ]------------------------------------------
#
if ( $forum_data[$j]['forum_last_post_id']
{
#
#-----[ AFTER, ADD ]--------------------------------------
#
							   if ( $newest_post == '' )  
							   {
							   	  $newest_post = $forum_data[$j];
							   }
							   else if ($forum_data[$j]['post_time'] > $newest_post['post_time'] )
							   {
							   	  $newest_post = $forum_data[$j];
							   }
#
#-----[ FIND ]------------------------------------------
#
//
// Generate the page
#
#-----[ BEFORE, ADD ]--------------------------------------
#
//
// Set Newest Post
//
if ( $newest_post != '' )
{
   $sql = "SELECT post_subject 
   		  FROM " . POSTS_TEXT_TABLE . " 
		  WHERE post_id = " . $newest_post['forum_last_post_id']; 

   if( ($result = $db->sql_query($sql)) ) 
   { 
   	 $row = $db->sql_fetchrow($result);
	 
	 $newest_subject = ( trim($row['post_subject']) != '' ) ? trim($row['post_subject']) : '';
	 
	 if ($newest_subject == '')
	 {
   	  	$sql = "SELECT topic_id 
   		  	   FROM " . POSTS_TABLE . " 
		  	   WHERE post_id = " . $newest_post['forum_last_post_id']; 

   		if( ($result = $db->sql_query($sql)) ) 
   		{
   	 	 	$row = $db->sql_fetchrow($result);
	 
   	  		$sql = "SELECT topic_title 
   		  	   FROM " . TOPICS_TABLE . " 
		  	   WHERE topic_id = " . $row['topic_id']; 

   			if ( ($result = $db->sql_query($sql)) ) 
   			{
   	 	 	   $row = $db->sql_fetchrow($result);
			   $newest_subject = $row['topic_title'];
			}
		} 
	 }
   } 

   $db->sql_freeresult($result);

   $last_post_time = create_date($board_config['default_dateformat'], $newest_post['post_time'], $board_config['board_timezone']);
   $newest_post2 = $lang['View_newest_post'] . '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $newest_post['forum_last_post_id']) . '#' . $newest_post['forum_last_post_id'] . '"><b>' . $newest_subject . '</b></a>';
   $newest_post2 .= ( $newest_post != '' ) ? ' by <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $newest_post['user_id']) . '"><b>' . $newest_post['username'] . '</b></a> ' : '';

   $template->assign_vars(array(
      'NEWEST_POST' => $newest_post2)
   );
}

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]--------------------------------------
#
$lang['View_newest_post'] = 'The newest post is :';
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]------------------------------------------
#
{NEWEST_USER}
#
#-----[ IN-LINE FIND ]------------------------------------------
#
{NEWEST_USER}
#
#-----[ IN-LINE AFTER, ADD ]--------------------------------------
#
<br /><br />{NEWEST_POST}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM