Location: PHPKode > projects > SiteX > admin/forums_add.php
<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");

if((!userForumManager())AND(!userAdmin())AND(!userEditor()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsForumsAdd']))  loginError($sxLang['LoginRequired']);

if($Submit)
{
	$query = "SELECT * FROM $DB_Forums WHERE groupid='$groupid' ORDER BY position DESC LIMIT 0,1";
	$result = mysql_query($query, $Link) or queryError("21", mysql_error());
	$ROW = mysql_fetch_object($result);
	$nextPosition = $ROW->position + 1;
			
	$query = "INSERT INTO $DB_Forums
	         (name, description, position, groupid) VALUES
			 ('$name', '$description', '$nextPosition', '$groupid')";
	$result = mysql_query($query, $Link) or queryError("21", mysql_error());
	
	$query = "SELECT * FROM $DB_Forums WHERE groupid='$groupid' ORDER BY position DESC LIMIT 0,1";
	$result = mysql_query($query, $Link) or queryError("21", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	if($private)
	{
		foreach ($user_types as $k => $v)
		{
			$query = "INSERT INTO $DB_Forums_Private (forumid, typeid) VALUES ('$ROW->id', '$k')";
			$result = mysql_query($query, $Link) or queryError("21", mysql_error());
		}
	}
	header("Location: forums_manager.php?message=".str_replace(" ","_",$sxLang['MessageForumAdded']));
	die();
}
$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function submitIt(myForm){
	if(form1.name.value.length < 1){
		alert("<?PHP echo $sxLang['ForumJSNoName']; ?>");
		form1.name.select();
		return false;
	}
}
//-->
</script>         
<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['ForumHeadingAdd']; ?></h1> 
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <a href="forums_manager.php"><?PHP echo $sxLang['ForumHeadingManager']; ?></a> > <?PHP echo $sxLang['ForumHeadingAdd']; ?></div>   
	<?PHP echoMessage($message); ?>
	<form name="form1" method="post" action="<?PHP echo $PHP_SELF; ?>" onSubmit="return submitIt(this)">
	<table border="0" cellspacing="0" cellpadding="5">
	  <tr>
		<td class="sxTdItem"><?PHP echo $sxLang['ForumItemForumName']; ?></td>
		<td><input type="text" name="name" id="name" style="width:300px;" /></td>
	  </tr>
	  <tr>
		<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemDescription']; ?></td>
		<td><textarea name="description" id="description" style="width:300px;height:100px;"></textarea></td>
	  </tr>
	  <tr>
		<td class="sxTdItem"><?PHP echo $sxLang['ForumItemGroup']; ?></td>
		<td><select name="groupid"><?PHP
		$query = "SELECT * FROM $DB_Forums_Groups ORDER BY position ASC";
		$result = mysql_query($query, $Link) or queryError("21", mysql_error());
		while($ROW = mysql_fetch_object($result)){
			echo '<option value="' . $ROW->id . '">' . $ROW->name . '</option>';
		}
		?></select></td>
	  </tr>
	  <tr>
		<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemPrivate']; ?></td>
		<td><input type="checkbox" name="private" value="1" /> <?PHP echo $sxLang['GeneralMakePrivate']; ?><hr size="1" noshade="noshade" /><?PHP
		$query = "SELECT * FROM $DB_Users_Types";
		$result = mysql_query($query, $Link) or queryError("21", mysql_error());
		while($ROW = mysql_fetch_object($result)){
			if($error){
				$found = false;
				foreach ($user_types as $k => $v) {
					if($k == $ROW->id) $found = true;
				}
				if($found) $checked = " checked";
				else $checked = "";
			}
			echo '<input name="user_types[' . $ROW->id . ']" type="checkbox" id="user_types" value="1"' . $checked;
			//if($ROW->id == 1) echo ' onclick="document.form1.user_types.checked=true"';
			echo ' />' . $ROW->name . '<br />';
		}
		?></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td align="right"><input type="submit" name="Submit" value="<?PHP echo $sxLang['ForumButtonAdd']; ?>" class="sxButton" /></td>
	  </tr>
	</table>
	</form>
  </div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX