<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------+
| Modified by PHP-Fusion SF Group
| Copyright © 2007 by SF
| http://www.rus-phpfusion.com/
+----------------------------------------------------*/
require_once "../../maincore.php";
require_once BASEDIR."subheader.php";
require_once BASEDIR."side_left.php";

if (file_exists(INFUSIONS."forum_threads_list_panel/locale/".$settings['locale'].".php")) {
	include INFUSIONS."forum_threads_list_panel/locale/".$settings['locale'].".php";
} else {
	include INFUSIONS."forum_threads_list_panel/locale/English.php";
}

if (!iMEMBER) fallback("index.php");

if (iMEMBER && isnum($_GET['lookup'])) {
	$lookup = $_GET['lookup'];
	$data = dbarray(dbquery("SELECT user_name FROM ".$db_prefix."users WHERE user_id='$lookup'"));
	$locale['027'] = $locale['URPM_002'].$data['user_name'];
	$locale['038'] = $data['user_name']." ".$locale['URPM_004'];
} else { $lookup = $userdata['user_id']; }

$result = dbquery(
	"SELECT tp.*, tf.* FROM ".$db_prefix."posts tp
	INNER JOIN ".$db_prefix."forums tf USING(forum_id)
	WHERE ".groupaccess('forum_access')." AND post_author='$lookup' LIMIT 100"
);
$rows = dbrows($result);
if ($rows != 0) {
	if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
	$result = dbquery(
		"SELECT tp.*, tf.* FROM ".$db_prefix."posts tp
		INNER JOIN ".$db_prefix."forums tf USING(forum_id)
		WHERE ".groupaccess('forum_access')." AND post_author='$lookup'
		ORDER BY post_datestamp DESC LIMIT $rowstart,20"
	);
	$i=0;
	opentable($locale['ftl111']);
	echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>\n<tr>\n";
	echo "<td style='text-align:center;' class='tbl2'>&nbsp;</td><td style='text-align:center;' width='180' class='tbl2'><span class='small'><b>".$locale['030']."</b></span></td>
<td style='text-align:center;' class='tbl2'><span class='small'><b>".$locale['ftl121']."</b></span></td>
<td style='text-align:center;' width='100' class='tbl2'><span class='small'><b>".$locale['ftl122']."</b></span></td>
</tr>\n";
	while ($data = dbarray($result)) {
		if ($i % 2 == 0) { $row_color = "tbl1"; } else { $row_color = "tbl2"; }
		$reply_count = dbcount("(thread_id)", "posts", "thread_id='".$data['thread_id']."'");
		$rstart = ($reply_count > 20 ? "rowstart=".((ceil($reply_count / 20)-1)*20)."&amp;" : "");
		echo "<tr>
						<td class='tbl1'><img alt='' border='0' src='".THEME."forum/folder.gif'>
                        </td>
<td width='180' class='$row_color'><span class='small'>".trimlink($data['forum_name'], 30)."</span></td>
<td class='$row_color'><span class='small'><a href='".FORUM."viewthread.php?".$rstart."forum_id=".$data['forum_id']."&amp;thread_id=".$data['thread_id']."#".$data['post_id']."' title='".$data['post_subject']."'>".trimlink($data['post_subject'], 40)."</a></span></td>
<td style='text-align:center;' width='115' class='$row_color'><span class='small'>".showdate("forumdate", $data['post_datestamp'])."</span></td>
</tr>\n";
		$i++;
	}
	echo "</table>\n";
	closetable();
	if ($rows > 20) echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,20,$rows,3,FUSION_SELF."?lookup=$lookup&amp;")."\n</div>\n";
} else {
	opentable($locale['027']);
	echo "<center><br>\n".$locale['038']."<br><br>\n</center>\n";
	closetable();
}

require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";
?>