<?php
// ------------------------------------------------------------------------- //
//                XOOPS - PHP Content Management System                      //
//                       <http://www.xoops.org/>                             //
// ------------------------------------------------------------------------- //
// Based on:								     //
// myPHPNUKE Web Portal System - http://myphpnuke.com/	  		     //
// PHP-NUKE Web Portal System - http://phpnuke.org/	  		     //
// Thatware - http://thatware.org/					     //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
// ------------------------------------------------------------------------- //

function b_newbb_new_show($options) {
	global $xoopsDB;
	$myts =& MyTextSanitizer::getInstance();
    	$block = array();
    	$block['title'] = _MB_NEWBB_RECENT;
    	$query="SELECT t.topic_id, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.forum_id, f.forum_name FROM ".$xoopsDB->prefix("bb_topics")." t, ".$xoopsDB->prefix("bb_forums")." f WHERE (f.forum_id=t.forum_id) AND (f.forum_type <> '1') ORDER BY t.topic_time DESC";
//echo $query;
    	if(!$result=$xoopsDB->query($query,$options[0],0)){
		echo "ERROR";
	}
    	if ($xoopsDB->getRowsNum($result) > 0) {
		$block['content'] = "<table border='0' cellpadding='0' cellspacing='0' valign='top' width='100%' class='bg2'><tr><td>\n";
		$block['content'] .= "<table width='100%' border='0' cellpadding='4' cellspacing='1'>\n";
		$block['content'] .= "<tr class='bg3'>";
		if ( $options[1] != 0 ) {
    			$block['content'] .= "<td><b>" ._MB_NEWBB_FORUM."</b></td>";
		}
		$block['content'] .= "<td><b>" ._MB_NEWBB_TOPIC."</b></td><td align='center'><b>" ._MB_NEWBB_RPLS."</b></td><td align='center'><b>" ._MB_NEWBB_VIEWS."</b></td>";
		if ( $options[1] != 0 ) {
			$block['content'] .= "<td align='right'><b>" ._MB_NEWBB_LPOST."</b></td>";
		}
		$block['content'] .= "</tr>";
    		while ( $arr = $xoopsDB->fetchArray($result) ) {
			$block['content'] .= "<tr class='bg1'>";
			if ( $options[1] != 0 ) {
				$block['content'] .= "<td><a href='".XOOPS_URL."/modules/newbb/viewforum.php?forum=" . $arr["forum_id"] . "'>";
				$block['content'] .= $myts->makeTboxData4Show($arr["forum_name"]);

				$block['content'] .= "</a></td>";
			}
			$block['content'] .= "<td><a href='".XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=" . $arr["topic_id"] . "&amp;forum=" . $arr["forum_id"] . "'>";
			$block['content'] .= $myts->makeTboxData4Show($arr["topic_title"]);
			$block['content'] .= "</a></td>";
			$block['content'] .= "<td align='center'>".$arr["topic_replies"]."</td>";
			$block['content'] .= "<td align='center'>".$arr["topic_views"]."</td>";
			if ( $options[1] != 0 ) {
				$block['content'] .= "<td align='right'>".formatTimestamp($arr["topic_time"],"m"). "</td>";
			}
		}
		$block['content'] .= "</tr></table></td></tr><tr class='bg4'><td align='right'><span style='font-weight:bold;'>&raquo;&raquo;</span>&nbsp;<b><a href='".XOOPS_URL."/modules/newbb/'>"._MB_NEWBB_VSTFRMS."</a></b>";
		$block['content'] .= "</td></tr></table>";
	} else {
		$block = false;
	}
    	return $block;
}

function b_newbb_new_edit($options) {
	$inputtag = "<input type='text' name='options[]' value='".$options[0]."' />";
	$form = sprintf(_MB_NEWBB_DISPLAY,$inputtag);
	$form .= "<br />"._MB_NEWBB_DISPLAYF."&nbsp;<input type='radio' id='options[]' name='options[]' value='1'";
	if ( $options[1] == 1 ) {
		$form .= " checked='checked'";
	}
	$form .= " />&nbsp;"._YES."<input type='radio' id='options[]' name='options[]' value='0'";
	if ( $options[1] == 0 ) {
		$form .= " checked='checked'";
	}
	$form .= " />&nbsp;"._NO."";
	return $form;
}

?>