<?php
// ======================================================================== //
//                                                                          //
//   KooBI- Webportalsystem                                                 //
//   SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS                     //
//                                                                          //
//   ====================================================================   //
//                                                                          //   
//   dream4 | webservices - Am Michelsgrund 7 - 69469 Weinheim - Germany    //    
//   tel. +49(0) 6201 - 980442 / fax. +49(0) 6201 - 64809                   //
//                                                                          //
// ======================================================================== //
$sql = new dbc("SELECT uid FROM ".PREFIX."_f_topic WHERE id='$_REQUEST[toid]'");
$row = $sql->fetchrow();
if($row->uid == UID){
	$own = 1;
}

$f_id = ($_POST['id'] != "") ? $_POST['fid'] : $_GET['fid'];


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



if($own != 1){
	if ($permissions[FORUM_PERMISSIONS_CAN_DELETE_TOPIC] == 0) {
		$EOUT = msg("nopermission", "nopermission_t", str_replace("__URL__", "index.php?p=showforums", $lang['redirect']), "index.php?p=showforums");
		$NOOUT = 1;
	}
}
else
{
	if ($permissions[FORUM_PERMISSION_CAN_DELETE_OWN_TOPIC] == 0) {
		$EOUT = msg("nopermission", "nopermission_t", str_replace("__URL__", "index.php?p=showforums", $lang['redirect']), "index.php?p=showforums");
		$NOOUT = 1;
	}
}

if($NOOUT != 1){
	
	if ($_REQUEST["toid"] == "" || $_GET["fid"] == "") {
		$EOUT = msg("f_newforum", "f_noid", str_replace("__URL__", "index.php?p=showforums", $lang['redirect']), "index.php?p=showforums");
		$NOOUT = 1;
	}
	
	deleteTopic($_GET["toid"]);
	
	$EOUT = msg("f_forum", "f_actionsuccess", str_replace("__URL__", "index.php?p=showforum&amp;fid=" . $_GET["fid"], $lang['redirect']), "index.php?p=showforum&amp;fid=" . $_GET["fid"]);
	$NOOUT = 1;
}
?>