<?php
// $Id: forumform.inc.php,v 1.1 2004/07/11 10:28:25 Farsus Exp $
// -------------------------------------------------------------------------//
//			                 RUNCMS                                         //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Based on:
// phpBB: http://www.phpBB.com
// License type: GPL
// ------------------------------------------------------------------------- //

include_once(XOOPS_ROOT_PATH."/class/xoopslists.php");
include_once(XOOPS_ROOT_PATH.'/class/xoopsform/formdhtmltextarea.php');
include_once('./cache/config.php');

if ( $newbbConfig['disc_show'] == 3 || ($isreply && $newbbConfig['disc_show'] == 2) || (empty($editpost) && $newbbConfig['disc_show'] == 1) ) {
	$disclaimer = join('', file("./cache/disclaimer.php"));
	if ($disclaimer != "") {
		OpenTable();
		$myts->setType('admin');
		echo $myts->makeTareaData4Show($disclaimer, 1, 1, 1);
		CloseTable();
		echo "<br /><br />";
	}
}

echo "
<table border='0' cellpadding='1' cellspacing='1' width='100%' class='bg2'><tr class='bg3' align='left'>
<td width='25%' valign='top'><b>". _MD_ABOUTPOST .":</b></td>";

if ( $forumdata['forum_access'] == 1 ) {
	echo "<td>". _MD_REGCANPOST ."</td>";
	} elseif ( $forumdata['forum_access'] == 2 ) {
		echo "<td>". _MD_ANONCANPOST ."</td>";
		} elseif ( $forumdata['forum_access'] == 3 ) {
			echo "<td>". _MD_MODSCANPOST ."</td>";
		}

echo "
</tr><tr class='bg1' align='left'>
<form action='post.php' method='post' name='forumform' id='forumform' onsubmit='return xoopsValidate(\"subject\", \"message\", \"contents_submit\");'>
<td width='25%' valign='top' style='white-space: nowrap;'><b>". _MD_YOURNAME ."</b></td><td>";

if ($xoopsUser) {
	echo "
	<a href='".XOOPS_URL."/userinfo.php?uid=".$xoopsUser->getVar("uid")."'>".$xoopsUser->getVar("uname")."</a>
	[ <a href='".XOOPS_URL."/user.php?op=logout'>"._MD_LOGOUT."</a> ]";
	} else {
		echo "
		<span style='color: #ff0000;'>".$xoopsConfig['anonymous']."</span>
		[ <a href='".XOOPS_URL."/register.php'>"._MD_REGISTER."</a> ]";
	}

echo "
</td></tr>
<tr class='bg3' align='left'>
<td valign='top' style='white-space: nowrap;'><b>". _MD_SUBJECTC ."</b></td>
<td>";

if ( !$istopic ) {
	if ( !preg_match("/^re:/i", $subject) ) {
		$subject = "Re: ".substr($subject, 0, 81);
	}
}

echo "
<input type='text' class='text' id='subject' name='subject' size='60' maxlength='100' value='$subject' /></td></tr>
<tr class='bg1' align='left'>
<td valign='top' style='white-space: nowrap;'><b>"._MD_MESSAGEICON."</b></td>
<td>
<table><tr align='left'>
<td>";

$lists    = new XoopsLists;
$filelist = $lists->getSubjectsList();
$count    = 1;
while ( list($key, $file) = each($filelist) ) {
	$checked = "";
	if ( isset($icon) && $file == $icon ) {
		$checked = " checked='checked'";
	}
	echo "
	<input type='radio' class='radio' value='$file' name='icon'$checked />
	<img src='".XOOPS_URL."/images/subject/$file' alt='' />";
	if ($count == 8) {
		echo "<br />";
		$count = 0;
	}
	$count++;
}

echo "
</td></tr></table></td>
</tr><tr class='bg3' align='left'>
<td valign='top' style='white-space: nowrap;'><b>"._MD_MESSAGEC."</b><br /></td>
<td><br />";

$desc = new XoopsFormDhtmlTextArea('', 'message', $message, 10, 50);
echo $desc->render();

if ( !empty($isreply) && isset($hidden) && $hidden != "" ) {
	echo "
	<input type='hidden' name='isreply' value='1' />
	<input type='hidden' name='hidden' id='hidden' value='$hidden' />
	<input type='button' class='button' name='quote' value='"._MD_QUOTE."' onclick='xoopsGetElementById(\"message\").value=xoopsGetElementById(\"message\").value + xoopsGetElementById(\"hidden\").value; xoopsGetElementById(\"hidden\").value=\"\";' />
	<br />";
}

echo "<br /><br />";

echo "
</td></tr>
<tr class='bg1' align='left'>
<td valign='top' style='white-space: nowrap;'><b>"._MD_OPTIONS."</b></td>
<td>";

// Allow html?
if ( $xoopsUser && !empty($forumdata['allow_html']) ) {
	echo _MD_ALLOWEDHTML."<br />";
	echo get_allowed_html();
	if ($allow_html == '0' || $HTTP_POST_VARS['allow_html'] == '0') {
		$option0 = " selected";
		} elseif ($allow_html == '2' || $HTTP_POST_VARS['allow_html'] == '2') {
			$option2 = " selected";
			} else {
				$option1 = " selected";
			}
	echo "<br /><br />
	<select class='select' name='allow_html'>
	<option value='0'$option0>"._HTMLOFF."</option>
	<option value='1'$option1>"._HTMLAUTOWRAP."</option>
	<option value='2'$option2>"._HTMLNOAUTOWRAP."</option>
	</select><br />";
	} else {
		echo "<input type='hidden' name='allow_html' value='0'>";
	}

// Enable Smileys?
echo "<input type='checkbox' class='checkbox' name='allow_smileys' value='1'";
if (!isPost() || $HTTP_POST_VARS['allow_smileys'] == 1) {
	echo " checked='checked'";
}
echo " />&nbsp;"._ENABLESMILEY."<br />";

// Enable bbcode?
echo "<input type='checkbox' class='checkbox' name='allow_bbcode' value='1'";
if (!isPost() || $HTTP_POST_VARS['allow_bbcode'] == 1) {
	echo " checked='checked'";
}
echo " />&nbsp;"._ENABLEBBCODE."<br />";


if ($xoopsUser && !empty($editpost) ) {
	echo "<input type='hidden' name='editpost' value='1' />";
}

if ($xoopsUser && isset($istopic) && $istopic) {
	echo "<input type='hidden' name='istopic' value='1' />";
	echo "<input type='checkbox' class='checkbox' name='notify' value='1'";
	if ( isset($notify) && $notify ) {
		echo " checked='checked'";
	}
	echo " />&nbsp;"._MD_EMAILNOTIFY."<br />";
}

if ( $xoopsUser && ($forumdata['forum_access'] == 2) && !$post_id ) {
	echo "<input type='checkbox' class='checkbox' name='noname' value='1'";
	if ( isset($noname) && $noname ) {
		echo " checked='checked'";
	}
	echo " />&nbsp;"._MD_POSTANONLY."<br />";
}

if ( $forumdata['allow_sig'] && $xoopsUser ) {
	echo "<input type='checkbox' class='checkbox' name='attachsig' value='1'";
	if ( isset($HTTP_POST_VARS['contents_preview'] ) ) {
		if ( $attachsig ) {
			echo " checked='checked' />&nbsp;";
			} else {
				echo " />&nbsp;";
			}
		} elseif ( isset($attachsig) && $attachsig == 1 ) {
			echo " checked='checked' />&nbsp;";
			} elseif ( isset($attachsig) && $attachsig == 0 ) {
				echo "/>&nbsp;";
				} else {
					if ( $xoopsUser->getVar("attachsig") ) {
						echo " checked='checked' />&nbsp;";
						} else {
							echo "/>&nbsp;";
						}
				}

	echo _MD_ATTACHSIG."<br />";
}

echo "
</td></tr>
<tr class='bg3' align='left'><td colspan='2' align='center'><br />
<input type='hidden' name='pid' value='".intval($pid)."' />
<input type='hidden' name='post_id' value='".intval($post_id)."' />
<input type='hidden' name='topic_id' value='".intval($topic_id)."' />
<input type='hidden' name='forum' value='".intval($forum)."' />
<input type='hidden' name='viewmode' value='$viewmode' />
<input type='hidden' name='order' value='".intval($order)."' />
<input type='submit' class='button' name='contents_preview' value='"._PREVIEW."' />
<input type='submit' class='button' name='contents_submit' id='contents_submit' value='"._SUBMIT."' />
<input type='button' class='button' onclick='location=\"";

if ( isset($topic_id) && $topic_id != "" ) {
	echo "viewtopic.php?topic_id=".intval($topic_id)."&amp;forum=".intval($forum)."\"'";
	} else {
		echo "viewforum.php?forum=".intval($forum)."\"'";
	}

echo " value='"._CANCEL."' /></form></td></tr></table>";
?>
