<?php
// ======================================================================== //
//   KOOBI - CMS                                                            //
//   SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS                     //
//                                                                          //
//   DREAM4 - AM MICHELSGRUND 7 - 69469 WEINHEIM - GERMANY                  //    
//   TEL. +49(0) 6201 - 980442 / FAX. +49(0) 6201 - 64809                   //
// ======================================================================== //
if(!checkactive('forums')) include(dirname(__FILE__)."/lib/notactive.php" );
// forum id überprüfen
$forum_result = new dbc("SELECT title, status FROM " . PREFIX . "_f_forum WHERE id = '" . escs($_REQUEST['fid']) . "'");
$forum = $forum_result->fetchrow();

// es wurde eine falsche fid übergeben
if ($forum_result->numrows() < 1) {
	$EOUT = msg("f_forum", "f_noid", str_replace("__URL__", "index.php?p=showforums&amp;area=$area", $lang['redirect']), "index.php?p=showforums&amp;area=$area");
	$NOOUT = 1;
}

if ( ($forum->status == FORUM_STATUS_CLOSED) && (UGROUP != 1) ) {
	$EOUT = msg("f_forum", "f_msg_forumclosed", str_replace("__URL__", "index.php?p=showforums&amp;area=$area", $lang['redirect']), "index.php?p=showforums&amp;area=$area");
	$NOOUT = 1;
}

// ====================================================================================
// zugriffsrechte
// ====================================================================================
$cat_query = new dbc("SELECT group_id FROM " . PREFIX . "_f_forum WHERE id = '" . escs($_REQUEST['fid']) . "'");
while ($category = $cat_query->fetchrow_assoc()) {
	
	// miscrechte
	$group_ids = array();
	include ( BASEDIR . "/system/misc_ids.php");
	
	$perm = false;
	$groups = explode(",", $category['group_id']);
	if (array_intersect($group_ids, $groups)) {
			$permissions = getForumPermissionsByUser(escs($_REQUEST['fid']), UID);
			if ($permissions[FORUM_PERMISSION_CAN_CREATE_TOPIC] == 1) {
				$perm = true;
		}
		
	}
	
}


// user ist nicht eingeloggt, hat keine berechtigung oder ist kein admin
//if ( ($islogged == 0 || !$perm) && (UGROUP != 1) ) {
if ( (!$perm) && (UGROUP != 1) ) {
	$EOUT = msg("nopermission", "nopermission_t", str_replace("__URL__", "index.php?p=showforum&amp;fid=" . escs($_REQUEST['fid']) . "&amp;area=$area", $lang['redirect']), "index.php?p=showforum&amp;fid=" . escs($_REQUEST['fid']) ."&amp;area=$area");
	$NOOUT = 1;
}

if (SMILIES == 1) $tmpl->assign("smilie", 1);

// navigation erzeugen
$navigation = getNavigation(escs($_REQUEST['fid']), "forum");

$stitle = $lang["forumtitle"];
$sname = simpletitle(str_replace($lang['f_navi_separator'], " - ", strip_tags($navigation)) . " - " . $forum->title);

$tmpl->assign("permissions", $permissions);
$tmpl->assign("bbcodes", BBCODESITE);
$tmpl->assign("new_topic", 1);
$tmpl->assign("navigation", $navigation . $lang['f_navi_separator'] . "<a class='forum_links_navi' href='index.php?p=showforum&amp;fid=" . escs($_REQUEST['fid']). "&amp;area=$area'>" . $forum->title . "</a>");
$tmpl->assign("maxlength_post", MAXLENGTH_POST);
$tmpl->assign("listfonts",  fontdropdown());
$tmpl->assign("sizedropdown",  sizedropdown());
$tmpl->assign("colordropdown",  colordropdown());
$tmpl->assign("lang", $lang);
$tmpl->assign("posticons", getPosticons());
$tmpl->assign("listemos", listsmilies());
$tmpl->assign("forum_id", $_GET["fid"]);
$tmpl->assign("topicform", $tmpl->fetch("forums/topicform.tpl"));
$tmpl->assign("threadform", $tmpl->fetch("forums/threadform.tpl"));
$tmpl->assign("action", "index.php?p=addtopic");
$tmpl->assign("content", parsetrue("container/".container("forum"), $stitle, $tmpl->fetch("forums/addtopic.tpl")));
?>