<?

/*
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
*/



	// ========================================================================================
	// save cat changes
	// ========================================================================================
	
	
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_articles.gif" width="22" height="21"> '.$MsgText[7][11];
	$BrowserTitle = $MsgText[7][11];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > '.$MsgText[7][11];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[703] == 'y') {
			
			ReadFormArguments();
			Global $FormArguments;
			
			if (count($FormArguments) > 0) {
				
				$PageContents = '';
			
				$FormArguments['CategoryIDToEdit'] = intval($FormArguments['CategoryIDToEdit']);
				
				$query = "select * from `".$Settings['DBPrefix']."na-Categories` where RecordNumber='".$FormArguments['CategoryIDToEdit']."' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$row = mysql_fetch_array($result);
					
										
						if ($FormArguments['DeleteCategory'] == 'y') {
						
							$query = "delete from `".$Settings['DBPrefix']."na-Categories` where RecordNumber='".$FormArguments['CategoryIDToEdit']."' limit 1";
							$result = mysql_query($query) or die (mysql_error());
							
							
							$query = "UPDATE `".$Settings['DBPrefix']."na-Articles` SET Category='0' WHERE Category='".$FormArguments['CategoryIDToEdit']."'";
				  			$result = mysql_query($query) or die (mysql_error());
							
							
							header('Location: ' . $MainURL . '/admin/articles.html');	
						
						}
						else {				
												
							$query = "UPDATE `".$Settings['DBPrefix']."na-Categories` SET CategoryName='".$FormArguments['CategoryName']."', CategoryDescription='".$FormArguments['CategoryDescription']."', Parent='".$FormArguments['Parent']."' WHERE RecordNumber='".$FormArguments['CategoryIDToEdit']."' LIMIT 1";
				  			$result = mysql_query($query) or die (mysql_error());
		
							header('Location: ' . $MainURL . '/admin/articles.html');
												
						
						} // end if not deleting
				
										
				}
				else {
					$PageContents = $MsgText[7][33];				
				}			
			
			}
			else {
				$PageContents = $MsgText[0][98];
			}


		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

	// ========================================================================================




?>
