<?

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



	// ========================================================================================
	// admin permission levels page
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_usersandpermissions.gif" width="19" height="20"> '.$MsgText[0][56];
	$BrowserTitle = $MsgText[0][56];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][56];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[6] == 'y') {
		
			ReadFormArguments();
			Global $FormArguments;
			
			if (count($FormArguments) > 0 && $FormArguments['NewLevel'] != '') {
			
			// if they have permission to create a new level this high
			if ($FormArguments['NewLevel'] < $UserLevel) {
			
				$query = "select Permissions from `".$Settings['DBPrefix']."core-Permissions` where Level=".intval($FormArguments['NewLevel'])." LIMIT 1";
			   	$result = mysql_query($query) or die (mysql_error());
				
				if (mysql_num_rows($result) == 0 && $FormArguments['NewLevel'] > 0) {
				
					$NewPermissions = '';
					for ($i = 1; $i <= 1000; $i++) {
						if ($FormArguments['NewPermissions-'.$i] == 'y') {
							$NewPermissions .= $i.'-';
						}
					}
				
					$query = "insert into `".$Settings['DBPrefix']."core-Permissions` (Level, Description, Permissions) values ('".intval($FormArguments['NewLevel'])."', '".$FormArguments['NewName']."', '".$NewPermissions."')";
					$result = mysql_query($query) or die (mysql_error());
					
					
					header('Location: ' . $MainURL.'/admin/levels.html');
				
				}
				else {
					
					$PageContents = $MsgText[0][363];
					
				}
				
				
				}
				else {
					$PageContents = $MsgText[0][98];
				}
			
			}
			else {
				
				$PageContents = $MsgText[0][364].' '.$UserLevel;
				
			}			

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

	}
	else {
	
		RedirectToLogin();
	
	}

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




?>
