<?

/*
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 changes to existing
	// ========================================================================================
	
	
	$query = "select * from `".$Settings['DBPrefix']."lm-Settings`";
	$result = mysql_query($query) or die (mysql_error());
	while ($row = mysql_fetch_array($result)) {
		$lmSettings[$row['Name']] = $row['Value'];
	}
	
	
	$PageTitle = $MsgText[8][20];
	$BrowserTitle = $MsgText[8][20];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL.'/admin/links.html">'.$MsgText[8][2].'</a> > '.$MsgText[8][20];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[801] == 'y') {
		
			ReadFormArguments();
			Global $FormArguments;
			
			$FormArguments['CatIDToEdit'] = intval($FormArguments['CatIDToEdit']);
			
			if (count($FormArguments) > 0 && $FormArguments['CatIDToEdit'] > 0) {
			
				if ($FormArguments['DeleteCat'] == 'y') {
				
					$query = "delete from `".$Settings['DBPrefix']."lm-Categories` where RecordNumber='".$FormArguments['CatIDToEdit']."' limit 1";
					$result = mysql_query($query) or die (mysql_error());
					
					$query = "update `".$Settings['DBPrefix']."lm-Links` set Category='0' where Category='".$FormArguments['CatIDToEdit']."'";
					$result = mysql_query($query) or die (mysql_error());
										
					Header('Location: '.$MainURL.'/admin/links.html');
				
				}
				else {
			
					if ($FormArguments['Title'] != '') {
			
						$query = "update `".$Settings['DBPrefix']."lm-Categories` set Title='".$FormArguments['Title']."', Description='".$FormArguments['Description']."', Parent='".$FormArguments['Parent']."' where RecordNumber='".$FormArguments['CatIDToEdit']."' limit 1";
						$result = mysql_query($query) or die (mysql_error());
					
						
						Header('Location: '.$MainURL.'/admin/links.html');
						
					}
					else {
					
						$PageContents = $MsgText[8][21];
				
					}
						
				}				

			}
			else {
				$PageContents = $MsgText[0][98];
			}
		
		} // end if permissions are sufficient
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
				
	
	// ========================================================================================




?>
