<?php
//v1.3 www.exoops.info 2006/03 
// $Id: edit.php,v 1.2 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 (!isset($forum)) {
	redirect_header("index.php", 2, _MD_ERRORFORUM);
	exit();
	} elseif (!isset($post_id)) {
		redirect_header("viewforum.php?forum=$forum", 2, _MD_ERRORPOST);
		exit();
		} else {
			$editpost = 1;
			$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->fetchArray($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 == 1 ) {
			redirect_header("viewtopic.php?topic_id=$topic_id&post_id=$post_id&order=$order&viewmode=$viewmode&pid=$pid&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("viewtopic.php?topic_id=$topic_id&post_id=$post_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum",2,_MD_NORIGHTTOPOST);
		exit();
	}
	include_once(XOOPS_ROOT_PATH."/header.php");
	include_once("class/class.forumposts.php");
	OpenTable();
	$forumpost      = new ForumPosts($post_id);
	$allow_html     = intval($forumpost->allow_html());
	$allow_smileys  = intval($forumpost->allow_smileys());
	$allow_bbcode   = intval($forumpost->allow_bbcode());
	$icon           = $forumpost->icon();
	$attachsig      = intval($forumpost->attachsig());
	$topic_id       = intval($forumpost->topic());
	if ($forumpost->is_topic($post_id)) {
		$istopic = 1;
		$notify = $forumpost->notify();
		} else {
			$istopic = 0;
		}
	$subject  = $forumpost->subject("Edit");
	$message  = $forumpost->text("Edit");
	$hidden   = "";
	$viewmode = $myts->oopsHtmlSpecialChars($viewmode);
	include_once("include/forumform.inc.php");
	CloseTable();
	include_once(XOOPS_ROOT_PATH."/footer.php");
}
?>
