<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	//  move existing thread
	// ========================================================================================

	
	ReadPermissions();
	Global $Permissions;
	

	$Arguments3 = intval($Arguments3);
	
	if ($Arguments3 > 0) {	
				
		// if this user has moderator permissions
		if ($Permissions[202] == 'y') {
		
			
			$query = "select * from `".$Settings['DBPrefix']."mb-Threads` where RecordNumber=".$Arguments3." limit 1";
			$result = mysql_query($query) or die (mysql_error());
			$row = mysql_fetch_array($result);
			
			$ThreadTitle = $row['Title'];
			$BoardID = $row['BoardID'];
			
				
			$query = "select Title,Category,Description from `".$Settings['DBPrefix']."mb-Boards` where RecordNumber=".$BoardID." limit 1";
			$result = mysql_query($query) or die (mysql_error());
			$row = mysql_fetch_array($result);
			
			$BoardTitle = $row['Title'];
			$BoardDescription = $row['Description'];
			$CategoryID = $row['Category'];
			
					
			$query = "select Title,Description from `".$Settings['DBPrefix']."mb-Categories` where RecordNumber=".$CategoryID." limit 1";
			$result = mysql_query($query) or die (mysql_error());
			$row = mysql_fetch_array($result);
			
			$CategoryTitle = $row['Title'];
			//$CategoryDescription = $row['Description'];
			
			
				
			
			$PageTitle = '<div align="'.$AlignmentCodes[$mbSettings['TitleAlignment']].'">'.$mbSettings['PageTitle'].'</div>';
			$BrowserTitle = $mbSettings['PageTitle'] . ' - '.$MsgText[2][101];
			$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/forum.html">'.$mbSettings['PageTitle'].'</a> > <a href="'.$MainURL.'/forum.html#'.$CategoryID.'">'.$CategoryTitle.'</a> > <a href="'.$MainURL.'/forum/'.$BoardID.'.html">'.$BoardTitle.'</a> > <a href="'.$MainURL.'/forum/'.$BoardID.'/'.$ThreadID.'.html">'.$ThreadTitle.'</a> > '.$MsgText[2][101];




			$query = "select * from `".$Settings['DBPrefix']."mb-Categories` order by CategoryOrder asc";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				$CategoryIDs[] = $row['RecordNumber'];
				$CategoryTitles[$row['RecordNumber']] = $row['Title'];
			}
			
			
			$query = "select * from `".$Settings['DBPrefix']."mb-Boards` where MinLevel <= ".$UserLevel." order by BoardOrder asc, Title asc";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				$BoardIDs[$row['Category']][] = $row['RecordNumber'];
				$BoardTitles[$row['Category']][] = $row['Title'];
			}
			
			
			for ($i = 0; $i < count($CategoryIDs); $i++) {
				if (count($BoardTitles[$CategoryIDs[$i]]) > 0) {
								
					$BoardsList .= '<br><br><b>'.$CategoryTitles[$CategoryIDs[$i]].'</b>';
				
					for ($j = 0; $j < count($BoardTitles[$CategoryIDs[$i]]); $j++) {
					
						if ($BoardIDs[$CategoryIDs[$i]][$j] == $BoardID) {
							$Checked = ' checked';
						}
						else {
							$Checked = '';
						}
					
						$BoardsList .= '<br><input type="radio" name="DestinationBoard" value="'.$BoardIDs[$CategoryIDs[$i]][$j].'"'.$Checked.'> '.$BoardTitles[$CategoryIDs[$i]][$j];

				
					}
			
				}
			}

			


			$PageContents = '<br><form name="PostForm" action="'.$MainURL.'/forum/thread-move-save" method="post">
<input type="hidden" name="ThreadID" value="'.$Arguments3.'"><b>'.$MsgText[2][102].':</b>'.$BoardsList.'<br><br><br><input type="submit" value="'.$MsgText[2][101].'" style="'.$FormStyle.'"><br><br><br><br><br><input type="button" value="'.$MsgText[2][103].'" onClick="window.location.href=\''.$MainURL.'/forum/'.$BoardID.'/'.$Arguments3.'.html\'" style="'.$FormStyle.'"></form>';
			
		
		}
		else {
		
			$PageContents = $MsgText[2][100];
		
		}	
	
	}
	else {
	
		$PageContents = $MsgText[2][80];
	
	}
	
?>
