<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// $Id: delete.php,v 1.3 2003/07/05 18:44:15 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Based on:
// phpBB: http://www.phpBB.com
// License type: GPL
// ------------------------------------------------------------------------- //
include_once("header.php");
if ( empty($forum) ){
	redirect_header("index.php", 2, _MD_ERRORFORUM);
	exit();
	} elseif ( empty($post_id) ) {
		redirect_header("viewforum.php?forum=$forum", 2, _MD_ERRORPOST);
		exit();
	}
if ( $xoopsUser ) {
	if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
		if ( !is_moderator($forum, $xoopsUser->uid()) ) {
			redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _NOTALLOWEDTODELETE);
			exit();
		}
	}
	} else {
		redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _NOTALLOWEDTODELETE);
		exit();
	}
include_once("class/class.forumposts.php");
if ( !empty($ok) ) {
	if ( !empty($post_id) ) {
		$post = new ForumPosts($post_id);
		$post->delete();
		sync($post->forum(), "forum");
		sync($post->topic(), "topic");
	}
	if ( $post->istopic() ) {
		redirect_header("viewforum.php?forum=$forum", 2, _MD_POSTSDELETED);
		exit();
	} else {
		redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_POSTSDELETED);
		exit();
	}
	} else {
		include_once(XOOPS_ROOT_PATH."/header.php");
		OpenTable();
		echo "<h4 style='color:#ff0000;'>"._SURETODELETECOMMENT."</font></h4>";
		echo "<table><tr><td>";
		echo myTextForm("./delete.php?post_id=".$post_id."&viewmode=".$viewmode."&order=".$order."&forum=".$forum."&topic_id=".$topic_id."&ok=1", _YES);
		echo "</td><td>";
		echo myTextForm("javascript:history.go(-1)", _NO);
		echo "</td></tr></table>";
		CloseTable();
	}
include_once(XOOPS_ROOT_PATH."/footer.php");
?>
