<?php
// $Id: newtopic.php,v 1.1 2004/07/11 10:28:23 Farsus Exp $
// -------------------------------------------------------------------------//
//			                 RUNCMS                                         //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //

include_once("header.php");

if ( empty($forum) ) {
	redirect_header("index.php", 2, _MD_ERRORFORUM);
	exit();
} else {
	$sql = "SELECT forum_type, forum_name, forum_access, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page FROM ".$db->prefix("bb_forums")." WHERE forum_id = $forum";
	if(!$result = $db->query($sql)) {
		redirect_header("index.php", 2, _MD_CANTGETFORUM);
		exit();
	}
	$forumdata = $db->fetch_array($result);
	if ($forumdata['forum_type'] == 1) {
		$accesserror = 0;
		if ( $xoopsUser ) {
			if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
				if ( !check_priv_forum_auth($xoopsUser->uid(), $forum, TRUE) ) {
					$accesserror = 1;
				}
			}
		} else {
			$accesserror = 1;
		}
		if ( $accesserror ) {
			redirect_header("viewforum.php?order=$order&viewmode=$viewmode&forum=$forum",2,_MD_NORIGHTTOPOST);
			exit();
		}
	}
	$accesserror = 0;
	if ( $forumdata['forum_access'] == 3 ) {
		if ( $xoopsUser ) {
			if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
				if ( !is_moderator($forum, $xoopsUser->uid()) ) {
					$accesserror = 1;
				}
			}
		} else {
			$accesserror = 1;
		}

	} elseif ( $forumdata['forum_access'] == 1 && !$xoopsUser ) {
		$accesserror = 1;
	}
	if ( $accesserror == 1 ) {
		redirect_header("viewforum.php?order=$order&viewmode=$viewmode&forum=$forum",2,_MD_NORIGHTTOPOST);
		exit();
	}
	include_once(XOOPS_ROOT_PATH."/header.php");
	OpenTable();
	$istopic  = 1;
	$pid      = 0;
	$subject  = "";
	$message  = "";
	$viewmode = $myts->oopsHtmlSpecialChars($viewmode);
	$hidden   = "";
	unset($post_id);
	unset($topic_id);
	include_once("include/forumform.inc.php");
	CloseTable();
	include_once(XOOPS_ROOT_PATH."/footer.php");
}
?>
