Location: PHPKode > projects > SiteX > admin/forums_edit.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['EditorRightsForumsManage']))  loginError($sxLang['LoginRequired']);

if($Submit)
{
	$queryA = "SELECT * FROM $DB_Forums WHERE id='$forumid'";
	$resultA = mysql_query($queryA, $Link) or queryError("2080", mysql_error());
	$ROWA = mysql_fetch_object($resultA);
	
	// User changed group
	if($groupid != $ROWA->groupid)
	{
		// Get new position in new group
		$sxPositionRank = 0;
		$queryB = "SELECT * FROM $DB_Forums WHERE groupid='$groupid'";
		$resultB = mysql_query($queryB, $Link) or queryError("2081", mysql_error());
		while($ROWB = mysql_fetch_object($resultB))
		{
			if($ROWB->position > $sxPositionRank)
				$sxPositionRank = $ROWB->position;
		}
		
		// Update forum
		$sxPositionRank += 1;
		$query = "UPDATE $DB_Forums SET groupid='$groupid', position='$sxPositionRank' WHERE id='$forumid'";
		$result = mysql_query($query, $Link) or queryError("2082", mysql_error());
		
		// Update old group positions
		$sxOldPosition = $ROWA->position;
		$sxOldGroup = $ROWA->groupid;
		$queryB = "SELECT * FROM $DB_Forums WHERE groupid='$sxOldGroup' AND position>'$sxOldPosition'";
		$resultB = mysql_query($queryB, $Link) or queryError("2087", mysql_error());
		if(mysql_num_rows($resultB))
		{
			while($ROWB = mysql_fetch_object($resultB))
			{
				$query = "UPDATE $DB_Forums SET position='".($ROWB->position - 1)."' WHERE id='$ROWB->id'";
				$result = mysql_query($query, $Link) or queryError("2088", mysql_error());
			}
		}

	}
			
	$query = "UPDATE $DB_Forums SET name='$name', description='$description' WHERE id='$forumid'";
	$result = mysql_query($query, $Link) or queryError("2083", mysql_error());
	
	$query = "DELETE FROM $DB_Forums_Private WHERE forumid='$forumid'";
	$result = mysql_query($query, $Link) or queryError("2084", mysql_error());
	
	if($private)
	{
		foreach ($user_types as $k => $v)
		{
			$query = "INSERT INTO $DB_Forums_Private (forumid, typeid) VALUES ('$forumid', '$k')";
			$result = mysql_query($query, $Link) or queryError("2085", mysql_error());
		}
	}
	
	header("Location: forums_manager.php?message=".str_replace(" ","_",$sxLang['MessageForumEdited']));
	die();
}

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");

$query = "SELECT * FROM $DB_Forums WHERE id='$forumid'";
$result = mysql_query($query, $Link) or queryError("2086", mysql_error());
$ROW = mysql_fetch_object($result);

?>  
  <div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['ForumHeadingEdit']; ?></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['ForumHeadingEdit']; ?></div>   
   <?PHP echoMessage($message); ?>
	<form name="form1" method="post" action="<?PHP echo $PHP_SELF; ?>">
	<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;" value="<?PHP echo  htmlspecialchars($ROW->name); ?>" /></td>
	  </tr>
	  <tr>
		<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemDescription']; ?></td>
		<td><textarea name="description" id="description" style="width:300px;height:100px;"><?PHP echo $ROW->description; ?></textarea></td>
	  </tr>
	  <tr>
		<td class="sxTdItem"><?PHP echo $sxLang['ForumItemGroup']; ?></td>
		<td><select name="groupid">
		<?PHP
		$query2 = "SELECT * FROM $DB_Forums_Groups ORDER BY position ASC";
		$result2 = mysql_query($query2, $Link) or queryError("21", mysql_error());
		while($ROW2 = mysql_fetch_object($result2)){
			if($ROW->groupid == $ROW2->id) $checked = " selected";
			else $checked = "";
			echo '<option value="' . $ROW2->id . '"' . $checked . '>' . $ROW2->name . '</option>';
		}
		?>
		</select></td>
	  </tr>
	  <tr>
		<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemPrivate']; ?></td>
		<td><?PHP
		$checked = "";
		$query3 = "SELECT * FROM $DB_Forums_Private WHERE forumid='$ROW->id'";
		$result3 = mysql_query($query3, $Link) or queryError("21", mysql_error());
		if(mysql_num_rows($result3)) $checked = " checked";
		?>
		<input type="checkbox" name="private" value="1"<?PHP echo $checked; ?> /> <?PHP echo $sxLang['GeneralMakePrivate']; ?><hr size="1" noshade="noshade" /><?PHP
		$query2 = "SELECT * FROM $DB_Users_Types";
		$result2 = mysql_query($query2, $Link) or queryError("21", mysql_error());
		while($ROW2 = mysql_fetch_object($result2)){
			
			$checked = "";
			$query3 = "SELECT * FROM $DB_Forums_Private WHERE forumid='$ROW->id'";
			$result3 = mysql_query($query3, $Link) or queryError("21", mysql_error());
			while($ROW3 = mysql_fetch_object($result3)){
				if($ROW3->typeid == $ROW2->id) $checked = " checked";
			}
			
			echo '<input name="user_types[' . $ROW2->id . ']" type="checkbox" id="user_types" value="1"' . $checked;
			echo ' />' . $ROW2->name . '<br />';
		}
		?></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		  <td align="right">
		  <input type="hidden" name="forumid" value="<?PHP echo $forumid; ?>" />
		  <input type="submit" name="Submit" value="<?PHP echo $sxLang['ForumButtonEdit']; ?>" class="sxButton" /></td>
	  </tr>
	</table>
	</form>
  </div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX